#!/bin/sh
#
# watchdog         
#
# chkconfig: 345 15 55
# description:  watchdog checks to make sure that the system  is not
#		hung for more than 5 minutes.  dogarm set the time to 5 minutes
#		and causes a reset on expiration.  The, it runs dogreset, which
#		starts the time, and finally it runs deadman, which wakes every
# 		minute and resets the timer        
# 		dogdisarm disables the system reset on expiration.
#

[ -f /usr/local/sbin/rc.watchdog ] || exit 0

# See how we were called.
case "$1" in
  start)
	# Start watchdog.
		echo "Starting watchdog timer and deadman process"
		/usr/local/bin/dogarm
		/usr/local/bin/dogreset
		/usr/local/bin/deadman 1>&- 2>1 <&- &
        ;;
  stop)
	# Stop watchdog.
		echo -n "disarming watchdog "
		/usr/local/bin/dogdisarm
        pross="$(ps ax | grep /usr/local/bin/deadman | grep -v grep | awk '{print $1}')"
		kill -9 $pross
		;;
  *)
        echo "Usage: watchdog {start|stop}"
        exit 1
esac

exit 0
