xref: /unit/pkg/deb/debian/unit.init (revision 1765:8ea20616cf04)
1#!/bin/sh
2#
3# unitd              NGINX Unit
4#
5### BEGIN INIT INFO
6# Provides:          unitd
7# Required-Start:    $network $remote_fs
8# Required-Stop:     $network $remote_fs
9# Default-Start:     2 3 4 5
10# Default-Stop:      0 1 6
11# Short-Description: NGINX Unit
12# Description:       NGINX Unit
13### END INIT INFO
14PATH=/sbin:/bin:/usr/sbin:/usr/bin
15DAEMON=/usr/sbin/unitd
16NAME=unit
17DESC=unitd
18
19#includes lsb functions
20. /lib/lsb/init-functions
21
22test -f $DAEMON || exit 0
23
24umask 022
25
26# Read configuration variable file if it is present
27[ -r /etc/default/$NAME ] && . /etc/default/$NAME
28
29case "$1" in
30    start)
31       	log_daemon_msg "Starting $DESC" "$NAME"
32        if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
33                --exec $DAEMON -- $DAEMON_ARGS; then
34                log_end_msg 0
35        else
36                log_end_msg 1
37        fi
38        ;;
39    status)
40        status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
41        ;;
42    stop)
43        log_daemon_msg "Stopping $DESC" "$NAME"
44        if start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
45                --exec $DAEMON; then
46                log_end_msg 0
47        else
48                log_end_msg 1
49        fi
50        ;;
51   reload|force-reload)
52        echo "Not implemented." >&2
53        exit 1
54        ;;
55    restart)
56        log_action_begin_msg "Restarting $DESC" "$NAME"
57
58        start-stop-daemon --stop --quiet --pidfile \
59                /var/run/$NAME.pid --exec $DAEMON || true
60        sleep 1
61        if start-stop-daemon --start --quiet --pidfile \
62                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_ARGS; then
63                log_end_msg 0
64        else
65                log_end_msg 1
66        fi
67        ;;
68    *)
69        echo "Usage: /etc/init.d/$NAME {start|status|stop|restart|reload|force-reload}" >&2
70        exit 1
71        ;;
72esac
73
74exit 0
75