1#! /bin/bash
2#
3# xen-watchdog
4#
5# chkconfig: 2345 21 79
6# description: Run domain watchdog daemon
7### BEGIN INIT INFO
8# Provides:          xen-watchdog
9# Required-Start:    $syslog $remote_fs
10# Should-Start:      xend
11# Required-Stop:     $syslog $remote_fs
12# Should-Stop:       xend
13# Default-Start:     2 3 5
14# Default-Stop:      0 1 6
15# Short-Description: Start/stop xen-watchdog
16# Description:       Run domain watchdog daemon.
17### END INIT INFO
18#
19
20. @XEN_SCRIPT_DIR@/hotplugpath.sh
21
22DAEMON=${sbindir}/xenwatchdogd
23base=$(basename $DAEMON)
24
25# Source function library.
26if [ -e  /etc/init.d/functions ] ; then
27    . /etc/init.d/functions
28elif [ -e /lib/lsb/init-functions ] ; then
29    . /lib/lsb/init-functions
30    success () {
31        log_success_msg $*
32    }
33    failure () {
34        log_failure_msg $*
35    }
36else
37    success () {
38        echo $*
39    }
40    failure () {
41        echo $*
42    }
43fi
44
45start() {
46	local r
47	echo -n $"Starting domain watchdog daemon: "
48
49	$DAEMON 30 15
50	r=$?
51	[ "$r" -eq 0 ] && success $"$base startup" || failure $"$base startup"
52	echo
53
54	return $r
55}
56
57stop() {
58	local r
59	echo -n $"Stopping domain watchdog daemon: "
60
61	killall -USR1 $base 2>/dev/null
62	r=$?
63	[ "$r" -eq 0 ] && success $"$base stop" || failure $"$base stop"
64	echo
65
66	return $r
67}
68
69case "$1" in
70  start)
71  	start
72	;;
73  stop)
74	stop
75	;;
76  restart)
77	stop
78	start
79	;;
80  status)
81	;;
82  condrestart)
83	stop
84	start
85	;;
86  *)
87	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
88	exit 1
89esac
90
91