From 8a1a1eee42bf25ca824b008f70bb8f646a9e89e1 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 30 Jun 2021 17:59:15 -0400 Subject: [PATCH] Prototype init script It should work, but testing it is not altogether obvious --- dist/init.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/dist/init.sh b/dist/init.sh index f36c605d..a3b4d945 100644 --- a/dist/init.sh +++ b/dist/init.sh @@ -12,6 +12,66 @@ # Description: The Arsse is a multi-protocol Web newsfeed synchronization service ### END INIT INFO -NAME=arsse -DAEMON=/usr/bin/arsse +# This script is designed for Debian; some adaptation will be required for other systems +NAME=arsse +DESC=newsfeed synchronization server +PIDFILE=/run/arsse.pid +DAEMON=/usr/bin/$NAME + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +arsse_start() { + touch "$PIDFILE" + chown arsse:arsse "$PIDFILE" + $DAEMON daemon --fork "$PIDFILE" || return 2 +} + +arsse_stop() { + killproc -p "$PIDFILE" "$DAEMON" +} + +arsse_reload() { + killproc -p "$PIDFILE" "$DAEMON" HUP +} + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + if pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then + return 1 + fi + arsse_start + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + arsse_stop + ;; + restart) + log_daemon_msg "Restarting $DESC" "$NAME" + if pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then + arsse_stop + fi + arsse_start + ;; + try-restart) + if pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then + log_daemon_msg "Restarting $DESC" "$NAME" + arsse_stop + arsse_start + fi + ;; + reload|force-reload) + log_daemon_msg "Reloading $DESC" "$NAME" + arsse_reload + ;; + status) + status_of_proc -p $PIDFILE $DAEMON $NAME + exit $? + ;; + *) + echo "Usage: $0 {start|stop|restart|try-restart|reload|status}" >&2 + exit 3 + ;; +esac