]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add rd.emergency=[reboot|poweroff|halt]
authorHarald Hoyer <harald@redhat.com>
Fri, 22 Jul 2016 11:32:47 +0000 (13:32 +0200)
committerHarald Hoyer <harald@redhat.com>
Fri, 22 Jul 2016 12:51:03 +0000 (14:51 +0200)
specifies what action to execute in case of a critical failure

dracut.cmdline.7.asc
modules.d/98dracut-systemd/dracut-emergency.sh
modules.d/99base/dracut-lib.sh

index bf007198b6122b6b05987bac86b68600bf71634e..a2d1f952ff2d50021f79bc1cee2db5fdc58d19ae 100644 (file)
@@ -129,6 +129,9 @@ menuentry 'Live Fedora 20' --class fedora --class gnu-linux --class gnu --class
 
 Misc
 ~~~~
+**rd.emergency=**__[reboot|poweroff|halt]__::
+    specify, what action to execute in case of a critical failure.
+
 **rd.driver.blacklist=**__<drivername>__[,__<drivername>__,...]::
     do not load kernel module <drivername>. This parameter can be specified
     multiple times.
index 63311c2dba36eed2caf1b67da23ad5900db1921f..548f64b9b299b509ce20a4e41fce2b80e1327bd6 100755 (executable)
@@ -11,7 +11,7 @@ source_conf /etc/conf.d
 type plymouth >/dev/null 2>&1 && plymouth quit
 
 export _rdshell_name="dracut" action="Boot" hook="emergency"
-
+_emergency_action=$(getarg rd.emergency)
 
 if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
     source_hook "$hook"
@@ -32,9 +32,18 @@ else
     export hook="shutdown-emergency"
     warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
     source_hook "$hook"
-    exit 1
+    [ -z "$_emergency_action" ] && _emergency_action=halt
 fi
 
 /bin/rm -f -- /.console_lock
 
+case "$_emergency_action" in
+    reboot)
+        reboot || exit 1;;
+    poweroff)
+        poweroff || exit 1;;
+    halt)
+        halt || exit 1;;
+esac
+
 exit 0
index 94e4614cf639289ed8f1c92e0889bf1ea09869b6..060b3fed534829bbd5e21ac8ca852a06e49c6a2c 100755 (executable)
@@ -1111,6 +1111,8 @@ emergency_shell()
     local _ctty
     set +e
     local _rdshell_name="dracut" action="Boot" hook="emergency"
+    local _emergency_action
+
     if [ "$1" = "-n" ]; then
         _rdshell_name=$2
         shift 2
@@ -1129,20 +1131,26 @@ emergency_shell()
     source_hook "$hook"
     echo
 
+    _emergency_action=$(getarg rd.emergency)
+    [ -z "$_emergency_action" ] \
+        && [ -e /run/initramfs/.die ] \
+        && _emergency_action=halt
+
     if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
         _emergency_shell $_rdshell_name
     else
         warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
-        # cause a kernel panic
-        exit 1
+        [ -z "$_emergency_action" ] && _emergency_action=halt
     fi
 
-    if [ -e /run/initramfs/.die ]; then
-        if [ -n "$DRACUT_SYSTEMD" ]; then
-            systemctl --no-block --force halt
-        fi
-        exit 1
-    fi
+    case "$_emergency_action" in
+        reboot)
+            reboot || exit 1;;
+        poweroff)
+            poweroff || exit 1;;
+        halt)
+            halt || exit 1;;
+    esac
 }
 
 # Retain the values of these variables but ensure that they are unexported