aboutsummaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
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