]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
move emergency_shell to dracut-lib.sh
authorWill Woods <wwoods@redhat.com>
Wed, 29 Feb 2012 18:09:58 +0000 (13:09 -0500)
committerHarald Hoyer <harald@redhat.com>
Fri, 2 Mar 2012 10:11:56 +0000 (11:11 +0100)
This lets things running outside init call an emergency_shell.
(example: scripts called by initqueue)

modules.d/99base/dracut-lib.sh
modules.d/99base/init.sh

index afd366ea235d80d3c2c4104efaf6469c7b861adc..c31854ed8297c825c7ad0edd75d402fad0aee7e4 100755 (executable)
@@ -753,3 +753,41 @@ killproc() {
 need_shutdown() {
     >/run/initramfs/.need_shutdown
 }
+
+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 emergency
+    echo
+    wait_for_loginit
+    [ -e /run/initramfs/.die ] && exit 1
+    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=/dev/console
+        if [ -n "$(command -v setsid)" ]; then
+            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
+            [ -c "$_ctty" ] || _ctty=/dev/tty1
+            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
+        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
+            openvt -f -c 1 -w -s -l -- sh
+        else
+            sh -i -l 0<$_ctty 1>$_ctty 2>&1
+        fi
+    else
+        warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
+        # cause a kernel panic
+        exit 1
+    fi
+}
index 4d0a2a25ed84bbf6cd814e7e8336ced41a61a7b2..d19749721e47c09970ce51517ffceceae3767c34 100755 (executable)
@@ -38,54 +38,16 @@ wait_for_loginit()
     rm -f /run/initramfs/loginit.pipe /run/initramfs/loginit.pid
 }
 
-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 emergency
-    echo
-    wait_for_loginit
-    [ -e /run/initramfs/.die ] && exit 1
-    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=/dev/console
-        if [ -n "$(command -v setsid)" ]; then
-            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
-            [ -c "$_ctty" ] || _ctty=/dev/tty1
-            setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
-        elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
-            openvt -f -c 1 -w -s -l -- sh
-        else
-            sh -i -l 0<$_ctty 1>$_ctty 2>&1
-        fi
-    else
-        warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
-        # cause a kernel panic
-        exit 1
-    fi
-}
-
 NEWROOT="/sysroot"
 [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT
 
-trap "emergency_shell Signal caught!" 0
 OLDPATH=$PATH
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 export PATH
 
 RD_DEBUG=""
 . /lib/dracut-lib.sh
+trap "emergency_shell Signal caught!" 0
 
 [ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3