packages: Add after-install target unit

Units that get installed via `rpm-ostree` on first boot cannot be
enabled by ignition, because they do not exist when it runs `systemctl
preset`.  Thus, anything we want to start after its been installed needs
to be explicitly started.  To allow this in an extensible fashion, I've
added an `after-install.target` unit and modified the
`install-packages.sh` script to activate this unit once the installation
is complete.  The script also re-runs `systemctl preset`, so services
will start automatically on subsequent boots.
master
Dustin 2024-01-06 19:43:08 -06:00
parent 9d941a9985
commit ac6c31c5d8
3 changed files with 9 additions and 0 deletions

2
after-install.target Normal file
View File

@ -0,0 +1,2 @@
[Unit]
Description=Start services after package install

View File

@ -6,3 +6,6 @@ if [ ! -d /etc/ignition/packages.d ]; then
fi
cat /etc/ignition/packages.d/* | xargs rpm-ostree install --apply-live -y
systemctl preset-all --preset-mode=enable-only
systemctl start after-install.target

View File

@ -14,6 +14,10 @@ storage:
mode: 0644
contents:
local: install-packages.service
- path: /etc/systemd/system/after-install.target
mode: 0644
contents:
local: after-install.target
systemd:
units: