]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
base/dracut-lib.sh: for systemd start emergency.service
authorHarald Hoyer <harald@redhat.com>
Wed, 20 Jun 2012 23:10:13 +0000 (01:10 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 20 Jun 2012 23:11:44 +0000 (01:11 +0200)
do not spawn the shell, start the emergency.service for systemd

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

index e0c4c19aaaed0743c31635bb0ad5c4495db62578..5dc3fbd769a52c0f4ca4027d986a42eec8e7c37e 100755 (executable)
@@ -825,30 +825,41 @@ emergency_shell()
         _rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
         shift 2
     fi
+
     echo ; echo
     warn $@
     source_hook "$hook"
     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 2>/dev/null)" "ctty" && CTTY="-c"
+        if [ -x /lib/systemd/systemd ]; then
+            > /.console_lock
+            echo "PS1=\"$_rdshell_name:\${PWD}# \"" >/etc/profile
+            systemctl start emergency.service
+            debug_off
+            while [ -e /.console_lock ]; do sleep 1; done
+            debug_on
+        else
+            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 2>/dev/null)" "ctty" && CTTY="-c"
         # stop watchdog
-        echo 'V' > /dev/watchdog
-        setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
+            echo 'V' > /dev/watchdog
+            setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
+        fi
     else
         warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
         # cause a kernel panic