]> git.netwichtig.de Git - user/henk/code/puppet/modules/s6.git/commitdiff
feat: a proper initscript allows proper handling of the processes, especially stopping
authorHendrik Jäger <gitcommit@henk.geekmail.org>
Sun, 22 May 2022 17:26:25 +0000 (19:26 +0200)
committerHendrik Jäger <gitcommit@henk.geekmail.org>
Sun, 22 May 2022 17:29:02 +0000 (19:29 +0200)
files/etc/init.d/s6

index 59de3faf43ec13c8dd92bd3e02de02571e5078e4..ef577a06572953707f9b79c9839e630035f7bbb2 100644 (file)
@@ -1,4 +1,4 @@
-#!/usr/bin/env /lib/init/init-d-script
+#!/bin/sh
 
 ### BEGIN INIT INFO
 # Provides:          s6
 # Description:       Start s6 service supervision suite
 ### END INIT INFO
 
+NAME="s6"
+DESC="s6 system service supervision suite"
 DAEMON="/usr/local/bin/s6-svscanboot"
-DAEMON_ARGS="/etc/s6-services"
+SCANDIR="/etc/s6-services/"
+DAEMON_ARGS=${SCANDIR}
+PIDFILE="/var/run/s6.pid"
+SCRIPTNAME="/etc/init.d/${NAME}"
 
-do_stop_cmd_override() {
-       /usr/bin/s6-svscanctl -t /etc/s6-services/
-}
+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