summaryrefslogtreecommitdiffabout
path: root/init/slackware
Side-by-side diff
Diffstat (limited to 'init/slackware') (more/less context) (ignore whitespace changes)
-rwxr-xr-xinit/slackware76
1 files changed, 76 insertions, 0 deletions
diff --git a/init/slackware b/init/slackware
new file mode 100755
index 0000000..db735ea
--- a/dev/null
+++ b/init/slackware
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+DAEMON=/usr/sbin/varnish-mib
+PIDFILE=/var/run/varnish-mib.pid
+OPTIONS=
+
+# 0 - running
+# 1 - not running
+# 2 - in doubt
+varnish_mib_is_running() {
+ if [ -f $PIDFILE ]; then
+ if [ ! -r $PIDFILE ]; then
+ diag="probably running; $PIDFILE exists, but is not readable"
+ return 2
+ else
+ pid=$(head -n 1 $PIDFILE)
+ if [ -z "$pid" ]; then
+ diag="can't read $PIDFILE"
+ return 2
+ else
+ if kill -0 $pid; then
+ diag="$DAEMON running (pid $pid)"
+ return 0
+ else
+ diag="stale pidfile $PIDFILE"
+ rm $PIDFILE
+ return 2
+ fi
+ fi
+ fi
+ else
+ diag="$DAEMON not running"
+ return 1
+ fi
+}
+
+varnish_mib_status() {
+ varnish_mib_is_running
+ echo $diag
+ exit $?
+}
+
+varnish_mib_start() {
+ if varnish_mib_is_running; then
+ echo $diag
+ else
+ $DAEMON $OPTIONS -p $PIDFILE
+ fi
+}
+
+varnish_mib_stop() {
+ if varnish_mib_is_running; then
+ kill -TERM $pid
+ sleep 2
+ if [ -r $PIDFILE ]; then
+ kill -9 $pid
+ rm -f $PIDFILE;
+ fi
+ else
+ echo $diag
+ fi
+}
+
+case "$1" in
+ start)
+ varnish_mib_start;;
+ stop)
+ varnish_mib_stop;;
+ restart)
+ varnish_mib_restart;;
+ status)
+ varnish_mib_status;;
+ *)
+ echo "usage: $0 start|stop|restart|status"
+esac
+

Return to:

Send suggestions and report system problems to the System administrator.