Harald Hoyer d1bf89
From ef914f7d833b7ea7a5916e7d56c9e9c158d3783a Mon Sep 17 00:00:00 2001
Harald Hoyer d1bf89
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer d1bf89
Date: Mon, 18 Jun 2012 19:17:22 +0200
Harald Hoyer d1bf89
Subject: [PATCH] add 04watchdog dracut module
Harald Hoyer d1bf89
Harald Hoyer d1bf89
---
Harald Hoyer d1bf89
 dracut.spec                          |    1 +
Harald Hoyer d1bf89
 modules.d/04watchdog/module-setup.sh |   23 +++++++++++++++++++++++
Harald Hoyer d1bf89
 modules.d/04watchdog/watchdog.sh     |    6 ++++++
Harald Hoyer d1bf89
 modules.d/99base/dracut-lib.sh       |    2 ++
Harald Hoyer d1bf89
 4 files changed, 32 insertions(+)
Harald Hoyer d1bf89
 create mode 100755 modules.d/04watchdog/module-setup.sh
Harald Hoyer d1bf89
 create mode 100755 modules.d/04watchdog/watchdog.sh
Harald Hoyer d1bf89
Harald Hoyer d1bf89
diff --git a/dracut.spec b/dracut.spec
Harald Hoyer d1bf89
index eb5df2c..6e8c733 100644
Harald Hoyer d1bf89
--- a/dracut.spec
Harald Hoyer d1bf89
+++ b/dracut.spec
Harald Hoyer d1bf89
@@ -254,6 +254,7 @@ rm -rf $RPM_BUILD_ROOT
Harald Hoyer d1bf89
 %{_mandir}/man5/dracut.conf.5*
Harald Hoyer d1bf89
 %{dracutlibdir}/modules.d/00bootchart
Harald Hoyer d1bf89
 %{dracutlibdir}/modules.d/00dash
Harald Hoyer d1bf89
+%{dracutlibdir}/modules.d/04watchdog
Harald Hoyer d1bf89
 %{dracutlibdir}/modules.d/05busybox
Harald Hoyer d1bf89
 %{dracutlibdir}/modules.d/10i18n
Harald Hoyer d1bf89
 %{dracutlibdir}/modules.d/30convertfs
Harald Hoyer d1bf89
diff --git a/modules.d/04watchdog/module-setup.sh b/modules.d/04watchdog/module-setup.sh
Harald Hoyer d1bf89
new file mode 100755
Harald Hoyer d1bf89
index 0000000..eb46143
Harald Hoyer d1bf89
--- /dev/null
Harald Hoyer d1bf89
+++ b/modules.d/04watchdog/module-setup.sh
Harald Hoyer d1bf89
@@ -0,0 +1,23 @@
Harald Hoyer d1bf89
+#!/bin/bash
Harald Hoyer d1bf89
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer d1bf89
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+check() {
Harald Hoyer d1bf89
+    return 255
Harald Hoyer d1bf89
+}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+depends() {
Harald Hoyer d1bf89
+    return 0
Harald Hoyer d1bf89
+}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+install() {
Harald Hoyer d1bf89
+    inst_hook cmdline   00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook cmdline   50 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook pre-trigger 00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook initqueue 00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook mount     00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook mount     50 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook pre-pivot 00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+    inst_hook cleanup   00 "$moddir/watchdog.sh"
Harald Hoyer d1bf89
+}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
diff --git a/modules.d/04watchdog/watchdog.sh b/modules.d/04watchdog/watchdog.sh
Harald Hoyer d1bf89
new file mode 100755
Harald Hoyer d1bf89
index 0000000..712969f
Harald Hoyer d1bf89
--- /dev/null
Harald Hoyer d1bf89
+++ b/modules.d/04watchdog/watchdog.sh
Harald Hoyer d1bf89
@@ -0,0 +1,6 @@
Harald Hoyer d1bf89
+#!/bin/sh
Harald Hoyer d1bf89
+if [ -e /dev/watchdog ]; then
Harald Hoyer d1bf89
+	>/dev/watchdog
Harald Hoyer d1bf89
+else
Harald Hoyer d1bf89
+	modprobe ib700wdt
Harald Hoyer d1bf89
+fi
Harald Hoyer d1bf89
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer d1bf89
index 3ecba9a..8cfd7b3 100755
Harald Hoyer d1bf89
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer d1bf89
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer d1bf89
@@ -832,6 +832,8 @@ emergency_shell()
Harald Hoyer d1bf89
         fi
Harald Hoyer d1bf89
         [ -c "$_ctty" ] || _ctty=/dev/tty1
Harald Hoyer d1bf89
         strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
Harald Hoyer d1bf89
+        # stop watchdog
Harald Hoyer d1bf89
+        echo 'V' > /dev/watchdog
Harald Hoyer d1bf89
         setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer d1bf89
     else
Harald Hoyer d1bf89
         warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."