blob: 5ddd94a3d6001861b8009887e5f15b7734edaf38 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001#!/bin/sh
2#
3### BEGIN INIT INFO
4# Provides: watchquagga
5# Required-Start: $local_fs $network $remote_fs $syslog
6# Required-Stop: $local_fs $network $remote_fs $syslog
7# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 6
9# Short-Description: start and stop the Quagga watchdog
10### END INIT INFO
11
12PATH=/bin:/usr/bin:/sbin:/usr/sbin
13
14# Load configuration
15test -f /etc/default/watchquagga && . /etc/default/watchquagga
16
17# Check that there are daemons to be monitored.
18[ -z "$watch_daemons" ] && exit 0
19
20pidfile="/var/run/quagga/watchquagga.pid"
21
22case "$1" in
23 start)
24 echo -n "Starting quagga watchdog daemon: watchquagga"
25 start-stop-daemon --start \
26 --pidfile $pidfile \
27 --exec /usr/sbin/watchquagga \
28 -- -d $watch_options $watch_daemons
29 echo "."
30 ;;
31
32 stop)
33 echo -n "Stopping quagga watchdog daemon: watchquagga"
34 start-stop-daemon --stop --quiet \
35 --pidfile $pidfile
36 echo "."
37 ;;
38
39 status)
40 echo -n "watchquagga "
41 res=1
42 [ -e $pidfile ] && kill -0 `cat $pidfile` 2> /dev/null
43 if [ $? -eq 0 ]; then
44 echo "(pid `cat $pidfile`) is running..."
45 res=0
46 else
47 echo "is stopped..."
48 fi
49 exit $res
50 ;;
51
52 restart|force-reload)
53 $0 stop $2
54 sleep 1
55 $0 start $2
56 ;;
57
58 *)
59 echo "Usage: /etc/init.d/watchquagga {start|stop|restart|force-reload}"
60 exit 1
61 ;;
62esac
63
64exit 0