xref: /unit/pkg/deb/debian/unit.init (revision 786:274c304d7f85)
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=unitd
17DESC=unitd
18
19[ -r /etc/default/${NAME} ] && . /etc/default/${NAME}
20
21#includes lsb functions
22. /lib/lsb/init-functions
23
24test -f $DAEMON || exit 0
25
26umask 022
27
28# Read configuration variable file if it is present
29[ -r /etc/default/$NAME ] && . /etc/default/$NAME
30
31case "$1" in
32    start)
33       	log_daemon_msg "Starting $DESC" "$NAME"
34        if start-stop-daemon --start --quiet --pidfile /run/$NAME.pid \
35                --exec $DAEMON -- $DAEMON_ARGS; then
36                log_end_msg 0
37        else
38                log_end_msg 1
39        fi
40        ;;
41    status)
42        status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
43        ;;
44    stop)
45        log_daemon_msg "Stopping $DESC" "$NAME"
46        if start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
47                --exec $DAEMON; then
48                log_end_msg 0
49        else
50                log_end_msg 1
51        fi
52        ;;
53   reload|force-reload)
54        echo "Not implemented." >&2
55        exit 1
56        ;;
57    restart)
58        log_action_begin_msg "Restarting $DESC" "$NAME"
59
60        start-stop-daemon --stop --quiet --pidfile \
61                /var/run/$NAME.pid --exec $DAEMON || true
62        sleep 1
63        if start-stop-daemon --start --quiet --pidfile \
64                /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_ARGS; then
65                log_end_msg 0
66        else
67                log_end_msg 1
68        fi
69        ;;
70    *)
71        echo "Usage: /etc/init.d/$NAME {start|status|stop|restart|reload|force-reload}" >&2
72        exit 1
73        ;;
74esac
75
76exit 0
77