From 75fc290c24268a3bb7cb6f45f0f4c928076ab514 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 23 Mar 2020 15:59:24 +0100
Subject: [PATCH] Add RemainAfterExit=yes to plymouth's systemd service files

All plymouth's systemd unit files are meant to only run once, either during
boot or during shutdown/restart.

Certain events cause systemd to recheck the dependency try between systemd
units. Systemd had a bug before the 245 release which caused this check to
sometimes not restart exited services for which the dependencies are met.

Systemd 245 fixes this, this is causing problems with plymouth.
When the conditions are met for systemd to recheck the dependencies;
and the plymouthd started by plymouth-start.service has exited;
then systemd will restart the plymouth-start unit, causing plymouthd to
take over tty1 after boot. This is causing various problems, also see:

https://bugzilla.redhat.com/show_bug.cgi?id=1803293

Since all plymouth's systemd units are intended to run only once, they
all should be marked as remaining after exit by adding:
"RemainAfterExit=yes" to them. This causes systemd to still consider them
running after e.g. plymouthd has exited, as long as they have started
successfully. This fixes systemd restarting plymouth's units when it
should not do so.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1803293
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1807771
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 systemd-units/plymouth-halt.service.in        | 1 +
 systemd-units/plymouth-kexec.service.in       | 1 +
 systemd-units/plymouth-poweroff.service.in    | 1 +
 systemd-units/plymouth-quit-wait.service.in   | 1 +
 systemd-units/plymouth-quit.service.in        | 1 +
 systemd-units/plymouth-read-write.service.in  | 1 +
 systemd-units/plymouth-reboot.service.in      | 1 +
 systemd-units/plymouth-start.service.in       | 1 +
 systemd-units/plymouth-switch-root.service.in | 1 +
 9 files changed, 9 insertions(+)

diff --git a/systemd-units/plymouth-halt.service.in b/systemd-units/plymouth-halt.service.in
index 38ae98c..cb87c1f 100644
--- a/systemd-units/plymouth-halt.service.in
+++ b/systemd-units/plymouth-halt.service.in
@@ -10,3 +10,4 @@ ConditionVirtualization=!container
 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
 Type=forking
+RemainAfterExit=yes
diff --git a/systemd-units/plymouth-kexec.service.in b/systemd-units/plymouth-kexec.service.in
index bed5eb7..22bc5bd 100644
--- a/systemd-units/plymouth-kexec.service.in
+++ b/systemd-units/plymouth-kexec.service.in
@@ -10,3 +10,4 @@ ConditionVirtualization=!container
 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
 Type=forking
+RemainAfterExit=yes
diff --git a/systemd-units/plymouth-poweroff.service.in b/systemd-units/plymouth-poweroff.service.in
index 7891e97..cf05e47 100644
--- a/systemd-units/plymouth-poweroff.service.in
+++ b/systemd-units/plymouth-poweroff.service.in
@@ -10,3 +10,4 @@ ConditionVirtualization=!container
 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=shutdown --attach-to-session
 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
 Type=forking
+RemainAfterExit=yes
diff --git a/systemd-units/plymouth-quit-wait.service.in b/systemd-units/plymouth-quit-wait.service.in
index fbb235c..94f66cc 100644
--- a/systemd-units/plymouth-quit-wait.service.in
+++ b/systemd-units/plymouth-quit-wait.service.in
@@ -5,4 +5,5 @@ After=rc-local.service plymouth-start.service systemd-user-sessions.service
 [Service]
 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth --wait
 Type=oneshot
+RemainAfterExit=yes
 TimeoutSec=0
diff --git a/systemd-units/plymouth-quit.service.in b/systemd-units/plymouth-quit.service.in
index cf9901e..ed9f9b9 100644
--- a/systemd-units/plymouth-quit.service.in
+++ b/systemd-units/plymouth-quit.service.in
@@ -5,4 +5,5 @@ After=rc-local.service plymouth-start.service systemd-user-sessions.service
 [Service]
 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth quit
 Type=oneshot
+RemainAfterExit=yes
 TimeoutSec=20
diff --git a/systemd-units/plymouth-read-write.service.in b/systemd-units/plymouth-read-write.service.in
index 55b975e..9a6b9c2 100644
--- a/systemd-units/plymouth-read-write.service.in
+++ b/systemd-units/plymouth-read-write.service.in
@@ -8,3 +8,4 @@ ConditionPathExists=!/etc/initrd-release
 [Service]
 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth update-root-fs --read-write
 Type=oneshot
+RemainAfterExit=yes
diff --git a/systemd-units/plymouth-reboot.service.in b/systemd-units/plymouth-reboot.service.in
index 147f824..3624550 100644
--- a/systemd-units/plymouth-reboot.service.in
+++ b/systemd-units/plymouth-reboot.service.in
@@ -10,3 +10,4 @@ ConditionVirtualization=!container
 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=reboot --attach-to-session
 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
 Type=forking
+RemainAfterExit=yes
diff --git a/systemd-units/plymouth-start.service.in b/systemd-units/plymouth-start.service.in
index 5d88f60..3d00cc6 100644
--- a/systemd-units/plymouth-start.service.in
+++ b/systemd-units/plymouth-start.service.in
@@ -11,5 +11,6 @@ ConditionVirtualization=!container
 ExecStart=@PLYMOUTH_DAEMON_DIR@/plymouthd --mode=boot --pid-file=@plymouthruntimedir@/pid --attach-to-session
 ExecStartPost=-@PLYMOUTH_CLIENT_DIR@/plymouth show-splash
 Type=forking
+RemainAfterExit=yes
 KillMode=none
 SendSIGKILL=no
diff --git a/systemd-units/plymouth-switch-root.service.in b/systemd-units/plymouth-switch-root.service.in
index 8986655..20b7f7b 100644
--- a/systemd-units/plymouth-switch-root.service.in
+++ b/systemd-units/plymouth-switch-root.service.in
@@ -6,6 +6,7 @@ Before=initrd-switch-root.service
 
 [Service]
 Type=oneshot
+RemainAfterExit=yes
 ExecStart=-@PLYMOUTH_CLIENT_DIR@/plymouth update-root-fs --new-root-dir=/sysroot
 StandardInput=null
 StandardOutput=null
-- 
2.26.2

