]> git.netwichtig.de Git - user/henk/code/puppet/modules/s6.git/blob - files/etc/init.d/s6
fix: s6-svscanctl returns before s6-svscan is really dead, which blocks the new insta...
[user/henk/code/puppet/modules/s6.git] / files / etc / init.d / s6
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides:          s6
5 # Required-Start:    $remote_fs $syslog nftables
6 # Required-Stop:     $remote_fs $syslog nftables
7 # Default-Start:     2 3 4 5
8 # Default-Stop:      0 1 6
9 # Short-Description: Start s6 service supervision suite
10 # Description:       Start s6 service supervision suite
11 ### END INIT INFO
12
13 NAME="s6"
14 DESC="s6 system service supervision suite"
15 DAEMON="/usr/local/bin/s6-svscanboot"
16 SCANDIR="/etc/s6-scandir/"
17 DAEMON_ARGS=${SCANDIR}
18 SCRIPTNAME="/etc/init.d/${NAME}"
19
20 test -x $DAEMON || exit 0
21
22 if test -f /etc/default/${NAME}; then
23         . /etc/default/${NAME}
24 fi
25
26 . /lib/init/vars.sh
27 . /lib/lsb/init-functions
28
29 case "$1" in
30         start)
31                 if $0 status > /dev/null ; then
32                         log_success_msg "$NAME is already running"
33                 else
34                         log_daemon_msg "Starting ${DESC}" "${NAME}"
35                         /sbin/start-stop-daemon \
36                                 --start \
37                                 --oknodo \
38                                 --make-pidfile \
39                                 --pidfile /run/s6-svscan.pid \
40                                 --background \
41                                 --chdir "${SCANDIR}" \
42                                 --exec "${DAEMON}" \
43                                 -- "${DAEMON_ARGS}"
44                         log_end_msg $?
45                 fi
46                 ;;
47         stop)
48                 log_daemon_msg "Stopping ${DESC}" "${NAME}"
49                 /usr/bin/s6-svscanctl -t "${SCANDIR}"
50                 if test $? = 111; then
51                         /sbin/start-stop-daemon \
52                                 --stop \
53                                 --oknodo \
54                                 --remove-pidfile \
55                                 --pidfile /run/s6-svscan.pid \
56                                 --retry TERM/60/KILL/10 \
57                                 --exec /usr/bin/s6-svscan
58                         /sbin/start-stop-daemon \
59                                 --stop \
60                                 --oknodo \
61                                 --retry TERM/60 \
62                                 --exec /usr/bin/s6-supervise
63                 fi
64                 while $0 status
65                 do
66                         sleep 0.1
67                 done
68                 log_end_msg $?
69                 ;;
70         force-reload|restart)
71                 $0 stop
72                 $0 start
73                 ;;
74         status)
75                 /usr/bin/s6-svscanctl "${SCANDIR}"
76                 exitcode=$?
77                 case "$exitcode" in
78                         0)
79                                 log_success_msg "$NAME is running"
80                                 return ${exitcode}
81                                 ;;
82                         100)
83                                 log_failure_msg "$NAME is not running"
84                                 return ${exitcode}
85                                 ;;
86                         *)
87                                 log_failure_msg "$NAME has some problem, exit code was ${exitcode}"
88                                 return ${exitcode}
89                                 ;;
90                 esac
91                 ;;
92         *)
93                 echo "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload|status}"
94                 exit 1
95                 ;;
96 esac
97
98 exit 0