43ff24c
From 7a4ab10135c2b8fdeedb53c0585c67a0d6448ce6 Mon Sep 17 00:00:00 2001
43ff24c
From: Michal Sekletar <msekleta@redhat.com>
43ff24c
Date: Tue, 8 Jul 2014 17:42:23 +0200
43ff24c
Subject: [PATCH] units: make ExecStopPost action part of ExecStart
43ff24c
43ff24c
Currently after exiting rescue shell we isolate default target. User
43ff24c
might want to isolate to some other target than default one. However
43ff24c
issuing systemctl isolate command to desired target would bring system
43ff24c
to default target as a consequence of running ExecStopPost action.
43ff24c
43ff24c
Having common ancestor for rescue shell and possible followup systemctl
43ff24c
default command should fix this. If user exits rescue shell we will
43ff24c
proceed with isolating default target, otherwise, on manual isolate,
43ff24c
parent shell process is terminated and we don't isolate default target,
43ff24c
but target chosen by user.
43ff24c
43ff24c
Suggested-by: Michal Schmidt <mschmidt@redhat.com>
43ff24c
(cherry picked from commit d3381512282f2ca1c7669f77fb736a90fdce6982)
43ff24c
---
43ff24c
 units/emergency.service.in | 3 +--
43ff24c
 units/rescue.service.m4.in | 3 +--
43ff24c
 2 files changed, 2 insertions(+), 4 deletions(-)
43ff24c
43ff24c
diff --git a/units/emergency.service.in b/units/emergency.service.in
43ff24c
index 94c090f654..91fc1bbf51 100644
43ff24c
--- a/units/emergency.service.in
43ff24c
+++ b/units/emergency.service.in
43ff24c
@@ -17,8 +17,7 @@ Environment=HOME=/root
43ff24c
 WorkingDirectory=/root
43ff24c
 ExecStartPre=-/bin/plymouth quit
43ff24c
 ExecStartPre=-/bin/echo -e 'Welcome to emergency mode! After logging in, type "journalctl -xb" to view\\nsystem logs, "systemctl reboot" to reboot, "systemctl default" to try again\\nto boot into default mode.'
43ff24c
-ExecStart=-/sbin/sulogin
43ff24c
-ExecStopPost=@SYSTEMCTL@ --fail --no-block default
43ff24c
+ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
43ff24c
 Type=idle
43ff24c
 StandardInput=tty-force
43ff24c
 StandardOutput=inherit
43ff24c
diff --git a/units/rescue.service.m4.in b/units/rescue.service.m4.in
43ff24c
index 552ef8981b..ef5436960f 100644
43ff24c
--- a/units/rescue.service.m4.in
43ff24c
+++ b/units/rescue.service.m4.in
43ff24c
@@ -18,8 +18,7 @@ Environment=HOME=/root
43ff24c
 WorkingDirectory=/root
43ff24c
 ExecStartPre=-/bin/plymouth quit
43ff24c
 ExecStartPre=-/bin/echo -e 'Welcome to rescue mode! Type "systemctl default" or ^D to enter default mode.\\nType "journalctl -xb" to view system logs. Type "systemctl reboot" to reboot.'
43ff24c
-ExecStart=-/sbin/sulogin
43ff24c
-ExecStopPost=-@SYSTEMCTL@ --fail --no-block default
43ff24c
+ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
43ff24c
 Type=idle
43ff24c
 StandardInput=tty-force
43ff24c
 StandardOutput=inherit