From dffc863b07716a11b773d33174336490503c122d Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Thu, 16 Apr 2020 12:45:46 -0400 Subject: [PATCH] overlay: adding tmpfiles.d entry for removal of /boot/coreos-firstboot-network This will clean up those files if they existed and were used. --- .../coreos-copy-firstboot-network.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-copy-firstboot-network/coreos-copy-firstboot-network.sh b/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-copy-firstboot-network/coreos-copy-firstboot-network.sh index 9ae960c9a9..43c2d5ac6a 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-copy-firstboot-network/coreos-copy-firstboot-network.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-copy-firstboot-network/coreos-copy-firstboot-network.sh @@ -4,8 +4,10 @@ set -euo pipefail # For a description of how this is used see coreos-copy-firstboot-network.service bootmnt=/mnt/boot_partition -firstboot_network_dir="${bootmnt}/coreos-firstboot-network/" +firstboot_network_dir_basename="coreos-firstboot-network" +initramfs_firstboot_network_dir="${bootmnt}/${firstboot_network_dir_basename}" initramfs_network_dir="/run/NetworkManager/system-connections/" +realroot_firstboot_network_dir="/boot/${firstboot_network_dir_basename}" # Mount /boot. Note that we mount /boot but we don't unmount boot because we # are run in a systemd unit with MountFlags=slave so it is unmounted for us. @@ -14,15 +16,19 @@ mkdir -p $bootmnt # running alongside other code that also has it mounted ro mount -o ro /dev/disk/by-label/boot $bootmnt -if [ -n "$(ls -A ${firstboot_network_dir} 2>/dev/null)" ]; then +if [ -n "$(ls -A ${initramfs_firstboot_network_dir} 2>/dev/null)" ]; then # Clear out any files that may have already been generated from # kargs by nm-initrd-generator rm -f ${initramfs_network_dir}/* # Copy files that were placed into boot (most likely by coreos-installer) # to the appropriate location for NetworkManager to use the configuration. - echo "info: copying files from ${firstboot_network_dir} to ${initramfs_network_dir}" + echo "info: copying files from ${initramfs_firstboot_network_dir} to ${initramfs_network_dir}" mkdir -p ${initramfs_network_dir} - cp -v ${firstboot_network_dir}/* ${initramfs_network_dir}/ + cp -v ${initramfs_firstboot_network_dir}/* ${initramfs_network_dir}/ + # If we make it to the realroot (successfully ran ignition) then + # clean up the files in the firstboot network dir + echo "R ${realroot_firstboot_network_dir} - - - - -" > \ + /run/tmpfiles.d/15-coreos-firstboot-network.conf else - echo "info: no files to copy from ${firstboot_network_dir}. skipping" + echo "info: no files to copy from ${initramfs_firstboot_network_dir}. skipping" fi