Blame 0020-move-emergency_shell-to-dracut-lib.sh.patch

Harald Hoyer 65a3b7
From ffcc64bdea9080c2a1430ba59720f583bc0ac908 Mon Sep 17 00:00:00 2001
Harald Hoyer 65a3b7
From: Will Woods <wwoods@redhat.com>
Harald Hoyer 65a3b7
Date: Wed, 29 Feb 2012 13:09:58 -0500
Harald Hoyer 65a3b7
Subject: [PATCH] move emergency_shell to dracut-lib.sh
Harald Hoyer 65a3b7
Harald Hoyer 65a3b7
This lets things running outside init call an emergency_shell.
Harald Hoyer 65a3b7
(example: scripts called by initqueue)
Harald Hoyer 65a3b7
---
Harald Hoyer 65a3b7
 modules.d/99base/dracut-lib.sh |   38 ++++++++++++++++++++++++++++++++++++++
Harald Hoyer 65a3b7
 modules.d/99base/init.sh       |   40 +---------------------------------------
Harald Hoyer 65a3b7
 2 files changed, 39 insertions(+), 39 deletions(-)
Harald Hoyer 65a3b7
Harald Hoyer 65a3b7
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 65a3b7
index afd366e..c31854e 100755
Harald Hoyer 65a3b7
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 65a3b7
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 65a3b7
@@ -753,3 +753,41 @@ killproc() {
Harald Hoyer 65a3b7
 need_shutdown() {
Harald Hoyer 65a3b7
     >/run/initramfs/.need_shutdown
Harald Hoyer 65a3b7
 }
Harald Hoyer 65a3b7
+
Harald Hoyer 65a3b7
+emergency_shell()
Harald Hoyer 65a3b7
+{
Harald Hoyer 65a3b7
+    local _ctty
Harald Hoyer 65a3b7
+    set +e
Harald Hoyer 65a3b7
+    if [ "$1" = "-n" ]; then
Harald Hoyer 65a3b7
+        _rdshell_name=$2
Harald Hoyer 65a3b7
+        shift 2
Harald Hoyer 65a3b7
+    else
Harald Hoyer 65a3b7
+        _rdshell_name=dracut
Harald Hoyer 65a3b7
+    fi
Harald Hoyer 65a3b7
+    echo ; echo
Harald Hoyer 65a3b7
+    warn $@
Harald Hoyer 65a3b7
+    source_hook emergency
Harald Hoyer 65a3b7
+    echo
Harald Hoyer 65a3b7
+    wait_for_loginit
Harald Hoyer 65a3b7
+    [ -e /run/initramfs/.die ] && exit 1
Harald Hoyer 65a3b7
+    if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
Harald Hoyer 65a3b7
+        echo "Dropping to debug shell."
Harald Hoyer 65a3b7
+        echo
Harald Hoyer 65a3b7
+        export PS1="$_rdshell_name:\${PWD}# "
Harald Hoyer 65a3b7
+        [ -e /.profile ] || >/.profile
Harald Hoyer 65a3b7
+        _ctty=/dev/console
Harald Hoyer 65a3b7
+        if [ -n "$(command -v setsid)" ]; then
Harald Hoyer 65a3b7
+            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
Harald Hoyer 65a3b7
+            [ -c "$_ctty" ] || _ctty=/dev/tty1
Harald Hoyer 65a3b7
+            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer 65a3b7
+        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
Harald Hoyer 65a3b7
+            openvt -f -c 1 -w -s -l -- sh
Harald Hoyer 65a3b7
+        else
Harald Hoyer 65a3b7
+            sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer 65a3b7
+        fi
Harald Hoyer 65a3b7
+    else
Harald Hoyer 65a3b7
+        warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
Harald Hoyer 65a3b7
+        # cause a kernel panic
Harald Hoyer 65a3b7
+        exit 1
Harald Hoyer 65a3b7
+    fi
Harald Hoyer 65a3b7
+}
Harald Hoyer 65a3b7
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer 65a3b7
index 4d0a2a2..d197497 100755
Harald Hoyer 65a3b7
--- a/modules.d/99base/init.sh
Harald Hoyer 65a3b7
+++ b/modules.d/99base/init.sh
Harald Hoyer 65a3b7
@@ -38,54 +38,16 @@ wait_for_loginit()
Harald Hoyer 65a3b7
     rm -f /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
Harald Hoyer 65a3b7
 }
Harald Hoyer 65a3b7
 
Harald Hoyer 65a3b7
-emergency_shell()
Harald Hoyer 65a3b7
-{
Harald Hoyer 65a3b7
-    local _ctty
Harald Hoyer 65a3b7
-    set +e
Harald Hoyer 65a3b7
-    if [ "$1" = "-n" ]; then
Harald Hoyer 65a3b7
-        _rdshell_name=$2
Harald Hoyer 65a3b7
-        shift 2
Harald Hoyer 65a3b7
-    else
Harald Hoyer 65a3b7
-        _rdshell_name=dracut
Harald Hoyer 65a3b7
-    fi
Harald Hoyer 65a3b7
-    echo ; echo
Harald Hoyer 65a3b7
-    warn $@
Harald Hoyer 65a3b7
-    source_hook emergency
Harald Hoyer 65a3b7
-    echo
Harald Hoyer 65a3b7
-    wait_for_loginit
Harald Hoyer 65a3b7
-    [ -e /run/initramfs/.die ] && exit 1
Harald Hoyer 65a3b7
-    if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
Harald Hoyer 65a3b7
-        echo "Dropping to debug shell."
Harald Hoyer 65a3b7
-        echo
Harald Hoyer 65a3b7
-        export PS1="$_rdshell_name:\${PWD}# "
Harald Hoyer 65a3b7
-        [ -e /.profile ] || >/.profile
Harald Hoyer 65a3b7
-        _ctty=/dev/console
Harald Hoyer 65a3b7
-        if [ -n "$(command -v setsid)" ]; then
Harald Hoyer 65a3b7
-            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
Harald Hoyer 65a3b7
-            [ -c "$_ctty" ] || _ctty=/dev/tty1
Harald Hoyer 65a3b7
-            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer 65a3b7
-        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
Harald Hoyer 65a3b7
-            openvt -f -c 1 -w -s -l -- sh
Harald Hoyer 65a3b7
-        else
Harald Hoyer 65a3b7
-            sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer 65a3b7
-        fi
Harald Hoyer 65a3b7
-    else
Harald Hoyer 65a3b7
-        warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
Harald Hoyer 65a3b7
-        # cause a kernel panic
Harald Hoyer 65a3b7
-        exit 1
Harald Hoyer 65a3b7
-    fi
Harald Hoyer 65a3b7
-}
Harald Hoyer 65a3b7
-
Harald Hoyer 65a3b7
 NEWROOT="/sysroot"
Harald Hoyer 65a3b7
 [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT
Harald Hoyer 65a3b7
 
Harald Hoyer 65a3b7
-trap "emergency_shell Signal caught!" 0
Harald Hoyer 65a3b7
 OLDPATH=$PATH
Harald Hoyer 65a3b7
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
Harald Hoyer 65a3b7
 export PATH
Harald Hoyer 65a3b7
 
Harald Hoyer 65a3b7
 RD_DEBUG=""
Harald Hoyer 65a3b7
 . /lib/dracut-lib.sh
Harald Hoyer 65a3b7
+trap "emergency_shell Signal caught!" 0
Harald Hoyer 65a3b7
 
Harald Hoyer 65a3b7
 [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
Harald Hoyer 65a3b7