File wdmd.init of Package sanlock

#!/bin/sh

### BEGIN INIT INFO
# Provides: wdmd
# Required-Start: $time $syslog $remote_fs
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: starts and stops wdmd daemon
# Description: starts and stops wdmd daemon
### END INIT INFO

WDMDBIN=/usr/sbin/wdmd
WDMDRUNDIR=/var/run/wdmd
WDMDPIDFILE=$WDMDRUNDIR/wdmd.pid

WDMDGROUP="sanlock"
WDMDOPTS="-G $WDMDGROUP"

test -x $WDMDBIN || { echo "$WDMDBIN not installed";
         if [ "$1" = "stop" ]; then exit 0;
	 else exit 5; fi; }

[ -f /etc/sysconfig/wdmd ] && . /etc/sysconfig/wdmd

. /etc/rc.status
rc_reset


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
}

case "$1" in 
    start)
	watchdog_check

	if [ ! -d $WDMDRUNDIR ]; then
		install -d -g $WDMDGROUP -m 775 $WDMDRUNDIR
		[ -x /sbin/restorecon ] && restorecon $WDMDRUNDIR
	fi

        if [ -e $WDMDPIDFILE ]; then
                if checkproc $WDMDBIN; then
                        echo -n "wdmd is already running."
			rc_status -v
                        rc_exit
                else
                        echo "Removing stale PID file $WDMDPIDFILE."
                        rm -f $WDMDPIDFILE
                fi
        fi
        echo -n "Starting wdmd "
        startproc $WDMDBIN $WDMDOPTS
        rc_status -v
	;;
    stop)
        echo -n "Shutting down wdmd "
        killproc -TERM $WDMDBIN > /dev/null 2>&1
        rm -f $WDMDPIDFILE
        rc_status -v
	;;
    try-restart)
        $0 status >/dev/null &&  $0 restart
        rc_status
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    reload)
	killproc -HUP $WDMDBIN
        rc_status -v
        ;;
    status)
        echo -n "Checking status of wdmd "
        checkproc $WDMDBIN
        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
	rc_failed 2
	rc_exit
        ;;
esac
rc_exit
openSUSE Build Service is sponsored by