2023-06-28 13:02:25 +02:00
|
|
|
#!/bin/bash
|
2023-06-28 14:05:23 +02:00
|
|
|
|
|
|
|
type getarg > /dev/null 2>&1 || source /lib/dracut-lib.sh
|
|
|
|
|
2023-06-28 19:55:09 +02:00
|
|
|
[ ! -d /run/void-usb/container ] && mkdir -p /run/void-usb/container
|
2023-06-28 14:05:23 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-06-28 15:19:06 +02:00
|
|
|
# try to wait for $CONTAINER to be available
|
|
|
|
function mount_container {
|
2023-06-28 19:55:09 +02:00
|
|
|
mount -t f2fs -o nodev,nosuid "$CONTAINER" /run/void-usb/container;
|
2023-06-28 15:19:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
else
|
|
|
|
sleep 1
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
else
|
|
|
|
sleep 1
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
else
|
|
|
|
sleep 3
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
else
|
|
|
|
sleep 5
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
if [ -b "$CONTAINER" ]; then
|
|
|
|
mount_container
|
|
|
|
fi
|
|
|
|
# assume that the drive won't show up after more than 20s
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2023-06-28 14:05:23 +02:00
|
|
|
|
2023-06-28 19:55:09 +02:00
|
|
|
if [ -f /run/void-usb/container/squashfs.img ]; then
|
|
|
|
losetup -r -f /run/void-usb/container/squashfs.img
|
2023-06-28 14:05:23 +02:00
|
|
|
else
|
|
|
|
echo "Failed to find squashfs image. Dropping into an emergency shell. Good luck!"
|
|
|
|
emergency_shell
|
|
|
|
fi
|