-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30ignition-coreos: Add
coreos-boot-edit.{service,sh}
`coreos-boot-edit.service` will run late in the initrd process after Ignition is completed successfully and temporarily mount /boot read-only to make edits in /boot (e.g. removing firstboot networking configuration files if necessary).
- Loading branch information
1 parent
9df08be
commit 7e684bf
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
overlay.d/05core/usr/lib/dracut/modules.d/30ignition-coreos/coreos-boot-edit.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This unit will run late in the initrd process after Ignition is completed | ||
# successfully and temporarily mount /boot read-only to make edits in /boot | ||
# (e.g. removing firstboot networking configuration files if necessary). | ||
|
||
[Unit] | ||
Description=CoreOS Boot Edit | ||
ConditionPathExists=/usr/lib/initrd-release | ||
ConditionPathExists=/run/coreos-copy-firstboot-network.stamp | ||
OnFailure=emergency.target | ||
OnFailureJobMode=isolate | ||
|
||
# Since we are mounting /boot, require the device first | ||
Requires=dev-disk-by\x2dlabel-boot.device | ||
After=dev-disk-by\x2dlabel-boot.device | ||
# Start after Ignition has finished | ||
After=ignition-files.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/sbin/coreos-boot-edit | ||
RemainAfterExit=yes | ||
# MountFlags=slave is so the umount of /boot is guaranteed to happen. | ||
# /boot will only be mounted for the lifetime of the unit. | ||
MountFlags=slave |
18 changes: 18 additions & 0 deletions
18
overlay.d/05core/usr/lib/dracut/modules.d/30ignition-coreos/coreos-boot-edit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# For a description of how this is used, see `coreos-boot-edit.service`. | ||
|
||
# Clean up firstboot networking config files if the user copied them into the | ||
# installed system (most likely by using `coreos-installer install --copy-network`). | ||
bootmnt=/mnt/boot_partition | ||
mkdir -p ${bootmnt} | ||
bootdev=/dev/disk/by-label/boot | ||
firstboot_network_dir_basename="coreos-firstboot-network" | ||
initramfs_firstboot_network_dir="${bootmnt}/${firstboot_network_dir_basename}" | ||
|
||
# Mount /boot. Note that we mount /boot but we don't unmount it because we | ||
# are run in a systemd unit with MountFlags=slave so it is unmounted for us. | ||
mount -o rw ${bootdev} ${bootmnt} | ||
|
||
rm -vrf ${initramfs_firstboot_network_dir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters