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:52:09 +0100 |
commit | b76af8a0982c3c7473bd6ba067d1c8030d4d2f26 (patch) | |
tree | c57bd2c414c0604e485e6b3ddfecd81b835f353c /meta/recipes-extended/watchdog/watchdog | |
parent | ea2f99161a22ae2e9eefd3b337c9af7704c33e37 (diff) | |
download | openembedded-core-contrib-b76af8a0982c3c7473bd6ba067d1c8030d4d2f26.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.
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/watchdog/watchdog')
-rw-r--r-- | meta/recipes-extended/watchdog/watchdog/wd_keepalive.init | 121 |
1 files changed, 121 insertions, 0 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 @@ +#!/bin/sh +#/etc/init.d/wd_keepalive: start wd_keepalive daemon. + +### BEGIN INIT INFO +# Provides: wd_keepalive +# Short-Description: Start watchdog keepalive daemon +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# X-Start-Before: $all +# Default-Start: 2 3 4 5 +# Default-Stop +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +test -x /usr/sbin/wd_keepalive || 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=wd_keepalive +DAEMON=/usr/sbin/wd_keepalive + +STOP_RETRY_SCHEDULE='TERM/10/forever/KILL/1' + +# . /lib/lsb/init-functions + +# Mock Debian stuff +log_begin_msg() { + echo -n $* +} + +log_end_msg() { + if [ "$1" = "0" ]; then + echo 'done' + else + echo 'error' + fi +} + +log_daemon_msg() { + echo $* +} + +log_progress_msg() { + echo $* +} + + +case "$1" in + start) + if [ $run_watchdog = 1 ] + then + [ ${watchdog_module:-none} != "none" ] && /sbin/modprobe $watchdog_module + echo -n "Starting watchdog keepalive daemon: " + if start-stop-daemon --start --quiet \ + --exec $DAEMON -- $watchdog_options + then + echo wd_keepalive. + else + echo + fi + fi + ;; + + stop) + if [ $run_watchdog = 1 ] + then + echo -n "Stopping watchdog keepalive daemon: " + if start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ + $STOP_RETRY_SCHEDULE + then + echo wd_keepalive. + else + echo + fi + fi + ;; + + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + + restart) + $0 force-reload + ;; + + force-reload) + if [ $run_watchdog = 0 ]; then exit 0; fi + echo -n "Restarting $NAME daemon." + start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ + $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/wd_keepalive {start|stop|status|restart|force-reload}" + exit 1 + +esac + +exit 0 + |