summaryrefslogtreecommitdiffstats
path: root/system/watchdog/rc.watchdog
blob: 7e07dff61fcca4e44c25f402d1e8228edee88ac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
#
# /etc/rc.d/rc.watchdog
#
# Start/stop/restart the watchdog timer service.

watchdog_start() {
  if [ ! -e /dev/watchdog ]; then
    echo "$0: No /dev/watchdog device node seems to exist on this system."
    echo "$0: A kernel module probably needs to be loaded; please see:"
    echo "$0: /usr/src/linux/Documentation/watchdog/watchdog-api.txt"
    exit 0
  fi
  if [ -x /usr/sbin/watchdog -a -r /etc/watchdog.conf ]; then
    echo "Starting the watchdog timer service:  /usr/sbin/watchdog"
    /usr/sbin/watchdog
  fi
}

watchdog_stop() {
  killall watchdog
}

watchdog_restart() {
  watchdog_stop
  sleep 10 # can take a while to die
  watchdog_start
}

case "$1" in
'start')
  watchdog_start
  ;;
'stop')
  watchdog_stop
  ;;
'restart')
  watchdog_restart
  ;;
*)
  echo $"Usage: $0 {start|stop|restart}"
esac