Extract pause_automatic_boot() from gui-init to gui_functions

pause_automatic_boot() prompts that an automatic boot is about to occur
and allows the user to interrupt it.

Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm>
This commit is contained in:
Jonathon Hall 2022-11-09 14:00:53 -05:00
parent 5d7afa2e02
commit b365f1324a
No known key found for this signature in database
GPG Key ID: 1E9C3CA91AE25114
2 changed files with 12 additions and 8 deletions

View File

@ -357,18 +357,11 @@ check_gpg_key()
prompt_auto_default_boot() prompt_auto_default_boot()
{ {
TRACE "Under /bin/gui-init: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" 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 pause_automatic_boot; then
if [[ $? -ne 0 ]]; then
IFS=$IFS_DEF
echo -e "\n\nAttempting default boot...\n\n" echo -e "\n\nAttempting default boot...\n\n"
attempt_default_boot attempt_default_boot
fi fi
IFS=$IFS_DEF
} }
show_main_menu() show_main_menu()

View File

@ -2,6 +2,17 @@
# Shell functions for common operations using fbwhiptail # Shell functions for common operations using fbwhiptail
. /etc/functions . /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() mount_usb()
{ {
TRACE "under gui_functions:mount_usb" TRACE "under gui_functions:mount_usb"