aboutsummaryrefslogtreecommitdiff
path: root/init/slackware
diff options
context:
space:
mode:
Diffstat (limited to 'init/slackware')
-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
--- /dev/null
+++ b/init/slackware
@@ -0,0 +1,76 @@
1#!/bin/sh
2
3DAEMON=/usr/sbin/varnish-mib
4PIDFILE=/var/run/varnish-mib.pid
5OPTIONS=
6
7# 0 - running
8# 1 - not running
9# 2 - in doubt
10varnish_mib_is_running() {
11 if [ -f $PIDFILE ]; then
12 if [ ! -r $PIDFILE ]; then
13 diag="probably running; $PIDFILE exists, but is not readable"
14 return 2
15 else
16 pid=$(head -n 1 $PIDFILE)
17 if [ -z "$pid" ]; then
18 diag="can't read $PIDFILE"
19 return 2
20 else
21 if kill -0 $pid; then
22 diag="$DAEMON running (pid $pid)"
23 return 0
24 else
25 diag="stale pidfile $PIDFILE"
26 rm $PIDFILE
27 return 2
28 fi
29 fi
30 fi
31 else
32 diag="$DAEMON not running"
33 return 1
34 fi
35}
36
37varnish_mib_status() {
38 varnish_mib_is_running
39 echo $diag
40 exit $?
41}
42
43varnish_mib_start() {
44 if varnish_mib_is_running; then
45 echo $diag
46 else
47 $DAEMON $OPTIONS -p $PIDFILE
48 fi
49}
50
51varnish_mib_stop() {
52 if varnish_mib_is_running; then
53 kill -TERM $pid
54 sleep 2
55 if [ -r $PIDFILE ]; then
56 kill -9 $pid
57 rm -f $PIDFILE;
58 fi
59 else
60 echo $diag
61 fi
62}
63
64case "$1" in
65 start)
66 varnish_mib_start;;
67 stop)
68 varnish_mib_stop;;
69 restart)
70 varnish_mib_restart;;
71 status)
72 varnish_mib_status;;
73 *)
74 echo "usage: $0 start|stop|restart|status"
75esac
76

Return to:

Send suggestions and report system problems to the System administrator.