Blame 0054-base-dracut-lib.sh-for-systemd-start-emergency.servi.patch

Harald Hoyer e3ef57
From 1e570bf8e3010c1cc4cec2f67e0cefd658f90b48 Mon Sep 17 00:00:00 2001
Harald Hoyer e3ef57
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer e3ef57
Date: Thu, 21 Jun 2012 01:10:13 +0200
Harald Hoyer e3ef57
Subject: [PATCH] base/dracut-lib.sh: for systemd start emergency.service
Harald Hoyer e3ef57
Harald Hoyer e3ef57
do not spawn the shell, start the emergency.service for systemd
Harald Hoyer e3ef57
---
Harald Hoyer e3ef57
 modules.d/99base/dracut-lib.sh |   47 +++++++++++++++++++++++++---------------
Harald Hoyer e3ef57
 1 file changed, 29 insertions(+), 18 deletions(-)
Harald Hoyer e3ef57
Harald Hoyer e3ef57
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer e3ef57
index e0c4c19..5dc3fbd 100755
Harald Hoyer e3ef57
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer e3ef57
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer e3ef57
@@ -825,30 +825,41 @@ emergency_shell()
Harald Hoyer e3ef57
         _rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
Harald Hoyer e3ef57
         shift 2
Harald Hoyer e3ef57
     fi
Harald Hoyer e3ef57
+
Harald Hoyer e3ef57
     echo ; echo
Harald Hoyer e3ef57
     warn $@
Harald Hoyer e3ef57
     source_hook "$hook"
Harald Hoyer e3ef57
     echo
Harald Hoyer e3ef57
+
Harald Hoyer e3ef57
     if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
Harald Hoyer e3ef57
-        echo "Dropping to debug shell."
Harald Hoyer e3ef57
-        echo
Harald Hoyer e3ef57
-        export PS1="$_rdshell_name:\${PWD}# "
Harald Hoyer e3ef57
-        [ -e /.profile ] || >/.profile
Harald Hoyer e3ef57
-
Harald Hoyer e3ef57
-        _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
Harald Hoyer e3ef57
-        if [ -z "$_ctty" ]; then
Harald Hoyer e3ef57
-            _ctty=console
Harald Hoyer e3ef57
-            while [ -f /sys/class/tty/$_ctty/active ]; do
Harald Hoyer e3ef57
-                _ctty=$(cat /sys/class/tty/$_ctty/active)
Harald Hoyer e3ef57
-                _ctty=${_ctty##* } # last one in the list
Harald Hoyer e3ef57
-            done
Harald Hoyer e3ef57
-            _ctty=/dev/$_ctty
Harald Hoyer e3ef57
-        fi
Harald Hoyer e3ef57
-        [ -c "$_ctty" ] || _ctty=/dev/tty1
Harald Hoyer e3ef57
-        strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
Harald Hoyer e3ef57
+        if [ -x /lib/systemd/systemd ]; then
Harald Hoyer e3ef57
+            > /.console_lock
Harald Hoyer e3ef57
+            echo "PS1=\"$_rdshell_name:\${PWD}# \"" >/etc/profile
Harald Hoyer e3ef57
+            systemctl start emergency.service
Harald Hoyer e3ef57
+            debug_off
Harald Hoyer e3ef57
+            while [ -e /.console_lock ]; do sleep 1; done
Harald Hoyer e3ef57
+            debug_on
Harald Hoyer e3ef57
+        else
Harald Hoyer e3ef57
+            echo "Dropping to debug shell."
Harald Hoyer e3ef57
+            echo
Harald Hoyer e3ef57
+            export PS1="$_rdshell_name:\${PWD}# "
Harald Hoyer e3ef57
+            [ -e /.profile ] || >/.profile
Harald Hoyer e3ef57
+
Harald Hoyer e3ef57
+            _ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
Harald Hoyer e3ef57
+            if [ -z "$_ctty" ]; then
Harald Hoyer e3ef57
+                _ctty=console
Harald Hoyer e3ef57
+                while [ -f /sys/class/tty/$_ctty/active ]; do
Harald Hoyer e3ef57
+                    _ctty=$(cat /sys/class/tty/$_ctty/active)
Harald Hoyer e3ef57
+                    _ctty=${_ctty##* } # last one in the list
Harald Hoyer e3ef57
+                done
Harald Hoyer e3ef57
+                _ctty=/dev/$_ctty
Harald Hoyer e3ef57
+            fi
Harald Hoyer e3ef57
+            [ -c "$_ctty" ] || _ctty=/dev/tty1
Harald Hoyer e3ef57
+            strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
Harald Hoyer e3ef57
         # stop watchdog
Harald Hoyer e3ef57
-        echo 'V' > /dev/watchdog
Harald Hoyer e3ef57
-        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer e3ef57
+            echo 'V' > /dev/watchdog
Harald Hoyer e3ef57
+            setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
Harald Hoyer e3ef57
+        fi
Harald Hoyer e3ef57
     else
Harald Hoyer e3ef57
         warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
Harald Hoyer e3ef57
         # cause a kernel panic