Add a whiptail GUI to usb-scan

This commit is contained in:
Kyle Rankin 2018-05-02 14:29:27 -07:00
parent 8108e419fe
commit f70fabd187
No known key found for this signature in database
GPG Key ID: 555577116BFA74B9

View File

@ -18,17 +18,35 @@ fi
# 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
if [ -x /bin/whiptail ]; then
MENU_OPTIONS=""
n=0
while read option
do
n=`expr $n + 1`
option=$(echo $option | tr " " "_")
MENU_OPTIONS="$MENU_OPTIONS $n ${option}"
done < $TMP_MENU_FILE
read \
-p "Choose the ISO boot option [1-$n, s for standard boot, a to abort]: " \
option_index
whiptail --clear --title "Select your ISO boot option" \
--menu "Choose the ISO boot option [1-$n, s for standard boot, a to abort]:" 20 120 8 \
-- $MENU_OPTIONS \
2>/tmp/whiptail || die "Aborting boot attempt"
option_index=$(cat /tmp/whiptail)
else
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
fi
if [ "$option_index" = "a" ]; then
die "Aborting boot attempt"
@ -62,6 +80,10 @@ fi
echo "!!! Could not find any ISO, trying bootable USB"
# Attempt to pull verified config from device
kexec-select-boot -b /media -c "*.cfg" -u
if [ -x /bin/whiptail ]; then
kexec-select-boot -b /media -c "*.cfg" -u -g
else
kexec-select-boot -b /media -c "*.cfg" -u
fi
die "Something failed in selecting boot"