18971c
From 779f980658ab223773ef065ac3f833aacd374c53 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Fri, 17 Jan 2014 15:27:47 +0100
18971c
Subject: [PATCH] base/dracut-lib.sh: "halt" the machine in systemd mode for
18971c
 die()
18971c
18971c
and only go in emergency shell if "rd.debug" is specified
18971c
18971c
https://bugzilla.redhat.com/show_bug.cgi?id=1053655
18971c
---
18971c
 modules.d/99base/dracut-lib.sh | 19 ++++++++++++++++---
18971c
 1 file changed, 16 insertions(+), 3 deletions(-)
18971c
18971c
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
18971c
index a3476ab3..e74b93fa 100755
18971c
--- a/modules.d/99base/dracut-lib.sh
18971c
+++ b/modules.d/99base/dracut-lib.sh
18971c
@@ -1,4 +1,4 @@
18971c
-#!/bin/sh
18971c
+!/bin/sh
18971c
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18971c
 # ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
 
18971c
@@ -430,8 +430,15 @@ die() {
18971c
         echo "warn dracut: Refusing to continue";
18971c
     } >> $hookdir/emergency/01-die.sh
18971c
     [ -d /run/initramfs ] || mkdir -p -- /run/initramfs
18971c
+
18971c
     > /run/initramfs/.die
18971c
-    emergency_shell
18971c
+
18971c
+    getargbool 0 "rd.debug=" && emergency_shell
18971c
+
18971c
+    if [ -n "$DRACUT_SYSTEMD" ]; then
18971c
+        systemctl --no-block --force halt
18971c
+    fi
18971c
+
18971c
     exit 1
18971c
 }
18971c
 
18971c
@@ -1045,7 +1052,13 @@ emergency_shell()
18971c
         # cause a kernel panic
18971c
         exit 1
18971c
     fi
18971c
-    [ -e /run/initramfs/.die ] && exit 1
18971c
+
18971c
+    if [ -e /run/initramfs/.die ]; then
18971c
+        if [ -n "$DRACUT_SYSTEMD" ]; then
18971c
+            systemctl --no-block --force halt
18971c
+        fi
18971c
+        exit 1
18971c
+    fi
18971c
 }
18971c
 
18971c
 action_on_fail()