|
|
a0a3b4 |
From cd6679c71665a53e2a55a204e7ea64b4a6d14030 Mon Sep 17 00:00:00 2001
|
|
|
a0a3b4 |
From: Harald Hoyer <harald@redhat.com>
|
|
|
a0a3b4 |
Date: Fri, 22 Jul 2016 13:32:47 +0200
|
|
|
a0a3b4 |
Subject: [PATCH] add rd.emergency=[reboot|poweroff|halt]
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
specifies what action to execute in case of a critical failure
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
(cherry picked from commit c45e856a659a37537c107f7ef3e680abf60a96a5)
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
https://bugzilla.redhat.com/show_bug.cgi?id=1359144
|
|
|
a0a3b4 |
---
|
|
|
a0a3b4 |
dracut.cmdline.7.asc | 3 +++
|
|
|
a0a3b4 |
modules.d/98systemd/dracut-emergency.sh | 12 +++++++++++-
|
|
|
a0a3b4 |
modules.d/99base/dracut-lib.sh | 24 ++++++++++++++++--------
|
|
|
a0a3b4 |
3 files changed, 30 insertions(+), 9 deletions(-)
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
|
|
|
1755ca |
index 1cf962e6..1fb4f746 100644
|
|
|
a0a3b4 |
--- a/dracut.cmdline.7.asc
|
|
|
a0a3b4 |
+++ b/dracut.cmdline.7.asc
|
|
|
a0a3b4 |
@@ -108,6 +108,9 @@ resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
Misc
|
|
|
a0a3b4 |
~~~~
|
|
|
a0a3b4 |
+**rd.emergency=**__[reboot|poweroff|halt]__::
|
|
|
a0a3b4 |
+ specify, what action to execute in case of a critical failure.
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
**rd.driver.blacklist=**__<drivername>__[,__<drivername>__,...]::
|
|
|
a0a3b4 |
do not load kernel module <drivername>. This parameter can be specified
|
|
|
a0a3b4 |
multiple times.
|
|
|
a0a3b4 |
diff --git a/modules.d/98systemd/dracut-emergency.sh b/modules.d/98systemd/dracut-emergency.sh
|
|
|
1755ca |
index 5771dc5e..b3e8d087 100755
|
|
|
a0a3b4 |
--- a/modules.d/98systemd/dracut-emergency.sh
|
|
|
a0a3b4 |
+++ b/modules.d/98systemd/dracut-emergency.sh
|
|
|
a0a3b4 |
@@ -16,6 +16,7 @@ export _rdshell_name="dracut" action="Boot" hook="emergency"
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
source_hook "$hook"
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
+_emergency_action=$(getarg rd.emergency)
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
|
|
|
a0a3b4 |
echo
|
|
|
a0a3b4 |
@@ -33,9 +34,18 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
|
|
|
a0a3b4 |
exec sh -i -l
|
|
|
a0a3b4 |
else
|
|
|
a0a3b4 |
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
|
|
|
a0a3b4 |
- exit 1
|
|
|
a0a3b4 |
+ [ -z "$_emergency_action" ] && _emergency_action=halt
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
/bin/rm -f -- /.console_lock
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
+case "$_emergency_action" in
|
|
|
a0a3b4 |
+ reboot)
|
|
|
a0a3b4 |
+ reboot || exit 1;;
|
|
|
a0a3b4 |
+ poweroff)
|
|
|
a0a3b4 |
+ poweroff || exit 1;;
|
|
|
a0a3b4 |
+ halt)
|
|
|
a0a3b4 |
+ halt || exit 1;;
|
|
|
a0a3b4 |
+esac
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
exit 0
|
|
|
a0a3b4 |
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
|
|
|
1755ca |
index 16bc74d4..10d9cbc5 100755
|
|
|
a0a3b4 |
--- a/modules.d/99base/dracut-lib.sh
|
|
|
a0a3b4 |
+++ b/modules.d/99base/dracut-lib.sh
|
|
|
a0a3b4 |
@@ -1068,6 +1068,8 @@ emergency_shell()
|
|
|
a0a3b4 |
local _ctty
|
|
|
a0a3b4 |
set +e
|
|
|
a0a3b4 |
local _rdshell_name="dracut" action="Boot" hook="emergency"
|
|
|
a0a3b4 |
+ local _emergency_action
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
if [ "$1" = "-n" ]; then
|
|
|
a0a3b4 |
_rdshell_name=$2
|
|
|
a0a3b4 |
shift 2
|
|
|
a0a3b4 |
@@ -1086,20 +1088,26 @@ emergency_shell()
|
|
|
a0a3b4 |
source_hook "$hook"
|
|
|
a0a3b4 |
echo
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
+ _emergency_action=$(getarg rd.emergency)
|
|
|
a0a3b4 |
+ [ -z "$_emergency_action" ] \
|
|
|
a0a3b4 |
+ && [ -e /run/initramfs/.die ] \
|
|
|
a0a3b4 |
+ && _emergency_action=halt
|
|
|
a0a3b4 |
+
|
|
|
a0a3b4 |
if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
|
|
|
a0a3b4 |
_emergency_shell $_rdshell_name
|
|
|
a0a3b4 |
else
|
|
|
a0a3b4 |
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
|
|
|
a0a3b4 |
- # cause a kernel panic
|
|
|
a0a3b4 |
- exit 1
|
|
|
a0a3b4 |
+ [ -z "$_emergency_action" ] && _emergency_action=halt
|
|
|
a0a3b4 |
fi
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
- if [ -e /run/initramfs/.die ]; then
|
|
|
a0a3b4 |
- if [ -n "$DRACUT_SYSTEMD" ]; then
|
|
|
a0a3b4 |
- systemctl --no-block --force halt
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
- exit 1
|
|
|
a0a3b4 |
- fi
|
|
|
a0a3b4 |
+ case "$_emergency_action" in
|
|
|
a0a3b4 |
+ reboot)
|
|
|
a0a3b4 |
+ reboot || exit 1;;
|
|
|
a0a3b4 |
+ poweroff)
|
|
|
a0a3b4 |
+ poweroff || exit 1;;
|
|
|
a0a3b4 |
+ halt)
|
|
|
a0a3b4 |
+ halt || exit 1;;
|
|
|
a0a3b4 |
+ esac
|
|
|
a0a3b4 |
}
|
|
|
a0a3b4 |
|
|
|
a0a3b4 |
action_on_fail()
|