Refactor settings menu and exit handling in build.func

Simplifies the menu item logic for settings and app defaults, updates the whiptail menu to use custom button labels, and replaces direct exit calls with the exit_script function for consistent script termination.
This commit is contained in:
CanbiZ 2025-09-17 16:02:42 +02:00
parent 92b1328f89
commit c7456236a0

View File

@ -1551,26 +1551,22 @@ install_script() {
"4" "My Defaults" "4" "My Defaults"
) )
local next=5
if [ -f "$(get_app_defaults_path)" ]; then if [ -f "$(get_app_defaults_path)" ]; then
menu_items+=("$next" "App Defaults for ${APP}") menu_items+=("5" "App Defaults for ${APP}")
next=$((next + 1)) menu_items+=("6" "Settings")
else
menu_items+=("5" "Settings")
fi fi
menu_items+=(
"$next" "Settings"
"$((next + 1))" "Exit"
)
TMP_CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \ TMP_CHOICE=$(whiptail --backtitle "[dev] Proxmox VE Helper Scripts" \
--title "SETTINGS" \ --title "SETTINGS" \
--ok-button "OK" --cancel-button "Exit Script" \
--menu "Choose an option:" 20 60 9 \ --menu "Choose an option:" 20 60 9 \
"${menu_items[@]}" \ "${menu_items[@]}" \
--default-item "1" 3>&1 1>&2 2>&3) || true --default-item "1" 3>&1 1>&2 2>&3) || true
if [ -z "$TMP_CHOICE" ]; then if [ -z "$TMP_CHOICE" ]; then
echo -e "\n${CROSS}${RD}Menu canceled. Exiting script.${CL}\n" exit_script
exit 0
fi fi
CHOICE="$TMP_CHOICE" CHOICE="$TMP_CHOICE"
fi fi
@ -1629,10 +1625,6 @@ install_script() {
settings_menu settings_menu
exit 0 exit 0
;; ;;
7)
echo -e "\n${CROSS}${RD}Script terminated.${CL}\n"
exit 0
;;
*) *)
echo -e "${CROSS}${RD}Invalid option, please try again.${CL}" echo -e "${CROSS}${RD}Invalid option, please try again.${CL}"
;; ;;