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