Skip to content

Commit

Permalink
ignition-ostree: Split unit for sysroot mounting
Browse files Browse the repository at this point in the history
The unit to mount sysroot only worked the *first* boot
because it was integrated with Ignition.  We need to have
separate units with different dependencies (but that execute
the same code) for the "Ignition boot" compared with "subsequent"
boots.

Depends coreos/ignition-dracut#131
  • Loading branch information
cgwalters authored and jlebon committed Oct 31, 2019
1 parent 464d055 commit 52dd9db
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[Unit]
Description=Mount OSTree /sysroot
Description=Ignition OSTree: Mount (firstboot) /sysroot
# These dependencies should match the "other" in
# ignition-ostree-mount-subsequent-sysroot.service
DefaultDependencies=false
# If root is specified, then systemd's generator will win
ConditionKernelCommandLine=!root
ConditionKernelCommandLine=ostree
ConditionPathExists=!/run/ostree-live

# There can be only one, Highlander style
Conflicts=ignition-ostree-mount-subsequent-sysroot.service
Before=initrd-root-fs.target
After=ignition-disks.service
# These have an explicit dependency on After=sysroot.mount today
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Unit]
Description=CoreOS: Mount (subsequent) /sysroot
# These dependencies should match the "other" in
# ignition-ostree-mount-firsboot-sysroot.service
DefaultDependencies=false
# If root is specified, then systemd's generator will win
ConditionKernelCommandLine=!root
ConditionKernelCommandLine=ostree
ConditionPathExists=!/run/ostree-live
# There can be only one, Highlander style
Conflicts=ignition-ostree-mount-firstboot-sysroot.service
# And in contrast to the firstboot, we expect
# the root device to be ready.
Requires=dev-disk-by\x2dlabel-root.device
After=dev-disk-by\x2dlabel-root.device
Before=initrd-root-fs.target
# This has an explicit dependency on After=sysroot.mount today
Before=ostree-prepare-root.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ignition-ostree-mount-sysroot
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ depends() {
}

install_ignition_unit() {
unit=$1; shift
local unit=$1; shift
local target=${1:-complete}
inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit"
ln_r "../$unit" "$systemdsystemunitdir/ignition-complete.target.requires/$unit"
local targetpath="$systemdsystemunitdir/ignition-${target}.target.requires/"
mkdir -p "${initdir}/${targetpath}"
ln_r "../$unit" "${targetpath}/${unit}"
}

install() {
inst_multiple \
systemd-sysusers \
systemd-tmpfiles

mkdir -p "$initdir/$systemdsystemunitdir/ignition-complete.target.requires"
for x in mount populate; do
install_ignition_unit ignition-ostree-${x}-var.service
inst_script "$moddir/ignition-ostree-${x}-var.sh" "/usr/sbin/ignition-ostree-${x}-var"
done

install_ignition_unit ignition-ostree-mount-var.service
inst_script "$moddir/ignition-ostree-mount-var.sh" \
"/usr/sbin/ignition-ostree-mount-var"

install_ignition_unit ignition-ostree-populate-var.service
inst_script "$moddir/ignition-ostree-populate-var.sh" \
"/usr/sbin/ignition-ostree-populate-var"

install_ignition_unit ignition-ostree-mount-sysroot.service
install_ignition_unit ignition-ostree-mount-firstboot-sysroot.service
install_ignition_unit ignition-ostree-mount-subsequent-sysroot.service subsequent
inst_script "$moddir/ignition-ostree-mount-sysroot.sh" \
"/usr/sbin/ignition-ostree-mount-sysroot"
}

0 comments on commit 52dd9db

Please sign in to comment.