2012-01-18 23:10:06 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: wdmd
|
2012-01-20 02:07:06 +01:00
|
|
|
# Required-Start: $time $syslog $remote_fs
|
2012-01-18 23:10:06 +01:00
|
|
|
# Required-Stop: $syslog
|
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
2012-01-20 02:07:06 +01:00
|
|
|
# Default-Start: 3 5
|
|
|
|
# Default-Stop: 0 1 2 6
|
2012-01-18 23:10:06 +01:00
|
|
|
# Short-Description: starts and stops wdmd daemon
|
|
|
|
# Description: starts and stops wdmd daemon
|
|
|
|
### END INIT INFO
|
|
|
|
|
2012-12-03 23:15:47 +01:00
|
|
|
WDMDBIN=/usr/sbin/wdmd
|
|
|
|
WDMDRUNDIR=/var/run/wdmd
|
|
|
|
WDMDPIDFILE=$WDMDRUNDIR/wdmd.pid
|
2012-01-18 23:10:06 +01:00
|
|
|
|
|
|
|
WDMDGROUP="sanlock"
|
|
|
|
WDMDOPTS="-G $WDMDGROUP"
|
|
|
|
|
2012-12-03 23:15:47 +01:00
|
|
|
test -x $WDMDBIN || { echo "$WDMDBIN not installed";
|
2012-01-18 23:10:06 +01:00
|
|
|
if [ "$1" = "stop" ]; then exit 0;
|
|
|
|
else exit 5; fi; }
|
|
|
|
|
2012-12-03 23:15:47 +01:00
|
|
|
[ -f /etc/sysconfig/wdmd ] && . /etc/sysconfig/wdmd
|
2012-01-18 23:10:06 +01:00
|
|
|
|
|
|
|
. /etc/rc.status
|
|
|
|
rc_reset
|
|
|
|
|
|
|
|
|
2012-12-03 23:15:47 +01:00
|
|
|
watchdog_check() {
|
|
|
|
if [ ! -c /dev/watchdog ]; then
|
|
|
|
echo -n "Loading the softdog kernel module "
|
|
|
|
modprobe softdog && udevadm settle
|
|
|
|
if [ ! -c /dev/watchdog ]; then
|
|
|
|
rc_failed 1
|
|
|
|
rc_status -v
|
|
|
|
rc_exit
|
|
|
|
fi
|
|
|
|
rc_status -v
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-01-18 23:10:06 +01:00
|
|
|
case "$1" in
|
|
|
|
start)
|
2012-12-03 23:15:47 +01:00
|
|
|
watchdog_check
|
|
|
|
|
|
|
|
if [ ! -d $WDMDRUNDIR ]; then
|
|
|
|
install -d -g $WDMDGROUP -m 775 $WDMDRUNDIR
|
|
|
|
[ -x /sbin/restorecon ] && restorecon $WDMDRUNDIR
|
2012-01-18 23:10:06 +01:00
|
|
|
fi
|
|
|
|
|
2012-12-03 23:15:47 +01:00
|
|
|
if [ -e $WDMDPIDFILE ]; then
|
|
|
|
if checkproc $WDMDBIN; then
|
2012-01-18 23:10:06 +01:00
|
|
|
echo -n "wdmd is already running."
|
|
|
|
rc_status -v
|
2012-12-03 23:15:47 +01:00
|
|
|
rc_exit
|
2012-01-18 23:10:06 +01:00
|
|
|
else
|
2012-12-03 23:15:47 +01:00
|
|
|
echo "Removing stale PID file $WDMDPIDFILE."
|
|
|
|
rm -f $WDMDPIDFILE
|
2012-01-18 23:10:06 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo -n "Starting wdmd "
|
2012-12-03 23:15:47 +01:00
|
|
|
startproc $WDMDBIN $WDMDOPTS
|
2012-01-18 23:10:06 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Shutting down wdmd "
|
2012-12-03 23:15:47 +01:00
|
|
|
killproc -TERM $WDMDBIN > /dev/null 2>&1
|
|
|
|
rm -f $WDMDPIDFILE
|
2012-01-18 23:10:06 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
try-restart)
|
|
|
|
$0 status >/dev/null && $0 restart
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
rc_status
|
|
|
|
;;
|
|
|
|
reload)
|
2012-12-03 23:15:47 +01:00
|
|
|
killproc -HUP $WDMDBIN
|
2012-01-18 23:10:06 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
echo -n "Checking status of wdmd "
|
2012-12-03 23:15:47 +01:00
|
|
|
checkproc $WDMDBIN
|
2012-01-18 23:10:06 +01:00
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
|
|
|
|
rc_failed 2
|
|
|
|
rc_exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
rc_exit
|