aboutsummaryrefslogtreecommitdiff
path: root/src/watchdog/watchdog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/watchdog/watchdog.sh')
-rwxr-xr-xsrc/watchdog/watchdog.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/watchdog/watchdog.sh b/src/watchdog/watchdog.sh
new file mode 100755
index 0000000..54f7845
--- /dev/null
+++ b/src/watchdog/watchdog.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID="$( cat /run/watchdog.pid 2>/dev/null )"
+[ -r /etc/conf.d/watchdog ] && source /etc/conf.d/watchdog
+
+case "$1" in
+ start)
+ stat_busy "Starting Watchdog Daemon"
+
+ [ -z "$PID" ] && /usr/sbin/watchdog ${WATCHDOG_OPTIONS}
+
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon watchdog
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Watchdog Daemon"
+
+ [ -n "$PID" ] && kill $PID &> /dev/null
+
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon watchdog
+ stat_done
+ fi
+
+ rm -f /run/watchdog.pid
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0