diff --git a/dracut-modules/90void-usb/squashfs-img.sh b/dracut-modules/90void-usb/squashfs-img.sh index a9bf588..5a9e1d5 100644 --- a/dracut-modules/90void-usb/squashfs-img.sh +++ b/dracut-modules/90void-usb/squashfs-img.sh @@ -1 +1,27 @@ #!/bin/bash + +type getarg > /dev/null 2>&1 || source /lib/dracut-lib.sh + +[ ! -d /sysroot/container ] && mkdir -p /sysroot/container + +CONTAINER="$(getarg void-usb-container)" +case "$CONTAINER" in + LABEL=* | UUID=* | PARTUUID=* | PARTLABEL=*) + CONTAINER="$(label_uuid_to_dev "$CONTAINER")" + ;; + /dev/*) + true + ;; + *) + echo -e "Invalid value for 'void-usb-container' kernel command line parameter!\nDropping into emergency shell." + emergency_shell +esac + +mount -t f2fs -o nodev,nosuid "$CONTAINER" /sysroot/container + +if [ -f /sysroot/container/squashfs.img ]; then + losetup -r -f /sysroot/container/squashfs.img +else + echo "Failed to find squashfs image. Dropping into an emergency shell. Good luck!" + emergency_shell +fi