Blame 0003-Change-the-implementation-of-action_on_fail.patch

Harald Hoyer ac117f
From d2765b5175663d094737d6819cc3f3df53e7a4cb Mon Sep 17 00:00:00 2001
Harald Hoyer ac117f
From: Baoquan He <bhe@redhat.com>
Harald Hoyer ac117f
Date: Tue, 23 Jul 2013 18:16:00 +0800
Harald Hoyer ac117f
Subject: [PATCH] Change the implementation of action_on_fail
Harald Hoyer ac117f
Harald Hoyer ac117f
Currently when action_on_fail is enabled, the emergency_shell won't be called.
Harald Hoyer ac117f
In kdump even though user specify the default action as emergency_shell,
Harald Hoyer ac117f
dracut skip it. Now change the implementation of action_on_fail to depend
Harald Hoyer ac117f
on a file which is created by kdump when making kdump initrd, then remove it
Harald Hoyer ac117f
at the beginning of kdump. This can solve the explicit emergency_shell problem.
Harald Hoyer ac117f
Harald Hoyer ac117f
And action_on_fail won't need paramenters, remove the relevant description in
Harald Hoyer ac117f
dracut man page.
Harald Hoyer ac117f
Harald Hoyer ac117f
Signed-off-by: Baoquan He <bhe@redhat.com>
Harald Hoyer ac117f
---
Harald Hoyer ac117f
 dracut.cmdline.7.asc                         |  4 ----
Harald Hoyer ac117f
 modules.d/98systemd/dracut-emergency.service |  2 +-
Harald Hoyer ac117f
 modules.d/98systemd/emergency.service        |  2 +-
Harald Hoyer ac117f
 modules.d/99base/dracut-lib.sh               | 28 ++++++++++------------------
Harald Hoyer ac117f
 4 files changed, 12 insertions(+), 24 deletions(-)
Harald Hoyer ac117f
Harald Hoyer ac117f
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
Harald Hoyer ac117f
index cf11d50..09c47e8 100644
Harald Hoyer ac117f
--- a/dracut.cmdline.7.asc
Harald Hoyer ac117f
+++ b/dracut.cmdline.7.asc
Harald Hoyer ac117f
@@ -121,10 +121,6 @@ Misc
Harald Hoyer ac117f
    specify the controlling terminal for the console.
Harald Hoyer ac117f
    This is useful, if you have multiple "console=" arguments.
Harald Hoyer ac117f
 
Harald Hoyer ac117f
-**rd.action_on_fail=**_{shell|continue}_::
Harald Hoyer ac117f
-   Specify the action after failure. By default it's emergency_shell.
Harald Hoyer ac117f
-   'continue' means: ignore the current failure and go ahead.
Harald Hoyer ac117f
-
Harald Hoyer ac117f
 [[dracutkerneldebug]]
Harald Hoyer ac117f
 Debug
Harald Hoyer ac117f
 ~~~~~
Harald Hoyer ac117f
diff --git a/modules.d/98systemd/dracut-emergency.service b/modules.d/98systemd/dracut-emergency.service
Harald Hoyer ac117f
index a4b81bc..5a6d525 100644
Harald Hoyer ac117f
--- a/modules.d/98systemd/dracut-emergency.service
Harald Hoyer ac117f
+++ b/modules.d/98systemd/dracut-emergency.service
Harald Hoyer ac117f
@@ -13,7 +13,7 @@ DefaultDependencies=no
Harald Hoyer ac117f
 After=systemd-vconsole-setup.service
Harald Hoyer ac117f
 Wants=systemd-vconsole-setup.service
Harald Hoyer ac117f
 Conflicts=emergency.service emergency.target
Harald Hoyer ac117f
-ConditionKernelCommandLine=!action_on_fail=continue
Harald Hoyer ac117f
+ConditionPathExists=!/lib/dracut/no-emergency-shell
Harald Hoyer ac117f
 
Harald Hoyer ac117f
 [Service]
Harald Hoyer ac117f
 Environment=HOME=/
Harald Hoyer ac117f
diff --git a/modules.d/98systemd/emergency.service b/modules.d/98systemd/emergency.service
Harald Hoyer ac117f
index c19fe37..5f1eaa2 100644
Harald Hoyer ac117f
--- a/modules.d/98systemd/emergency.service
Harald Hoyer ac117f
+++ b/modules.d/98systemd/emergency.service
Harald Hoyer ac117f
@@ -12,7 +12,7 @@ Description=Emergency Shell
Harald Hoyer ac117f
 DefaultDependencies=no
Harald Hoyer ac117f
 After=systemd-vconsole-setup.service
Harald Hoyer ac117f
 Wants=systemd-vconsole-setup.service
Harald Hoyer ac117f
-ConditionKernelCommandLine=!action_on_fail=continue
Harald Hoyer ac117f
+ConditionPathExists=!/lib/dracut/no-emergency-shell
Harald Hoyer ac117f
 
Harald Hoyer ac117f
 [Service]
Harald Hoyer ac117f
 Environment=HOME=/
Harald Hoyer ac117f
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer ac117f
index 9e49a9c..248cc8e 100755
Harald Hoyer ac117f
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer ac117f
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer ac117f
@@ -1030,24 +1030,16 @@ emergency_shell()
Harald Hoyer ac117f
 
Harald Hoyer ac117f
 action_on_fail()
Harald Hoyer ac117f
 {
Harald Hoyer ac117f
-    local _action=$(getarg rd.action_on_fail= -d action_on_fail=)
Harald Hoyer ac117f
-    case "$_action" in
Harald Hoyer ac117f
-        continue)
Harald Hoyer ac117f
-            [ "$1" = "-n" ] && shift 2
Harald Hoyer ac117f
-            [ "$1" = "--shutdown" ] && shift 2
Harald Hoyer ac117f
-            warn "$*"
Harald Hoyer ac117f
-            warn "Not dropping to emergency shell, because 'action_on_fail=continue' was set on the kernel command line."
Harald Hoyer ac117f
-            return 0
Harald Hoyer ac117f
-            ;;
Harald Hoyer ac117f
-        shell)
Harald Hoyer ac117f
-            emergency_shell $@
Harald Hoyer ac117f
-            return 1
Harald Hoyer ac117f
-            ;;
Harald Hoyer ac117f
-        *)
Harald Hoyer ac117f
-            emergency_shell $@
Harald Hoyer ac117f
-            return 1
Harald Hoyer ac117f
-            ;;
Harald Hoyer ac117f
-    esac
Harald Hoyer ac117f
+    if [ -f "$initdir/lib/dracut/no-emergency-shell" ]; then
Harald Hoyer ac117f
+        [ "$1" = "-n" ] && shift 2
Harald Hoyer ac117f
+        [ "$1" = "--shutdown" ] && shift 2
Harald Hoyer ac117f
+        warn "$*"
Harald Hoyer ac117f
+        warn "Not dropping to emergency shell, because $initdir/lib/dracut/no-emergency-shell exists."
Harald Hoyer ac117f
+        return 0
Harald Hoyer ac117f
+    fi
Harald Hoyer ac117f
+
Harald Hoyer ac117f
+    emergency_shell $@
Harald Hoyer ac117f
+    return 1
Harald Hoyer ac117f
 }
Harald Hoyer ac117f
 
Harald Hoyer ac117f
 # Retain the values of these variables but ensure that they are unexported