summaryrefslogtreecommitdiff
path: root/files/etc/init.d/s6
blob: 371e53ef313f488b2bc9c36ca0c7803625690cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

### BEGIN INIT INFO
# Provides:          s6
# Required-Start:    $remote_fs $syslog nftables
# Required-Stop:     $remote_fs $syslog nftables
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start s6 service supervision suite
# Description:       Start s6 service supervision suite
### END INIT INFO

NAME="s6"
DESC="s6 system service supervision suite"
DAEMON="/usr/local/bin/s6-svscanboot"
SCANDIR="/etc/s6-scandir/"
DAEMON_ARGS=${SCANDIR}
SCRIPTNAME="/etc/init.d/${NAME}"

test -x $DAEMON || exit 0

if test -f /etc/default/${NAME}; then
	. /etc/default/${NAME}
fi

. /lib/init/vars.sh
. /lib/lsb/init-functions

case "$1" in
	start)
		if $0 status > /dev/null ; then
			log_success_msg "$NAME is already running"
		else
			log_daemon_msg "Starting ${DESC}" "${NAME}"
			/sbin/start-stop-daemon \
				--start \
				--oknodo \
				--chdir "${SCANDIR}" \
				--exec "${DAEMON}" \
				-- "${DAEMON_ARGS}"
			log_end_msg $?
		fi
		;;
	stop)
		log_daemon_msg "Stopping ${DESC}" "${NAME}"
		/usr/bin/s6-svscanctl -t "${SCANDIR}"
		if test $? = 111; then
			/sbin/start-stop-daemon \
				--stop \
				--oknodo \
				--retry TERM/60/KILL/10 \
				--exec /usr/bin/s6-svscan
			/sbin/start-stop-daemon \
				--stop \
				--oknodo \
				--retry TERM/60 \
				--exec /usr/bin/s6-supervise
		fi
		log_end_msg $?
		;;
	force-reload|restart)
		$0 stop
		$0 start
		;;
	status)
		status_of_proc ${DAEMON} s6 && exit 0 || exit $?
		;;
	*)
		echo "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload|status}"
		exit 1
		;;
esac

exit 0