dracut/0005-shutdown-use-emergency_shell-from-dracut-lib.patch

110 lines
3.7 KiB
Diff
Raw Normal View History

From bd3bf2ce41379459e79b9f48027d457caecce30a Mon Sep 17 00:00:00 2001
From: Will Woods <wwoods@redhat.com>
Date: Thu, 5 Apr 2012 13:01:39 -0400
Subject: [PATCH] shutdown: use emergency_shell from dracut-lib
---
modules.d/99base/dracut-lib.sh | 10 ++++----
modules.d/99shutdown/shutdown.sh | 47 +++-----------------------------------
2 files changed, 9 insertions(+), 48 deletions(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index e10a34d..a29d586 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -767,15 +767,17 @@ emergency_shell()
{
local _ctty
set +e
+ local _rdshell_name="dracut" action="Boot" hook="emergency"
if [ "$1" = "-n" ]; then
_rdshell_name=$2
shift 2
- else
- _rdshell_name=dracut
+ elif [ "$1" = "--shutdown" ]; then
+ _rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
+ shift 2
fi
echo ; echo
warn $@
- source_hook emergency
+ source_hook "$hook"
echo
wait_for_loginit
[ -e /run/initramfs/.die ] && exit 1
@@ -798,7 +800,7 @@ emergency_shell()
strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
else
- warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
+ warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
# cause a kernel panic
exit 1
fi
diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh
index 8817a4c..45345a4 100755
--- a/modules.d/99shutdown/shutdown.sh
+++ b/modules.d/99shutdown/shutdown.sh
@@ -12,49 +12,8 @@
export TERM=linux
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-emergency_shell()
-{
- local _ctty
- set +e
- if [ "$1" = "-n" ]; then
- _rdshell_name=$2
- shift 2
- else
- _rdshell_name=dracut
- fi
- echo ; echo
- warn $@
- source_hook shutdown-emergency
- echo
- if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
- echo "Dropping to debug shell."
- echo
- export PS1="$_rdshell_name:\${PWD}# "
- [ -e /.profile ] || >/.profile
-
- _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
- if [ -z "$_ctty" ]; then
- _ctty=console
- while [ -f /sys/class/tty/$_ctty/active ]; do
- _ctty=$(cat /sys/class/tty/$_ctty/active)
- _ctty=${_ctty##* } # last one in the list
- done
- _ctty=/dev/$_ctty
- fi
- [ -c "$_ctty" ] || _ctty=/dev/tty1
- strstr "$(setsid --help)" "control" && CTTY="-c"
- setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
- else
- exec /lib/systemd/systemd-shutdown "$@"
- warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line."
- # cause a kernel panic
- exit 1
- fi
-}
-
-trap "emergency_shell Signal caught!" 0
-
-getarg 'rd.break=pre-shutdown' && emergency_shell -n cmdline "Break before pre-shutdown"
+trap "emergency_shell --shutdown shutdown Signal caught!" 0
+getarg 'rd.break=pre-shutdown' && emergency_shell --shutdown pre-shutdown "Break before pre-shutdown"
umount_a() {
local _did_umount="n"
@@ -97,7 +56,7 @@ while _check_shutdown; do
done
_check_shutdown final
-getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown"
+getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"
[ "$1" = "reboot" ] && reboot -f -d -n --no-wall
[ "$1" = "poweroff" ] && poweroff -f -d -n --no-wall
[ "$1" = "halt" ] && halt -f -d -n --no-wall