1 |
#! /bin/sh |
2 |
# |
3 |
# chkconfig: - 27 46 |
4 |
# description: A software watchdog |
5 |
# |
6 |
# rc file author: Marc Merlin <marcsoft@merlins.org> |
7 |
# Henning P. Schmiedehausen <hps@tanstaafl.de> |
8 |
|
9 |
# Source function library. |
10 |
. /etc/rc.d/init.d/functions |
11 |
|
12 |
[ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0 |
13 |
|
14 |
VERBOSE="no" |
15 |
if [ -f /etc/sysconfig/watchdog ]; then |
16 |
. /etc/sysconfig/watchdog |
17 |
fi |
18 |
|
19 |
RETVAL=0 |
20 |
prog=watchdog |
21 |
pidfile=/var/run/watchdog.pid |
22 |
lockfile=/var/lock/subsys/watchdog |
23 |
|
24 |
start() { |
25 |
|
26 |
echo -n $"Starting $prog: " |
27 |
if [ -n "$(pidofproc $prog)" ]; then |
28 |
echo -n $"$prog: already running" |
29 |
echo_failure |
30 |
echo |
31 |
return 1 |
32 |
fi |
33 |
if [ "$VERBOSE" = "yes" ]; then |
34 |
daemon /usr/sbin/${prog} -v |
35 |
else |
36 |
daemon /usr/sbin/${prog} |
37 |
fi |
38 |
RETVAL=$? |
39 |
[ $RETVAL -eq 0 ] && touch $lockfile |
40 |
[ $RETVAL -eq 0 ] && echo_success |
41 |
[ $RETVAL -ne 0 ] && echo_failure |
42 |
echo |
43 |
return $RETVAL |
44 |
} |
45 |
|
46 |
stop() { |
47 |
echo -n "Stopping $prog: " |
48 |
# We are forcing it to _only_ use -TERM as killproc could use |
49 |
# -KILL which would result in BMC timer not being set properly |
50 |
# and reboot the box. |
51 |
killproc $prog -TERM |
52 |
RETVAL=$? |
53 |
echo |
54 |
[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile |
55 |
return $RETVAL |
56 |
} |
57 |
|
58 |
restart() { |
59 |
stop |
60 |
sleep 6 |
61 |
start |
62 |
} |
63 |
|
64 |
case "$1" in |
65 |
start) |
66 |
start |
67 |
;; |
68 |
stop) |
69 |
stop |
70 |
;; |
71 |
reload|restart) |
72 |
restart |
73 |
;; |
74 |
condrestart) |
75 |
if [ -f $lockfile ]; then |
76 |
restart |
77 |
fi |
78 |
;; |
79 |
status) |
80 |
status $prog |
81 |
RETVAL=$? |
82 |
;; |
83 |
*) |
84 |
echo $"Usage: $0 {start|stop|restart|status|condrestart}" |
85 |
exit 1 |
86 |
esac |