#! /bin/bash
#
# xen-watchdog
#
# chkconfig: 2345 21 79
# description: Run domain watchdog daemon
### BEGIN INIT INFO
# Provides:          xen-watchdog
# Required-Start:    $syslog $remote_fs
# Should-Start:      xend
# Required-Stop:     $syslog $remote_fs
# Should-Stop:       xend
# Default-Start:     2 3 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop xen-watchdog
# Description:       Run domain watchdog daemon.
### END INIT INFO
#

. /etc/xen/scripts/hotplugpath.sh

LOCKFILE=${XEN_LOCK_DIR}/subsys/xenwatchdogd
xencommons_config=/etc/sysconfig

test -f $xencommons_config/xencommons && . $xencommons_config/xencommons

test -n "$XENWATCHDOGD_ARGS" || XENWATCHDOGD_ARGS='30 15'
DAEMON=${sbindir}/xenwatchdogd

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

start() {
	start_daemon --lockfile "$LOCKFILE" --expect-user root -- $DAEMON 30 15
	RETVAL=$?
	return $RETVAL
}

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

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	status)
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$LOCKFILE" ]; then
			stop
			start
		fi
		;;
	*)
		echo $"Usage: $0 {start|stop|status|restart|condstop|condrestart}"
		exit 1
esac

