heads/initrd/bin/usb-init
Francis Lam efd662c63a
adds a USB boot option with basic parsing to kexec
Supports booting from USB media using either the root device or
a signed ISO as the boot device.  Boot options are parsed with
quick/dirty shell scripts to infer kexec params.

Closes #195 and begins to address #196
2017-04-29 13:40:34 -04:00

66 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Boot a Tails installation
. /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
# TODO: Do a scan of USB devices to detect the Tails USB
mount-usb "$CONFIG_USB_BOOT_DEV"
# 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
exec usb-iso-init $option
fi
fi
echo "!!! Could not find any ISO, trying bootable USB"
exec usb-select-boot /media
recovery "Something failed..."