2017-04-29 13:40:34 -04:00
|
|
|
#!/bin/sh
|
2017-07-02 23:01:04 -04:00
|
|
|
# Boot a USB installation
|
2017-04-29 13:40:34 -04:00
|
|
|
|
|
|
|
. /etc/functions
|
|
|
|
. /etc/config
|
|
|
|
|
|
|
|
# Confirm we have a good TOTP unseal
|
|
|
|
if ! confirm_totp ; then
|
|
|
|
recovery 'Failed to unseal TOTP'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Extend PCR4 as soon as possible
|
|
|
|
tpm extend -ix 4 -ic usb
|
|
|
|
|
|
|
|
if [ ! "$totp_confirm" = "y" ]; then
|
|
|
|
recovery "Failed to confirm validity of TOTP"
|
|
|
|
fi
|
|
|
|
|
2017-07-02 23:01:04 -04:00
|
|
|
# Mount the USB boot device
|
|
|
|
mount-usb "$CONFIG_USB_BOOT_DEV" \
|
|
|
|
|| recovery '$CONFIG_USB_BOOT_DEV: Unable to mount /media'
|
2017-04-29 13:40:34 -04:00
|
|
|
|
|
|
|
# Check for ISO first
|
|
|
|
get_menu_option() {
|
|
|
|
echo "+++ Select your ISO boot option:"
|
|
|
|
n=0
|
|
|
|
while read option
|
|
|
|
do
|
|
|
|
n=`expr $n + 1`
|
|
|
|
echo "$n. $option"
|
|
|
|
done < /tmp/iso_menu.txt
|
|
|
|
|
|
|
|
read \
|
|
|
|
-p "Choose the ISO boot option [1-$n, s for standard boot, a to abort]: " \
|
|
|
|
option_index
|
|
|
|
|
|
|
|
if [ "$option_index" = "a" ]; then
|
|
|
|
recovery "Aborting boot attempt"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$option_index" = "s" ]; then
|
|
|
|
option=""
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
option=`head -n $option_index /tmp/iso_menu.txt | tail -1`
|
|
|
|
}
|
|
|
|
|
|
|
|
# create ISO menu options
|
|
|
|
ls -1r /media/*.iso 2>/dev/null > /tmp/iso_menu.txt
|
|
|
|
if [ `wc -l /tmp/iso_menu.txt | cut -d\ -f1` -gt 0 ]; then
|
|
|
|
option_confirm=""
|
|
|
|
while [ -z "$option" -a "$option_index" != "s" ]
|
|
|
|
do
|
|
|
|
get_menu_option
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$option" ]; then
|
2017-07-02 23:01:04 -04:00
|
|
|
MOUNTED_ISO=$option
|
|
|
|
ISO=${option:7} # remove /media/ to get device relative path
|
|
|
|
kexec-check-config /media/kexec_iso/$ISO
|
|
|
|
exec kexec-iso-init $MOUNTED_ISO $ISO $CONFIG_USB_BOOT_DEV
|
2017-04-29 13:40:34 -04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "!!! Could not find any ISO, trying bootable USB"
|
2017-07-02 23:01:04 -04:00
|
|
|
# Attempt to pull verified config from device
|
|
|
|
kexec-check-config /media
|
|
|
|
exec kexec-select-boot /media
|
2017-04-29 13:40:34 -04:00
|
|
|
|
|
|
|
recovery "Something failed..."
|