8486e6
#! /bin/sh
8486e6
#
8486e6
# watchdog - a watchdog daemon
8486e6
#
8486e6
# chkconfig: - 27 46
8486e6
# description: A watchdog daemon
8486e6
#
8486e6
# rc file author: Marc Merlin <marcsoft@merlins.org>
8486e6
#                 Henning P. Schmiedehausen <hps@tanstaafl.de>
8486e6
#                 Richard W.M. Jones <rjones@redhat.com>
8486e6
8486e6
# Source function library.
8486e6
. /etc/rc.d/init.d/functions
8486e6
8486e6
[ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0
8486e6
8486e6
VERBOSE="no"
8486e6
if [ -f /etc/sysconfig/watchdog ]; then
8486e6
    . /etc/sysconfig/watchdog
8486e6
fi
8486e6
8486e6
RETVAL=0
8486e6
prog=watchdog
8486e6
pidfile=/var/run/watchdog.pid
8486e6
lockfile=/var/lock/subsys/watchdog
8486e6
8486e6
start() {
8486e6
8486e6
	echo -n $"Starting $prog: "
8486e6
	if [ -n "$(pidofproc $prog)" ]; then
8486e6
		echo -n $"$prog: already running"
8486e6
		echo_failure
8486e6
		echo
8486e6
		return 1
8486e6
	fi
8486e6
	if [ "$VERBOSE" = "yes" ]; then
8486e6
	    daemon /usr/sbin/${prog} -v
8486e6
	else
8486e6
	    daemon /usr/sbin/${prog}
8486e6
        fi
8486e6
	RETVAL=$?
8486e6
	echo
8486e6
	[ $RETVAL -eq 0 ] && touch $lockfile
8486e6
	[ $RETVAL -eq 0 ] && echo_success
8486e6
	[ $RETVAL -ne 0 ] && echo_failure
8486e6
	return $RETVAL
8486e6
}
8486e6
8486e6
stop() {
8486e6
	echo -n "Stopping $prog: "
8486e6
	# We are forcing it to _only_ use -TERM as killproc could use
8486e6
	# -KILL which would result in BMC timer not being set properly 
8486e6
	# and reboot the box.
8486e6
	killproc $prog -TERM
8486e6
	RETVAL=$?
8486e6
	echo
8486e6
	[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
8486e6
	return $RETVAL
8486e6
}
8486e6
8486e6
restart() {
8486e6
  	stop
8486e6
	sleep 6
8486e6
	start
8486e6
}	
8486e6
8486e6
case "$1" in
8486e6
  start)
8486e6
  	start
8486e6
	;;
8486e6
  stop)
8486e6
  	stop
8486e6
	;;
8486e6
  reload|restart)
8486e6
  	restart
8486e6
	;;
8486e6
  condrestart)
8486e6
    if [ -f $lockfile ]; then
8486e6
	restart
8486e6
    fi
8486e6
    ;;
8486e6
  status)
8486e6
	status $prog
8486e6
	RETVAL=$?
8486e6
	;;
8486e6
  *)
8486e6
	echo $"Usage: $0 {start|stop|restart|status|condrestart}"
8486e6
	exit 1
8486e6
esac
8486e6
8486e6
exit $RETVAL