forked from coreos/fedora-coreos-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
15coreos-network: Add new unit to remove firstboot networking config
We would like to mount `/boot` read-only in the real root, so add a new unit in 15coreos-network to temporarily mount /boot rw and clean up firstboot networking configuration files late in the initramfs. Remove the current 15-coreos-firstboot-network.conf since it would not work once `/boot` is mounted ro. xref coreos#659
- Loading branch information
1 parent
599311b
commit 9b682d8
Showing
4 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...05core/usr/lib/dracut/modules.d/15coreos-network/coreos-cleanup-firstboot-network.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,20 @@ | ||
# This unit will run late in the initrd process and clean up firstboot | ||
# networking config files if the user copied them into the installed | ||
# system (most likely by using `coreos-installer install --copy-network`). | ||
# We want to make sure the firstboot networking config files in /boot are | ||
# cleaned up only after Ignition completed successfully. | ||
|
||
[Unit] | ||
Description=CoreOS Clean Up Firstboot Networking Config | ||
OnFailure=emergency.target | ||
OnFailureJobMode=isolate | ||
|
||
After=ignition-files.service | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/sbin/coreos-cleanup-firstboot-network | ||
RemainAfterExit=no | ||
# 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 |
19 changes: 19 additions & 0 deletions
19
...ay.d/05core/usr/lib/dracut/modules.d/15coreos-network/coreos-cleanup-firstboot-network.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,19 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# For a description of how this is used, see coreos-cleanup-firstboot-network.service | ||
|
||
bootmnt=/mnt/boot_partition | ||
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} | ||
|
||
if [ -n "$(ls -A ${initramfs_firstboot_network_dir} 2>/dev/null)" ]; then | ||
rm -r ${initramfs_firstboot_network_dir} | ||
else | ||
echo "info: no firstboot networking config files to clean from /boot. skipping" | ||
fi |
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
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