🐛 Copy default values and configs in the oem partition for rpi

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka 2023-06-02 14:28:30 +02:00
parent 53a74136d6
commit a892113ff6

View File

@ -72,6 +72,13 @@ cleanup() {
umount $oem || true
fi
losetup -D || true
for LOOPS in $(losetup -a | awk -F':' {'print $1'} | awk -F'/' {'print $3'}); do
for LOOPPART in $(ls /dev/mapper/${LOOPS}*| awk -F'/' {'print $4'}); do
dmsetup remove "${LOOPPART}";
done;
losetup -d /dev/"${LOOPS}";
done
}
ensure_dir_structure() {
@ -423,23 +430,30 @@ fi
mount $state $WORKDIR/state
mount $efi $WORKDIR/efi
mkdir $WORKDIR/persistent
mount $persistent $WORKDIR/persistent
mkdir -p $WORKDIR/persistent/cloud-config
cp -rfv /defaults.yaml $WORKDIR/persistent/cloud-config/01_defaults.yaml
if [ "$disable_lvm" == "false" ]; then
mkdir $WORKDIR/oem
mount $oem_lv $WORKDIR/oem
cp -rfv /defaults.yaml $WORKDIR/oem/01_defaults.yaml
# Set a OEM config file if specified
if [ -n "$config" ]; then
echo ">> Copying $config OEM config file"
get_url $config $WORKDIR/oem/99_custom.yaml
fi
umount $WORKDIR/oem
else
echo "LVM disabled: Not adding default config with default user/pass and custom config file"
echo "Enable LVM to copy those files into /oem"
fi
grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=$menu_entry"
# We copy the file we saved earier to the STATE partition
cp -rfv "${tmpgrubconfig}" $WORKDIR/state/grubmenu
# Set a OEM config file if specified
if [ -n "$config" ]; then
echo ">> Copying $config OEM config file"
get_url $config $WORKDIR/persistent/cloud-config/99_custom.yaml
fi
umount $WORKDIR/persistent
# Copy over content
cp -arf $EFI/* $WORKDIR/efi