File: init

package info (click to toggle)
watchdog 5.4-10lenny2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 936 kB
  • ctags: 684
  • sloc: ansic: 6,294; sh: 1,266; makefile: 72
file content (114 lines) | stat: -rw-r--r-- 2,643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/sh
#/etc/init.d/watchdog: start watchdog daemon.

### BEGIN INIT INFO
# Provides:          watchdog
# Short-Description: Start software watchdog daemon
# Required-Start:    $local_fs $remote_fs $syslog
# Required-Stop:     $local_fs $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
### END INIT INFO

PATH=/bin:/usr/bin:/sbin:/usr/sbin

test -x /usr/sbin/watchdog || exit 0

# For configuration of the init script use the file
# /etc/default/watchdog, do not edit this init script.

# Set run_watchdog to 1 to start watchdog or 0 to disable it.
run_watchdog=0

# Specify additional watchdog options here (see manpage).
watchdog_options=""

# Specify module to load
watchdog_module="none"

[ -e /etc/default/watchdog ] && . /etc/default/watchdog

NAME=watchdog
KEEPALIVE_NAME=wd_keepalive

DAEMON=/usr/sbin/watchdog
KEEPALIVE_DAEMON=/usr/sbin/wd_keepalive

STOP_RETRY_SCHEDULE='TERM/10/forever/KILL/1'

case "$1" in
  start)
    if [ $run_watchdog = 1 ]
    then
    	# do we have to load a module?
	[ ${watchdog_module:-none} != "none" ] && /sbin/modprobe $watchdog_module
	# make sure that wd_keepalive is stopped
	echo -n "Stopping watchdog keepalive daemon: "
        if start-stop-daemon --stop --quiet --oknodo --retry $STOP_RETRY_SCHEDULE \
            --pidfile /var/run/$KEEPALIVE_NAME.pid
	then
		echo wd_keepalive.
	else
		echo
	fi

	echo -n "Starting watchdog daemon: "
	if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
	    --exec $DAEMON -- $watchdog_options
	then
	    echo watchdog.
	else
	    echo
	fi
    fi
    ;;

  stop)
    if [ $run_watchdog = 1 ]
    then
	echo -n "Stopping watchdog daemon: "
	if start-stop-daemon --stop --quiet --retry $STOP_RETRY_SCHEDULE \
	    --pidfile /var/run/$NAME.pid
	then
	    echo watchdog.
	    # make sure that wd_keepalive is started
	    echo -n "Starting watchdog keepalive daemon: "
	    if start-stop-daemon --start --quiet --pidfile /var/run/$KEEPALIVE_NAME.pid \
	        --exec $KEEPALIVE_DAEMON -- $watchdog_options
	    then
		echo wd_keepalive.
	    else
		echo
	    fi
	else
	    echo
	fi
    fi
    ;;

  restart)
    $0 force-reload
    ;;

  force-reload)
    if [ $run_watchdog = 0 ]; then exit 0; fi
    echo -n "Restarting $NAME daemon."
    start-stop-daemon --stop --pidfile /var/run/$NAME.pid --quiet \
	--retry $STOP_RETRY_SCHEDULE
    echo -n "."
    if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
	--exec $DAEMON -- $watchdog_options
    then
	echo "done."
    else
	echo
    fi
    ;;

  *)
    echo "Usage: /etc/init.d/watchdog {start|stop|restart|force-reload}"
    exit 1

esac

exit 0