diff --git a/tools-image/build-arm-image.sh b/tools-image/build-arm-image.sh index 5f4bd72..a8b34c2 100755 --- a/tools-image/build-arm-image.sh +++ b/tools-image/build-arm-image.sh @@ -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