mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 13:07:58 +00:00
ce4b91cad9
Also split out usb-scan to allow manual initiation of scan from the recovery shell
62 lines
1.3 KiB
Bash
Executable File
62 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
# Scan for USB installation options
|
|
|
|
. /etc/functions
|
|
. /etc/config
|
|
|
|
# Mount the USB boot device
|
|
mount-usb "$CONFIG_USB_BOOT_DEV" \
|
|
|| recovery '$CONFIG_USB_BOOT_DEV: Unable to mount /media'
|
|
|
|
# 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 [ `cat /tmp/iso_menu.txt | wc -l` -gt 0 ]; then
|
|
option_confirm=""
|
|
while [ -z "$option" -a "$option_index" != "s" ]
|
|
do
|
|
get_menu_option
|
|
done
|
|
|
|
if [ -n "$option" ]; then
|
|
MOUNTED_ISO=$option
|
|
ISO=${option:7} # remove /media/ to get device relative path
|
|
kexec-check-config /media/kexec_iso/$ISO/
|
|
kexec-iso-init $MOUNTED_ISO $ISO $CONFIG_USB_BOOT_DEV
|
|
|
|
recovery "Something failed..."
|
|
fi
|
|
fi
|
|
|
|
echo "!!! Could not find any ISO, trying bootable USB"
|
|
# Attempt to pull verified config from device
|
|
kexec-check-config /media/
|
|
kexec-select-boot /media/
|
|
|
|
recovery "Something failed..."
|