]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
units: skip some units in the initrd
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 21 May 2021 08:53:25 +0000 (10:53 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 22 May 2021 06:58:40 +0000 (15:58 +0900)
I'm working on building initramfs images directly from normal packages, and it
doesn't make sense for those units to be started. Pristine system rpms need to
behave correctly as much as possible also in the initrd, and those units are
enabled by the rpms. There usually isn't enough time for the timer to actually
fire, but starting it gives a line on the console and generally looks confusing
and sloppy. Flushing the journal means that its actually lost, since the real
/var is not available yet.

Another approach would be not enable those units, but right now they are
statically enabled, and changing that would be more work, and doesn't really
seem necessary, since the condition checks are very quick.

Checking for /etc/initrd-release is the standard condition that the initrd
units use, so let's do the same here.

units/systemd-journal-flush.service
units/systemd-random-seed.service.in
units/systemd-tmpfiles-clean.timer

index 1a71592b931be0f8f90066221b0d2785971dc55c..6423f6ea80c848e2de745261130cf43374484cd0 100644 (file)
@@ -15,6 +15,7 @@ Requires=systemd-journald.service
 After=systemd-journald.service systemd-remount-fs.service
 Before=systemd-tmpfiles-setup.service
 RequiresMountsFor=/var/log/journal
+ConditionPathExists=!/etc/initrd-release
 
 [Service]
 ExecStart=journalctl --flush
index 5c542ec84646b67b2dca1e6db89c1c664d19125e..1aa9af9710476c13b1740668f1692dc9e952b340 100644 (file)
@@ -17,6 +17,7 @@ After=systemd-remount-fs.service
 Before=first-boot-complete.target shutdown.target
 Wants=first-boot-complete.target
 ConditionVirtualization=!container
+ConditionPathExists=!/etc/initrd-release
 
 [Service]
 Type=oneshot
index 6c6cfe7a08403c070e6b1baa0a943021bc088643..310cfe28e38a61a3e8ae24765a085cf9e6e8365e 100644 (file)
@@ -10,6 +10,7 @@
 [Unit]
 Description=Daily Cleanup of Temporary Directories
 Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
+ConditionPathExists=!/etc/initrd-release
 
 [Timer]
 OnBootSec=15min