#!/bin/sh
#
# chkconfig: - 99 01
# description: bmc-watchdog startup script
# processname: bmc-watchdog
#
### BEGIN INIT INFO
# Provides: bmc-watchdog
# Required-Start: $network $remote_fs $syslog
# Required-Stop:  $network $remote_fs $syslog
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: Start and stop bmc-watchdog
# Description: BMC watchdog timer daemon
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

SourceIfNotEmpty /etc/sysconfig/bmc-watchdog

DAEMON=/usr/sbin/bmc-watchdog
PIDFILE=/var/run/bmc-watchdog.pid
LOCKFILE=/var/lock/subsys/bmc-watchdog
CONFFILE=/etc/sysconfig/bmc-watchdog
RETVAL=0

[ -f $DAEMON ] || exit 5

if [ -r $CONFFILE ]; then
        . $CONFFILE
fi

start()
{
        start_daemon $NICE --lockfile "$LOCKFILE" --expect-user root -- bmc-watchdog $OPTIONS
        RETVAL=$?
        return $RETVAL
}

stop()
{
        stop_daemon --lockfile "$LOCKFILE" --expect-user root -- bmc-watchdog
        RETVAL=$?
        return $RETVAL
}

restart()
{
        stop
        start
}

# See how we were called.
case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart|reload)
                restart
                ;;
        condstop)
                if [ -e "$LOCKFILE" ]; then
                        stop
                fi
                ;;
        condrestart|condreload)
                if [ -e "$LOCKFILE" ]; then
                        restart
                fi
                ;;
        status)
                status --expect-user root -- bmc-watchdog
                RETVAL=$?
                ;;
        *)
                msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
                RETVAL=1
esac

exit $RETVAL
