summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorHendrik Jäger <gitcommit@henk.geekmail.org>2022-05-22 19:26:25 +0200
committerHendrik Jäger <gitcommit@henk.geekmail.org>2022-05-22 19:29:02 +0200
commit4e7e16252670533a7eed9568b660e6fdd574e5e1 (patch)
tree76e37cf265136e234c8a00db3b03f8cd0ebd4d40 /files
parent6695957284364e91c83f013086dd6aaa7b9efb4f (diff)
feat: a proper initscript allows proper handling of the processes, especially stopping
Diffstat (limited to 'files')
-rw-r--r--files/etc/init.d/s675
1 files changed, 70 insertions, 5 deletions
diff --git a/files/etc/init.d/s6 b/files/etc/init.d/s6
index 59de3fa..ef577a0 100644
--- a/files/etc/init.d/s6
+++ b/files/etc/init.d/s6
@@ -1,4 +1,4 @@
-#!/usr/bin/env /lib/init/init-d-script
+#!/bin/sh
### BEGIN INIT INFO
# Provides: s6
@@ -10,9 +10,74 @@
# 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