diff --git a/initrd/bin/gui-init b/initrd/bin/gui-init index f6480c6e..8b904019 100755 --- a/initrd/bin/gui-init +++ b/initrd/bin/gui-init @@ -357,18 +357,11 @@ check_gpg_key() prompt_auto_default_boot() { TRACE "Under /bin/gui-init:prompt_auto_default_boot" - # save IFS before changing, restore after read - IFS_DEF=$IFS - IFS='' - first_pass=false echo -e "\nHOTP verification success\n\n" - read -t $CONFIG_AUTO_BOOT_TIMEOUT -s -n 1 -p "Automatic boot in $CONFIG_AUTO_BOOT_TIMEOUT seconds unless interrupted by keypress... " - if [[ $? -ne 0 ]]; then - IFS=$IFS_DEF + if pause_automatic_boot; then echo -e "\n\nAttempting default boot...\n\n" attempt_default_boot fi - IFS=$IFS_DEF } show_main_menu() diff --git a/initrd/etc/gui_functions b/initrd/etc/gui_functions index c0c40465..a2da1382 100755 --- a/initrd/etc/gui_functions +++ b/initrd/etc/gui_functions @@ -2,6 +2,17 @@ # Shell functions for common operations using fbwhiptail . /etc/functions +# Pause for the configured timeout before booting automatically. Returns 0 to +# continue with automatic boot, nonzero if user interrupted. +pause_automatic_boot() +{ + if IFS= read -t "$CONFIG_AUTO_BOOT_TIMEOUT" -s -n 1 -p \ + "Automatic boot in $CONFIG_AUTO_BOOT_TIMEOUT seconds unless interrupted by keypress... "; then + return 1 # Interrupt automatic boot + fi + return 0 # Continue with automatic boot +} + mount_usb() { TRACE "under gui_functions:mount_usb"