[systemd-devel] [PATCH] units: make ExecStopPost action part of ExecStart

Lennart Poettering lennart at poettering.net
Wed Jul 9 09:37:43 PDT 2014


On Tue, 08.07.14 18:01, Michal Sekletar (msekleta at redhat.com) wrote:

> Currently after exiting rescue shell we isolate default target. User
> might want to isolate to some other target than default one. However
> issuing systemctl isolate command to desired target would bring system
> to default target as a consequence of running ExecStopPost action.
> 
> Having common ancestor for rescue shell and possible followup systemctl
> default command should fix this. If user exits rescue shell we will
> proceed with isolating default target, otherwise, on manual isolate,
> parent shell process is terminated and we don't isolate default target,
> but target chosen by user.
> 
> Suggested-by: Michal Schmidt <mschmidt at redhat.com>
> ---
>  units/emergency.service.in | 3 +--
>  units/rescue.service.m4.in | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/units/emergency.service.in b/units/emergency.service.in
> index 94c090f..91fc1bb 100644
> --- a/units/emergency.service.in
> +++ b/units/emergency.service.in
> @@ -17,8 +17,7 @@ Environment=HOME=/root
>  WorkingDirectory=/root
>  ExecStartPre=-/bin/plymouth quit
>  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.'
> -ExecStart=-/sbin/sulogin
> -ExecStopPost=@SYSTEMCTL@ --fail --no-block default
> +ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
>  Type=idle
>  StandardInput=tty-force
>  StandardOutput=inherit
> diff --git a/units/rescue.service.m4.in b/units/rescue.service.m4.in
> index 552ef89..ef54369 100644
> --- a/units/rescue.service.m4.in
> +++ b/units/rescue.service.m4.in
> @@ -18,8 +18,7 @@ Environment=HOME=/root
>  WorkingDirectory=/root
>  ExecStartPre=-/bin/plymouth quit
>  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.'
> -ExecStart=-/sbin/sulogin
> -ExecStopPost=- at SYSTEMCTL@ --fail --no-block default
> +ExecStart=-/bin/sh -c "/sbin/sulogin; @SYSTEMCTL@ --fail --no-block default"
>  Type=idle
>  StandardInput=tty-force
>  StandardOutput=inherit

Patch looks good I figure, should probably go in, but I must say I
really don't like the use of shell here, this is something we should be
able to do with built-in functionality.

I figure what we probably should do is allow passing multiple ExecStart=
for all Type= settings. We currently only allow that for Type=oneshot,
but we could open this up for all others too. 

Anyway, go ahead, commit this for now, but I think we should get this
fixed properly within the service state machine.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list