summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
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
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')
-rw-r--r--meta/recipes-extended/watchdog/watchdog/watchdog-init.patch56
-rw-r--r--meta/recipes-extended/watchdog/watchdog/watchdog.init110
-rw-r--r--meta/recipes-extended/watchdog/watchdog_5.15.bb6
3 files changed, 113 insertions, 59 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
diff --git a/meta/recipes-extended/watchdog/watchdog_5.15.bb b/meta/recipes-extended/watchdog/watchdog_5.15.bb
index 8353ec0d20..1acab2e9e7 100644
--- a/meta/recipes-extended/watchdog/watchdog_5.15.bb
+++ b/meta/recipes-extended/watchdog/watchdog_5.15.bb
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=ecc0551bf54ad97f6b541720f84d6569"
11SRC_URI = "${SOURCEFORGE_MIRROR}/watchdog/watchdog-${PV}.tar.gz \ 11SRC_URI = "${SOURCEFORGE_MIRROR}/watchdog/watchdog-${PV}.tar.gz \
12 file://0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch \ 12 file://0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch \
13 file://0001-watchdog-remove-interdependencies-of-watchdog-and-wd.patch \ 13 file://0001-watchdog-remove-interdependencies-of-watchdog-and-wd.patch \
14 file://watchdog-init.patch \ 14 file://watchdog.init \
15 file://wd_keepalive.init \ 15 file://wd_keepalive.init \
16" 16"
17 17
@@ -31,7 +31,7 @@ EXTRA_OECONF += " --disable-nfs "
31 31
32INITSCRIPT_PACKAGES = "${PN} ${PN}-keepalive" 32INITSCRIPT_PACKAGES = "${PN} ${PN}-keepalive"
33 33
34INITSCRIPT_NAME_${PN} = "watchdog.sh" 34INITSCRIPT_NAME_${PN} = "watchdog"
35INITSCRIPT_PARAMS_${PN} = "start 25 1 2 3 4 5 . stop 85 0 6 ." 35INITSCRIPT_PARAMS_${PN} = "start 25 1 2 3 4 5 . stop 85 0 6 ."
36 36
37INITSCRIPT_NAME_${PN}-keepalive = "wd_keepalive" 37INITSCRIPT_NAME_${PN}-keepalive = "wd_keepalive"
@@ -49,7 +49,7 @@ do_install_append() {
49 install -m 0644 ${S}/debian/watchdog.service ${D}${systemd_system_unitdir} 49 install -m 0644 ${S}/debian/watchdog.service ${D}${systemd_system_unitdir}
50 install -m 0644 ${S}/debian/wd_keepalive.service ${D}${systemd_system_unitdir} 50 install -m 0644 ${S}/debian/wd_keepalive.service ${D}${systemd_system_unitdir}
51 51
52 install -D ${S}/redhat/watchdog.init ${D}/${sysconfdir}/init.d/watchdog.sh 52 install -Dm 0755 ${WORKDIR}/watchdog.init ${D}/${sysconfdir}/init.d/watchdog
53 install -Dm 0755 ${WORKDIR}/wd_keepalive.init ${D}${sysconfdir}/init.d/wd_keepalive 53 install -Dm 0755 ${WORKDIR}/wd_keepalive.init ${D}${sysconfdir}/init.d/wd_keepalive
54 54
55 # watchdog.conf is provided by the watchdog-config recipe 55 # watchdog.conf is provided by the watchdog-config recipe