2017-07-03 17:07:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Scan for USB installation options
|
2017-07-12 04:17:45 +00:00
|
|
|
set -e -o pipefail
|
2017-07-03 17:07:03 +00:00
|
|
|
. /etc/functions
|
|
|
|
. /etc/config
|
|
|
|
|
2017-07-04 23:49:14 +00:00
|
|
|
# Unmount any previous boot device
|
|
|
|
if grep -q /boot /proc/mounts ; then
|
|
|
|
umount /boot \
|
2017-07-08 20:59:37 +00:00
|
|
|
|| die '$CONFIG_USB_BOOT_DEV: Unable to unmount /boot'
|
2017-07-04 23:49:14 +00:00
|
|
|
fi
|
|
|
|
|
2017-07-03 17:07:03 +00:00
|
|
|
# Mount the USB boot device
|
2017-07-04 23:49:14 +00:00
|
|
|
if ! grep -q /media /proc/mounts ; then
|
|
|
|
mount-usb "$CONFIG_USB_BOOT_DEV" \
|
2017-07-08 20:59:37 +00:00
|
|
|
|| die '$CONFIG_USB_BOOT_DEV: Unable to mount /media'
|
2017-07-04 23:49:14 +00:00
|
|
|
fi
|
2017-07-03 17:07:03 +00: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
|
2017-07-08 20:59:37 +00:00
|
|
|
die "Aborting boot attempt"
|
2017-07-03 17:07:03 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$option_index" = "s" ]; then
|
|
|
|
option=""
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
option=`head -n $option_index /tmp/iso_menu.txt | tail -1`
|
|
|
|
}
|
|
|
|
|
|
|
|
# create ISO menu options
|
2017-07-12 04:17:45 +00:00
|
|
|
ls -1r /media/*.iso 2>/dev/null > /tmp/iso_menu.txt || true
|
2017-07-03 17:07:03 +00:00
|
|
|
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-iso-init $MOUNTED_ISO $ISO $CONFIG_USB_BOOT_DEV
|
|
|
|
|
2017-07-08 20:59:37 +00:00
|
|
|
die "Something failed in iso init"
|
2017-07-03 17:07:03 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "!!! Could not find any ISO, trying bootable USB"
|
|
|
|
# Attempt to pull verified config from device
|
2017-07-04 23:49:14 +00:00
|
|
|
kexec-select-boot -b /media/ -c "*.cfg" -u
|
2017-07-03 17:07:03 +00:00
|
|
|
|
2017-07-08 20:59:37 +00:00
|
|
|
die "Something failed in selecting boot"
|