Add gui option to kexec-select-boot, use in gui-init menu option

When selecting the boot menu option (m) in the gui-init you call out to
kexec-select-boot. To better maintain the graphical menu experience,
I've added a -g option to kexec-select-boot that, when set, will use a
graphical whiptail menu for the most common menu selection modes.
This commit is contained in:
Kyle Rankin 2018-02-22 13:18:16 -08:00
parent 57405b0d28
commit 6ab78ae236
No known key found for this signature in database
GPG Key ID: 555577116BFA74B9
2 changed files with 38 additions and 9 deletions

View File

@ -82,7 +82,7 @@ while true; do
if [ "$totp_confirm" = "m" ]; then
# Try to select a kernel from the menu
mount_boot
kexec-select-boot -m -b /boot -c "grub.cfg"
kexec-select-boot -m -b /boot -c "grub.cfg" -g
continue
fi

View File

@ -12,7 +12,8 @@ valid_hash="n"
valid_global_hash="n"
valid_rollback="n"
force_menu="n"
while getopts "b:d:p:a:r:c:uim" arg; do
gui_menu="n"
while getopts "b:d:p:a:r:c:uimg" arg; do
case $arg in
b) bootdir="$OPTARG" ;;
d) paramsdev="$OPTARG" ;;
@ -23,6 +24,7 @@ while getopts "b:d:p:a:r:c:uim" arg; do
u) unique="y" ;;
m) force_menu="y" ;;
i) valid_hash="y"; valid_rollback="y" ;;
g) gui_menu="y" ;;
esac
done
@ -80,6 +82,24 @@ get_menu_option() {
if [ $num_options -eq 1 -a $first_menu = "y" ]; then
option_index=1
elif [ "$gui_menu" = "y" ]; then
MENU_OPTIONS=""
n=0
while read option
do
parse_option
n=`expr $n + 1`
name=$(echo $name | tr " " "_")
kernel=$(echo $kernel | cut -f2 -d " ")
MENU_OPTIONS="$MENU_OPTIONS $n ${name}_[$kernel]"
done < $TMP_MENU_FILE
whiptail --clear --title "Select your boot option" \
--menu "Choose the boot option [1-$n, a to abort]:" 20 120 8 \
-- $MENU_OPTIONS \
2>/tmp/whiptail || die "Aborting boot attempt"
option_index=$(cat /tmp/whiptail)
else
echo "+++ Select your boot option:"
n=0
@ -105,14 +125,23 @@ get_menu_option() {
}
confirm_menu_option() {
echo "+++ Please confirm the boot details for $name:"
echo $option
if [ "$gui_menu" = "y" ]; then
whiptail --clear --title "Confirm boot details" \
--menu "Confirm the boot details for $name:\n\n$option\n\n" 20 120 8 \
-- 'y' "Boot $name" 'd' "Make $name the default" \
2>/tmp/whiptail || die "Aborting boot attempt"
read \
-n 1 \
-p "Confirm selection by pressing 'y', make default with 'd': " \
option_confirm
echo
option_confirm=$(cat /tmp/whiptail)
else
echo "+++ Please confirm the boot details for $name:"
echo $option
read \
-n 1 \
-p "Confirm selection by pressing 'y', make default with 'd': " \
option_confirm
echo
fi
}
parse_option() {