summaryrefslogtreecommitdiff
path: root/files/etc/init.d/s6
blob: a30790887b7c2be042331722e35bb03d3c5822d3 (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
75
76
77
78
79
80
81
82
83
#!/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}
PIDFILE="/var/run/s6.pid"
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}" \
				--startas "${DAEMON}" \
				--background \
				--make-pidfile \
				--pidfile "${PIDFILE}" \
				-- "${DAEMON_ARGS}"
			log_end_msg $?
		fi
		;;
	stop)
		log_daemon_msg "Stopping ${DESC}" "${NAME}"
		/sbin/start-stop-daemon \
			--stop \
			--oknodo \
			--retry TERM/60/QUIT/60 \
			--remove-pidfile \
			--pidfile "${PIDFILE}"
		if test $? = 2; 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 -p ${PIDFILE} ${DAEMON} s6 && exit 0 || exit $?
		;;
	*)
		echo "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload|status}"
		exit 1
		;;
esac

exit 0