Add enhanced error handling to make-image-raw

This commit is contained in:
Fierelier 2022-08-08 21:21:28 +02:00
parent 256dd3b2f0
commit a026ea863c

View File

@ -1,8 +1,11 @@
#!/usr/bin/env bash
set -e
if
export DISK_IMAGE="$2"
export ROOT_MOUNT="$OPUS_OUTPUT/mount"
export DISK_IMAGE="$2"
export ROOT_MOUNT="$1-mount"
set +e
(
set -e
# Get the approximate size required for the image
export DISK_SIZE=$(du -sb "$1" | cut -f1)
@ -44,7 +47,7 @@ if
mount "${DISK_LOOP}p2" "$ROOT_MOUNT"
# Add files
dupe "$1/." "$ROOT_MOUNT"
cp -a "$1/." "$ROOT_MOUNT"
# Make fstab
echo "UUID=$(blkid -o value -s UUID "${DISK_LOOP}p1") none swap sw 0 0" >"$ROOT_MOUNT/etc/fstab"
@ -60,10 +63,8 @@ if
umount -l "$ROOT_MOUNT"
rmdir "$ROOT_MOUNT"
losetup -d "$DISK_LOOP"
then
set +e
else
set +e
)
if [ $? != 0 ]; then
echo
echo Script execution ended due to error. Cleaning up...
umount -l "$ROOT_MOUNT"