gui-init: chain initial checks outside of main loop

Checking the keyring for a GPG and updating the TOTP/HTOP
status need only happen once at initial boot; the latter
can be updated at any later time from the main menu itself.
Having them repeated each loop of the main menu is unnecessary
(and often annoying). Likewise, the default auto boot can be
moved and the first_pass (and unused MAIN_MENU_OPTIONS)
variable dropped.

Signed-off-by: Matt DeVillier <matt.devillier@puri.sm>
This commit is contained in:
Matt DeVillier 2021-09-23 12:13:40 -05:00 committed by tlaurion
parent 463ec15522
commit a86debb257

View File

@ -5,11 +5,12 @@ BOARD_NAME=${CONFIG_BOARD_NAME:-${CONFIG_BOARD}}
MAIN_MENU_TITLE="${BOARD_NAME} | Heads Boot Menu"
export BG_COLOR_WARNING="${CONFIG_WARNING_BG_COLOR:-"--background-gradient 0 0 0 150 125 0"}"
export BG_COLOR_ERROR="${CONFIG_ERROR_BG_COLOR:-"--background-gradient 0 0 0 150 0 0"}"
export MAIN_MENU_BG_COLOR=""
. /etc/functions
. /tmp/config
first_pass=true
last_half=X
mount_boot()
{
@ -512,21 +513,14 @@ else
HOTPKEY_BRANDING="HOTP USB Security Dongle"
fi
last_half=X
# detect whether any GPG keys exist in the keyring, if not, initialize that first
check_gpg_key && update_totp && update_hotp
if [[ "$HOTP" = "Success" && $CONFIG_AUTO_BOOT_TIMEOUT ]]; then
prompt_auto_default_boot
fi
while true; do
MAIN_MENU_OPTIONS=""
MAIN_MENU_BG_COLOR=""
# detect whether any GPG keys exist in the keyring, if not, initialize that first
check_gpg_key
update_totp
update_hotp
if [[ "$HOTP" = "Success" && $CONFIG_AUTO_BOOT_TIMEOUT && $first_pass = true ]]; then
prompt_auto_default_boot
fi
show_main_menu
done