aboutsummaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2021-08-09 16:25:42 +0200
committerWojtek Kosior <koszko@koszko.org>2021-08-10 14:15:02 +0200
commitf1894d8aba1f8ae4a52dafc50b0a138978607bc4 (patch)
tree6e055db7ed76375c3fffb84b655f29faecffe7de /daemon
parent834df7ce46e7e8c79840c99baa505d90b4c732c4 (diff)
downloadhydrilla-f1894d8aba1f8ae4a52dafc50b0a138978607bc4.tar.gz
hydrilla-f1894d8aba1f8ae4a52dafc50b0a138978607bc4.zip
add sysv init script
Diffstat (limited to 'daemon')
-rw-r--r--daemon/sysv.in78
1 files changed, 78 insertions, 0 deletions
diff --git a/daemon/sysv.in b/daemon/sysv.in
new file mode 100644
index 0000000..cec25f5
--- /dev/null
+++ b/daemon/sysv.in
@@ -0,0 +1,78 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: @hydrilla@
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Hydrilla repository server
+# Description: Provides HTTP service to serve packages for Hachette
+### END INIT INFO
+
+set -e
+if [ ! -f "@bindir@/@hydrilla@" ]
+then
+ exit 5
+fi
+
+mkdir -p "@runstatedir@"
+mkdir -p "@logdir@"
+
+case "$1" in
+start)
+ if [ -f "@runstatedir@/@hydrilla@.pid" ]
+ then
+ if pgrep -F "@runstatedir@/@hydrilla@.pid" @hydrilla@
+ then
+ exit 0
+ else
+ echo "@hydrilla@ has a stale pid file" >&2
+ exit 1
+ fi
+ else
+ daemonize \
+ -a \
+ -e "@logdir@/@hydrilla@-stderr.log" \
+ -o "@logdir@/@hydrilla@-stdout.log" \
+ -p "@runstatedir@/@hydrilla@.pid" \
+ -E "HYDRILLA_WAIT_SIGTERM=yes" \
+ @bindir@/@hydrilla@
+ fi
+ ;;
+stop)
+ if [ -f "@runstatedir@/@hydrilla@.pid" ]
+ then
+ pkill -F "@runstatedir@/@hydrilla@.pid" @hydrilla@ || {
+ exit 1
+ }
+ rm -f "@runstatedir@/@hydrilla@.pid"
+ exit 0
+ else
+ exit 0
+ fi
+ ;;
+status)
+ if [ -f "@runstatedir@/@hydrilla@.pid" ]
+ then
+ if pgrep -F "@runstatedir@/@hydrilla@.pid" @hydrilla@
+ then
+ echo "@hydrilla@ is running"
+ exit 0
+ else
+ echo "@hydrilla@ has a stale pid file"
+ exit 1
+ fi
+ else
+ echo "@hydrilla@ is not running"
+ exit 3
+ fi
+ ;;
+restart|force-reload)
+ "$0" stop
+ "$0" start
+ ;;
+*)
+ echo "Usage: $0 (start|stop|status|restart|force-reload)"
+ exit 3
+ ;;
+esac