merge r4529 to trunk
[project/luci.git] / contrib / package / freifunk-watchdog / files / freifunk-watchdog.init
1 #!/bin/sh /etc/rc.common
2
3 START=99
4 PID=/var/run/ffwatchd.pid
5 BIN=/usr/sbin/ffwatchd
6
7 boot()
8 {
9         # If watchdog service is enabled, install cronjob, create device node and start daemon
10         if /etc/init.d/freifunk-watchdog enabled 2>/dev/null; then
11                 if ! grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
12                         echo "* * * * * $BIN running || /etc/init.d/freifunk-watchdog restart" >> /etc/crontabs/root
13                 fi
14
15                 mknod /dev/watchdog c 10 130
16
17                 start
18                 
19         # If service is disabled, find and remove related cronjob
20         elif grep -q "$BIN" /etc/crontabs/root 2>/dev/null; then
21                 sed -i -e "\\'$BIN'd" /etc/crontabs/root
22         fi
23 }
24
25 start()
26 {
27         start-stop-daemon -q -b -m -p $PID -x $BIN -S
28 }
29
30 stop()
31 {
32         start-stop-daemon -q -p $PID -x $BIN -K
33 }