Skip to content

Commit

Permalink
overlay: adding tmpfiles.d entry for removal of /boot/coreos-firstboo…
Browse files Browse the repository at this point in the history
…t-network

This will clean up those files if they existed and were used.
  • Loading branch information
dustymabe committed Apr 16, 2020
1 parent e869586 commit dffc863
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit dffc863

Please sign in to comment.