mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 21:17:55 +00:00
gui-init: add support for auto-booting default target
if CONFIG_AUTO_BOOT_TIMEOUT exists and is set, and if HOTP validation was successful, then attempt to boot the default target after CONFIG_AUTO_BOOT_TIMEOUT seconds if not interrupted by key press Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
This commit is contained in:
parent
89c457706f
commit
055165d61a
@ -9,6 +9,8 @@ export BG_COLOR_ERROR="${CONFIG_ERROR_BG_COLOR:-"--background-gradient 0 0 0 150
|
||||
. /etc/functions
|
||||
. /tmp/config
|
||||
|
||||
first_pass=true
|
||||
|
||||
mount_boot()
|
||||
{
|
||||
|
||||
@ -239,6 +241,23 @@ while true; do
|
||||
HOTP='N/A'
|
||||
fi
|
||||
|
||||
if [[ "$HOTP" = "Success" && $CONFIG_AUTO_BOOT_TIMEOUT && $first_pass = true ]]; then
|
||||
# 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
|
||||
# skip to default boot
|
||||
totp_confirm='y'
|
||||
echo -e "\n\nAttempting default boot...\n\n"
|
||||
fi
|
||||
IFS=$IFS_DEF
|
||||
fi
|
||||
|
||||
if [ "$totp_confirm" != "y" -o -z "$totp_confirm" ]; then
|
||||
whiptail $MAIN_MENU_BG_COLOR --clear --title "$MAIN_MENU_TITLE" \
|
||||
--menu "$date\nTOTP: $TOTP | HOTP: $HOTP" 20 90 10 \
|
||||
'y' ' Default boot' \
|
||||
@ -250,6 +269,7 @@ while true; do
|
||||
|
||||
totp_confirm=$(cat /tmp/whiptail)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$totp_confirm" = "a" ]; then
|
||||
whiptail --clear --title "HEADS Options" \
|
||||
|
Loading…
Reference in New Issue
Block a user