From a86debb2572c591e50241cda47592c91e7fe2a34 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Thu, 23 Sep 2021 12:13:40 -0500 Subject: [PATCH] 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 --- initrd/bin/gui-init | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/initrd/bin/gui-init b/initrd/bin/gui-init index ddb28c37..1a6e8b2c 100755 --- a/initrd/bin/gui-init +++ b/initrd/bin/gui-init @@ -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