# SystemRescue loopback-mount GRUB config file

# Per loopback.cfg convention, 'iso_path' should have been set to the
# filesystem location of the SystemRescue ISO-image file.
# (Reference: https://www.supergrubdisk.org/wiki/Loopback.cfg)

if [ -z "$iso_path" ]
then
	echo "Warning: 'iso_path' is not set."

elif search --file --set=archiso_grub_dev --no-floppy $iso_path
then
	echo "Found '$iso_path' on ($archiso_grub_dev)"

	if probe --fs-uuid --set=archiso_fs_uuid $archiso_grub_dev
	then
		echo "($archiso_grub_dev) filesystem UUID: $archiso_fs_uuid"
		archiso_param="img_dev=/dev/disk/by-uuid/$archiso_fs_uuid img_loop=$iso_path"
	else
		echo
		echo "Warning: Could not get filesystem UUID for ($archiso_grub_dev)."
	fi
else
	echo
	echo "Warning: Could not find the SystemRescue ISO-image file."
fi

if [ -z "$archiso_param" ]
then
	echo "The following GRUB menu is unlikely to boot SystemRescue successfully."
	echo
	echo -n "Press Enter to continue ... "
	read
fi

srcd_skip_init=yes
source /boot/grub/grubsrcd.cfg
