summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/watchdog/watchdog
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2018-06-13 15:58:23 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-06-18 11:07:57 +0100
commitd200e3196d6646a43be1aa5ec80d299b6524bac0 (patch)
treea7ce98b756967fe0ee45161793cc87dfb49f39e3 /meta/recipes-extended/watchdog/watchdog
parent8aee3cce93666c758c9f01ffbcbdb8da915cb2dc (diff)
downloadpoky-d200e3196d6646a43be1aa5ec80d299b6524bac0.tar.gz
watchdog: fix init script for sysvinit
The current init script is installed from source with redhat style. It does not get configuration from /etc/default/watchdog. We should use debian style init script. Write our own script just like what wd_keepalive does. Also, in the init script, we check the existence of /dev/watchdog to determine whether to start the daemon or not. (From OE-Core rev: a31f8dd34e8ea34dfb087ed464575aa390ece09b) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/watchdog/watchdog')
-rw-r--r--meta/recipes-extended/watchdog/watchdog/watchdog-init.patch56
-rw-r--r--meta/recipes-extended/watchdog/watchdog/watchdog.init110
2 files changed, 110 insertions, 56 deletions
diff --git a/meta/recipes-extended/watchdog/watchdog/watchdog-init.patch b/meta/recipes-extended/watchdog/watchdog/watchdog-init.patch
deleted file mode 100644
index b2765f1908..0000000000
--- a/meta/recipes-extended/watchdog/watchdog/watchdog-init.patch
+++ /dev/null
@@ -1,56 +0,0 @@
1Signed-off-by: Diego Rondini <diego.ml@zoho.com>
2Upstream-Status: Inappropriate
3
4--- watchdog-5.13.orig/redhat/watchdog.init 2014-11-12 17:18:39.125943000 +0100
5+++ watchdog-5.13/redhat/watchdog.init 2014-11-12 18:27:36.189943000 +0100
6@@ -7,7 +7,7 @@
7 # Henning P. Schmiedehausen <hps@tanstaafl.de>
8
9 # Source function library.
10-. /etc/rc.d/init.d/functions
11+. /etc/init.d/functions
12
13 [ -x /usr/sbin/watchdog -a -e /etc/watchdog.conf ] || exit 0
14
15@@ -23,22 +23,22 @@
16
17 start() {
18
19- echo -n $"Starting $prog: "
20+ echo -n "Starting $prog: "
21 if [ -n "$(pidofproc $prog)" ]; then
22- echo -n $"$prog: already running"
23- echo_failure
24+ echo -n "$prog: already running "
25+ failure
26 echo
27 return 1
28 fi
29 if [ "$VERBOSE" = "yes" ]; then
30- daemon /usr/sbin/${prog} -v
31+ /usr/sbin/${prog} -v
32 else
33- daemon /usr/sbin/${prog}
34+ /usr/sbin/${prog}
35 fi
36 RETVAL=$?
37 [ $RETVAL -eq 0 ] && touch $lockfile
38- [ $RETVAL -eq 0 ] && echo_success
39- [ $RETVAL -ne 0 ] && echo_failure
40+ [ $RETVAL -eq 0 ] && success
41+ [ $RETVAL -ne 0 ] && failure
42 echo
43 return $RETVAL
44 }
45@@ -50,8 +50,10 @@
46 # and reboot the box.
47 killproc $prog -TERM
48 RETVAL=$?
49- echo
50 [ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
51+ [ $RETVAL -eq 0 ] && success
52+ [ $RETVAL -ne 0 ] && failure
53+ echo
54 return $RETVAL
55 }
56
diff --git a/meta/recipes-extended/watchdog/watchdog/watchdog.init b/meta/recipes-extended/watchdog/watchdog/watchdog.init
new file mode 100644
index 0000000000..d37107cf0e
--- /dev/null
+++ b/meta/recipes-extended/watchdog/watchdog/watchdog.init
@@ -0,0 +1,110 @@
1#!/bin/sh
2#/etc/init.d/watchdog: start watchdog daemon.
3
4### BEGIN INIT INFO
5# Provides: watchdog
6# Short-Description: Start software watchdog daemon
7# Required-Start: $all
8# Required-Stop: $all
9# Should-Start:
10# Should-Stop:
11# Default-Start: 2 3 4 5
12# Default-Stop: 0 1 6
13### END INIT INFO
14
15PATH=/bin:/usr/bin:/sbin:/usr/sbin
16
17test -x /usr/sbin/watchdog || exit 0
18
19# For configuration of the init script use the file
20# /etc/default/watchdog, do not edit this init script.
21
22# Set run_watchdog to 1 to start watchdog or 0 to disable it.
23run_watchdog=0
24
25# Specify additional watchdog options here (see manpage).
26watchdog_options=""
27
28# Specify module to load
29watchdog_module="none"
30
31[ -e /etc/default/watchdog ] && . /etc/default/watchdog
32
33NAME=watchdog
34DAEMON=/usr/sbin/watchdog
35
36STOP_RETRY_SCHEDULE='TERM/10/forever/KILL/1'
37
38. /etc/init.d/functions
39
40# Mock Debian stuff
41log_begin_msg() {
42 echo -n $*
43}
44
45log_end_msg() {
46 if [ "$1" = "0" ]; then
47 echo 'done'
48 else
49 echo 'error'
50 fi
51}
52
53log_daemon_msg() {
54 echo $*
55}
56
57log_progress_msg() {
58 echo $*
59}
60
61case "$1" in
62 start)
63 if [ $run_watchdog = 1 ]
64 then
65 # do we have to load a module?
66 [ "${watchdog_module:-none}" != "none" ] && /sbin/modprobe $watchdog_module
67
68 # Check /dev/watchdog here because if it does not exist after module loading,
69 # it makes no sense to start the daemon
70 test -e /dev/watchdog || { log_daemon_msg "daemon not start due to lack of /dev/watchdog"; exit 0; }
71
72 log_begin_msg "Starting watchdog daemon..."
73 start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
74 --exec $DAEMON -- $watchdog_options
75 log_end_msg $?
76 fi
77 ;;
78
79 stop)
80 if [ $run_watchdog = 1 ]
81 then
82 log_begin_msg "Stopping watchdog daemon..."
83 start-stop-daemon --stop --quiet --retry $STOP_RETRY_SCHEDULE \
84 --pidfile /var/run/$NAME.pid
85
86 fi
87 ;;
88
89 restart)
90 $0 force-reload
91 ;;
92
93 force-reload)
94 if [ $run_watchdog = 0 ]; then exit 0; fi
95 log_daemon_msg "Restarting $NAME"
96 $0 stop
97 $0 start
98 ;;
99
100 status)
101 status "$DAEMON"
102 ;;
103
104 *)
105 echo "Usage: /etc/init.d/watchdog {start|stop|restart|force-reload|status}"
106 exit 1
107
108esac
109
110exit 0