diff options
author | Fabio Berton <fabio.berton@ossystems.com.br> | 2016-08-26 16:55:01 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-09 11:53:36 +0100 |
commit | 7a79aba22be0ca0bc3535dea64a79b697013337d (patch) | |
tree | c8387acc99a77a447c26a059722d065a4df40151 /meta/recipes-extended | |
parent | f344440172df166a317cdfbf5ea4f295dbfc79d3 (diff) | |
download | poky-7a79aba22be0ca0bc3535dea64a79b697013337d.tar.gz |
watchdog: Add wd_keepalive package
This is a simplified version of the watchdog daemon. It only opens
/dev/watchdog, and keeps writing to it often enough to keep the kernel
from resetting, at least once per minute. Each write delays the reboot
time another minute. After a minute of inactivity the watchdog hardware
will cause a reset. In the case of the software watchdog the ability to
reboot will depend on the state of the machines and interrupts.
Installs wd_keepalive binary and enable initscript.
(From OE-Core rev: b76af8a0982c3c7473bd6ba067d1c8030d4d2f26)
Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r-- | meta/recipes-extended/watchdog/watchdog/wd_keepalive.init | 121 | ||||
-rw-r--r-- | meta/recipes-extended/watchdog/watchdog_5.15.bb | 23 |
2 files changed, 141 insertions, 3 deletions
diff --git a/meta/recipes-extended/watchdog/watchdog/wd_keepalive.init b/meta/recipes-extended/watchdog/watchdog/wd_keepalive.init new file mode 100644 index 0000000000..1d3e4c5558 --- /dev/null +++ b/meta/recipes-extended/watchdog/watchdog/wd_keepalive.init | |||
@@ -0,0 +1,121 @@ | |||
1 | #!/bin/sh | ||
2 | #/etc/init.d/wd_keepalive: start wd_keepalive daemon. | ||
3 | |||
4 | ### BEGIN INIT INFO | ||
5 | # Provides: wd_keepalive | ||
6 | # Short-Description: Start watchdog keepalive daemon | ||
7 | # Required-Start: $remote_fs | ||
8 | # Required-Stop: $remote_fs | ||
9 | # X-Start-Before: $all | ||
10 | # Default-Start: 2 3 4 5 | ||
11 | # Default-Stop | ||
12 | ### END INIT INFO | ||
13 | |||
14 | PATH=/bin:/usr/bin:/sbin:/usr/sbin | ||
15 | |||
16 | test -x /usr/sbin/wd_keepalive || exit 0 | ||
17 | |||
18 | # For configuration of the init script use the file | ||
19 | # /etc/default/watchdog, do not edit this init script. | ||
20 | |||
21 | # Set run_watchdog to 1 to start watchdog or 0 to disable it. | ||
22 | run_watchdog=0 | ||
23 | |||
24 | # Specify additional watchdog options here (see manpage). | ||
25 | watchdog_options="" | ||
26 | |||
27 | # Specify module to load | ||
28 | watchdog_module="none" | ||
29 | |||
30 | [ -e /etc/default/watchdog ] && . /etc/default/watchdog | ||
31 | |||
32 | NAME=wd_keepalive | ||
33 | DAEMON=/usr/sbin/wd_keepalive | ||
34 | |||
35 | STOP_RETRY_SCHEDULE='TERM/10/forever/KILL/1' | ||
36 | |||
37 | # . /lib/lsb/init-functions | ||
38 | |||
39 | # Mock Debian stuff | ||
40 | log_begin_msg() { | ||
41 | echo -n $* | ||
42 | } | ||
43 | |||
44 | log_end_msg() { | ||
45 | if [ "$1" = "0" ]; then | ||
46 | echo 'done' | ||
47 | else | ||
48 | echo 'error' | ||
49 | fi | ||
50 | } | ||
51 | |||
52 | log_daemon_msg() { | ||
53 | echo $* | ||
54 | } | ||
55 | |||
56 | log_progress_msg() { | ||
57 | echo $* | ||
58 | } | ||
59 | |||
60 | |||
61 | case "$1" in | ||
62 | start) | ||
63 | if [ $run_watchdog = 1 ] | ||
64 | then | ||
65 | [ ${watchdog_module:-none} != "none" ] && /sbin/modprobe $watchdog_module | ||
66 | echo -n "Starting watchdog keepalive daemon: " | ||
67 | if start-stop-daemon --start --quiet \ | ||
68 | --exec $DAEMON -- $watchdog_options | ||
69 | then | ||
70 | echo wd_keepalive. | ||
71 | else | ||
72 | echo | ||
73 | fi | ||
74 | fi | ||
75 | ;; | ||
76 | |||
77 | stop) | ||
78 | if [ $run_watchdog = 1 ] | ||
79 | then | ||
80 | echo -n "Stopping watchdog keepalive daemon: " | ||
81 | if start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ | ||
82 | $STOP_RETRY_SCHEDULE | ||
83 | then | ||
84 | echo wd_keepalive. | ||
85 | else | ||
86 | echo | ||
87 | fi | ||
88 | fi | ||
89 | ;; | ||
90 | |||
91 | status) | ||
92 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? | ||
93 | ;; | ||
94 | |||
95 | restart) | ||
96 | $0 force-reload | ||
97 | ;; | ||
98 | |||
99 | force-reload) | ||
100 | if [ $run_watchdog = 0 ]; then exit 0; fi | ||
101 | echo -n "Restarting $NAME daemon." | ||
102 | start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ | ||
103 | $STOP_RETRY_SCHEDULE | ||
104 | echo -n "." | ||
105 | if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ | ||
106 | --exec $DAEMON -- $watchdog_options | ||
107 | then | ||
108 | echo "done." | ||
109 | else | ||
110 | echo | ||
111 | fi | ||
112 | ;; | ||
113 | |||
114 | *) | ||
115 | echo "Usage: /etc/init.d/wd_keepalive {start|stop|status|restart|force-reload}" | ||
116 | exit 1 | ||
117 | |||
118 | esac | ||
119 | |||
120 | exit 0 | ||
121 | |||
diff --git a/meta/recipes-extended/watchdog/watchdog_5.15.bb b/meta/recipes-extended/watchdog/watchdog_5.15.bb index ee1a8933ef..1c0049c7af 100644 --- a/meta/recipes-extended/watchdog/watchdog_5.15.bb +++ b/meta/recipes-extended/watchdog/watchdog_5.15.bb | |||
@@ -12,6 +12,7 @@ SRC_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://watchdog-init.patch \ | 13 | file://watchdog-init.patch \ |
14 | file://watchdog-conf.patch \ | 14 | file://watchdog-conf.patch \ |
15 | file://wd_keepalive.init \ | ||
15 | " | 16 | " |
16 | 17 | ||
17 | SRC_URI[md5sum] = "678c32f6f35a0492c9c1b76b4aa88828" | 18 | SRC_URI[md5sum] = "678c32f6f35a0492c9c1b76b4aa88828" |
@@ -28,11 +29,27 @@ CFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc " | |||
28 | LDFLAGS_append_libc-musl = " -ltirpc " | 29 | LDFLAGS_append_libc-musl = " -ltirpc " |
29 | EXTRA_OECONF_append_libc-musl = " --disable-nfs " | 30 | EXTRA_OECONF_append_libc-musl = " --disable-nfs " |
30 | 31 | ||
31 | INITSCRIPT_NAME = "watchdog.sh" | 32 | INITSCRIPT_PACKAGES = "${PN} ${PN}-keepalive" |
32 | INITSCRIPT_PARAMS = "start 15 1 2 3 4 5 . stop 85 0 6 ." | ||
33 | 33 | ||
34 | RRECOMMENDS_${PN} = "kernel-module-softdog" | 34 | INITSCRIPT_NAME_${PN} = "watchdog.sh" |
35 | INITSCRIPT_PARAMS_${PN} = "start 15 1 2 3 4 5 . stop 85 0 6 ." | ||
36 | |||
37 | INITSCRIPT_NAME_${PN}-keepalive = "wd_keepalive" | ||
38 | INITSCRIPT_PARAMS_${PN}-keepalive = "start 15 1 2 3 4 5 . stop 85 0 6 ." | ||
35 | 39 | ||
36 | do_install_append() { | 40 | do_install_append() { |
37 | install -D ${S}/redhat/watchdog.init ${D}/${sysconfdir}/init.d/watchdog.sh | 41 | install -D ${S}/redhat/watchdog.init ${D}/${sysconfdir}/init.d/watchdog.sh |
42 | install -Dm 0755 ${WORKDIR}/wd_keepalive.init ${D}${sysconfdir}/init.d/wd_keepalive | ||
38 | } | 43 | } |
44 | |||
45 | PACKAGES =+ "${PN}-keepalive" | ||
46 | |||
47 | FILES_${PN}-keepalive = " \ | ||
48 | ${sysconfdir}/init.d/wd_keepalive \ | ||
49 | ${sbindir}/wd_keepalive \ | ||
50 | " | ||
51 | |||
52 | RDEPENDS_${PN} += "${PN}-keepalive" | ||
53 | |||
54 | RRECOMMENDS_${PN} = "kernel-module-softdog" | ||
55 | |||