diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-sysroot.service b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-firstboot-sysroot.service similarity index 65% rename from overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-sysroot.service rename to overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-firstboot-sysroot.service index 9c09ad96ed..ff8224def1 100644 --- a/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-sysroot.service +++ b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-firstboot-sysroot.service @@ -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 diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-subsequent-sysroot.service b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-subsequent-sysroot.service new file mode 100644 index 0000000000..45f34385e4 --- /dev/null +++ b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/ignition-ostree-mount-subsequent-sysroot.service @@ -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 diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/module-setup.sh b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/module-setup.sh index 99bf35b598..cf0ba38c9e 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/module-setup.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/40ignition-ostree/module-setup.sh @@ -7,9 +7,12 @@ 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() { @@ -17,17 +20,13 @@ install() { 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" }