All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Berton <fabio.berton@ossystems.com.br>
To: openembedded-core@lists.openembedded.org
Cc: Otavio Salvador <otavio@ossystems.com.br>
Subject: [PATCH 1/2] watchdog: Add wd_keepalive package
Date: Fri, 26 Aug 2016 16:55:01 -0300	[thread overview]
Message-ID: <1472241302-7437-1-git-send-email-fabio.berton@ossystems.com.br> (raw)

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>
---
 .../watchdog/watchdog/wd_keepalive.init            | 121 +++++++++++++++++++++
 meta/recipes-extended/watchdog/watchdog_5.15.bb    |  23 +++-
 2 files changed, 141 insertions(+), 3 deletions(-)
 create mode 100644 meta/recipes-extended/watchdog/watchdog/wd_keepalive.init

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 0000000..1d3e4c5
--- /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
+
diff --git a/meta/recipes-extended/watchdog/watchdog_5.15.bb b/meta/recipes-extended/watchdog/watchdog_5.15.bb
index ee1a893..1c0049c 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 \
            file://0001-Include-linux-param.h-for-EXEC_PAGESIZE-definition.patch \
            file://watchdog-init.patch \
            file://watchdog-conf.patch \
+           file://wd_keepalive.init \
 "
 
 SRC_URI[md5sum] = "678c32f6f35a0492c9c1b76b4aa88828"
@@ -28,11 +29,27 @@ CFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc "
 LDFLAGS_append_libc-musl = " -ltirpc "
 EXTRA_OECONF_append_libc-musl = " --disable-nfs "
 
-INITSCRIPT_NAME = "watchdog.sh"
-INITSCRIPT_PARAMS = "start 15 1 2 3 4 5 . stop 85 0 6 ."
+INITSCRIPT_PACKAGES = "${PN} ${PN}-keepalive"
 
-RRECOMMENDS_${PN} = "kernel-module-softdog"
+INITSCRIPT_NAME_${PN} = "watchdog.sh"
+INITSCRIPT_PARAMS_${PN} = "start 15 1 2 3 4 5 . stop 85 0 6 ."
+
+INITSCRIPT_NAME_${PN}-keepalive = "wd_keepalive"
+INITSCRIPT_PARAMS_${PN}-keepalive = "start 15 1 2 3 4 5 . stop 85 0 6 ."
 
 do_install_append() {
 	install -D ${S}/redhat/watchdog.init ${D}/${sysconfdir}/init.d/watchdog.sh
+    install -Dm 0755 ${WORKDIR}/wd_keepalive.init ${D}${sysconfdir}/init.d/wd_keepalive
 }
+
+PACKAGES =+ "${PN}-keepalive"
+
+FILES_${PN}-keepalive = " \
+    ${sysconfdir}/init.d/wd_keepalive \
+    ${sbindir}/wd_keepalive \
+"
+
+RDEPENDS_${PN} += "${PN}-keepalive"
+
+RRECOMMENDS_${PN} = "kernel-module-softdog"
+
-- 
2.1.4



             reply	other threads:[~2016-08-26 19:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 19:55 Fabio Berton [this message]
2016-08-26 19:55 ` [PATCH 2/2] watchdog-config: Add recipe Fabio Berton
2016-09-06 13:44   ` Fabio Berton
2016-09-06 13:43 ` [PATCH 1/2] watchdog: Add wd_keepalive package Fabio Berton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472241302-7437-1-git-send-email-fabio.berton@ossystems.com.br \
    --to=fabio.berton@ossystems.com.br \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=otavio@ossystems.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.