#!/bin/sh
#
# chkconfig: - 99 01
# description: bmc-watchdog startup script
#
DAEMON=/usr/sbin/bmc-watchdog
PIDFILE=/var/run/freeipmi-bmc-watchdog.pid
LOCKFILE=/var/lock/subsys/freeipmi-bmc-watchdog
CONFFILE=/etc/sysconfig/freeipmi-bmc-watchdog

. /etc/rc.d/init.d/functions

RETVAL=0

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

case "$1" in
   start)
      echo -n "Starting bmc-watchdog: "
      [ -f $DAEMON ] || exit 1

      # Default deamon mode
      #
      # timer use = SMS/OS
      # pre-timeout interrupt = none
      # action = reset
      # -F, -P, -L, -S, -O - clear flags
      # initial-countdown = 900 seconds (15 mins)
      # reset-period = 60 seconds

      daemon -20 $DAEMON $OPTIONS
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && touch $LOCKFILE
	;;

  stop)
      echo -n "Shutting down bmc-watchdog: "
      killproc bmc-watchdog
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
	;;

  restart|reload)
   	$0 stop
   	$0 start
   	RETVAL=$?
	;;
  status)
   	status bmc-watchdog
   	RETVAL=$?
	;;
  condrestart)
        if test -e $LOCKFILE; then \
            $0 stop; \
            $0 start; \
            RETVAL=$?; \
        fi
        ;;
  *)
	echo "Usage: $0 {start|stop|restart|status|condrestart}"
	exit 1
esac

exit $RETVAL
