summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/watchdog/watchdog/watchdog.init
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended/watchdog/watchdog/watchdog.init')
-rw-r--r--meta/recipes-extended/watchdog/watchdog/watchdog.init110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-extended/watchdog/watchdog/watchdog.init b/meta/recipes-extended/watchdog/watchdog/watchdog.init
new file mode 100644
index 0000000000..d37107cf0e
--- /dev/null
+++ b/meta/recipes-extended/watchdog/watchdog/watchdog.init
@@ -0,0 +1,110 @@
1#!/bin/sh
2#/etc/init.d/watchdog: start watchdog daemon.
3
4### BEGIN INIT INFO
5# Provides: watchdog
6# Short-Description: Start software watchdog daemon
7# Required-Start: $all
8# Required-Stop: $all
9# Should-Start:
10# Should-Stop:
11# Default-Start: 2 3 4 5
12# Default-Stop: 0 1 6
13### END INIT INFO
14
15PATH=/bin:/usr/bin:/sbin:/usr/sbin
16
17test -x /usr/sbin/watchdog || exit 0
18
19# For configuration of the init script use the file
20# /etc/default/watchdog, do not edit this init script.
21
22# Set run_watchdog to 1 to start watchdog or 0 to disable it.
23run_watchdog=0
24
25# Specify additional watchdog options here (see manpage).
26watchdog_options=""
27
28# Specify module to load
29watchdog_module="none"
30
31[ -e /etc/default/watchdog ] && . /etc/default/watchdog
32
33NAME=watchdog
34DAEMON=/usr/sbin/watchdog
35
36STOP_RETRY_SCHEDULE='TERM/10/forever/KILL/1'
37
38. /etc/init.d/functions
39
40# Mock Debian stuff
41log_begin_msg() {
42 echo -n $*
43}
44
45log_end_msg() {
46 if [ "$1" = "0" ]; then
47 echo 'done'
48 else
49 echo 'error'
50 fi
51}
52
53log_daemon_msg() {
54 echo $*
55}
56
57log_progress_msg() {
58 echo $*
59}
60
61case "$1" in
62 start)
63 if [ $run_watchdog = 1 ]
64 then
65 # do we have to load a module?
66 [ "${watchdog_module:-none}" != "none" ] && /sbin/modprobe $watchdog_module
67
68 # Check /dev/watchdog here because if it does not exist after module loading,
69 # it makes no sense to start the daemon
70 test -e /dev/watchdog || { log_daemon_msg "daemon not start due to lack of /dev/watchdog"; exit 0; }
71
72 log_begin_msg "Starting watchdog daemon..."
73 start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
74 --exec $DAEMON -- $watchdog_options
75 log_end_msg $?
76 fi
77 ;;
78
79 stop)
80 if [ $run_watchdog = 1 ]
81 then
82 log_begin_msg "Stopping watchdog daemon..."
83 start-stop-daemon --stop --quiet --retry $STOP_RETRY_SCHEDULE \
84 --pidfile /var/run/$NAME.pid
85
86 fi
87 ;;
88
89 restart)
90 $0 force-reload
91 ;;
92
93 force-reload)
94 if [ $run_watchdog = 0 ]; then exit 0; fi
95 log_daemon_msg "Restarting $NAME"
96 $0 stop
97 $0 start
98 ;;
99
100 status)
101 status "$DAEMON"
102 ;;
103
104 *)
105 echo "Usage: /etc/init.d/watchdog {start|stop|restart|force-reload|status}"
106 exit 1
107
108esac
109
110exit 0