3 # chkconfig: 12345 89 89
4 # description: A software watchdog
5 # rc file author: Marc Merlin <marcsoft@merlins.org>
6 # Henning P. Schmiedehausen <hps@tanstaafl.de>
7 # Note that even though chkconfig says that this should be run at runlevel 1,
8 # RH by default won't do this, so the RPM applies an ugly patch to
9 # /etc/rc.d/init.d/single so that if you go from RL 3 to RL 1, watchdog is
10 # restarted anyway (if it's not, it can cause the kernel to reboot your machine
11 # depending on whether your kernel was compiled with CONFIG_WATCHDOG_NOWAYOUT)
13 # I have filed a bug with RH about this, and I hope they will change their
14 # single script to allow for other scripts to be run in RL 1.
16 # Source function library.
17 . /etc/rc.d/init.d/functions
19 [ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0
21 WATCHDOG_OOM_ADJUST="-1000"
23 if [ -f /etc/sysconfig/watchdog ]; then
24 . /etc/sysconfig/watchdog
28 if [ -e /var/run/watchdog.pid ]; then
29 for pid in $(cat /var/run/watchdog.pid); do
30 if [ -w "/proc/$pid/oom_score_adj" ]; then
31 echo "$WATCHDOG_OOM_ADJUST" > "/proc/$pid/oom_score_adj" 2> /dev/null || :
38 if [ ! -f /var/lock/subsys/watchdog ]; then
41 if [ -z "$WATCHDOG_MODULES" ]; then
42 # preload software module
43 modprobe -s softdog > /dev/null 2>&1
45 for module in $WATCHDOG_MODULES; do
46 if [ "$module" = "ipmi_watchdog" ]; then
47 modprobe -s ipmi_si > /dev/null 2>&1
48 modprobe -s ipmi_devintf > /dev/null 2>&1
50 modprobe -s $module > /dev/null 2>&1
54 if [ "${VERBOSE}" = "yes" ]; then
61 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/watchdog
63 msg_already_running watchdog
68 if [ -f /var/lock/subsys/watchdog ]; then
71 # If you compiled your kernel with CONFIG_WATCHDOG_NOWAYOUT, you may
72 # not want to remove the module as sometimes /etc/rc.d/init.d/halt
73 # will hang on umounting some remote nfs partition or for some other
74 # reason, and you may then want the kernel to reboot by itself.
75 # However, this means that if you stop watchdog, your system has one
76 # minute to reboot cleanly, or it will be rebooted by the kernel. If
77 # this behavior isn't what you want, just uncomment the following
79 if [ "$WATCHDOG_UNLOAD" = "yes" ]; then
80 if [ -z "$WATCHDOG_MODULES" ]; then
81 # try to unload software module
82 rmmod -s softdog > /dev/null 2>&1
84 for module in $WATCHDOG_MODULES; do
85 rmmod -s $module > /dev/null 2>&1
90 rm -f /var/lock/subsys/watchdog >/dev/null 2>&1
92 msg_not_running watchdog
97 if [ -f /var/lock/subsys/watchdog ]; then
101 msg_not_running watchdog
107 # See how we were called.
115 restart|force-reload)
130 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"