diff --git a/menu b/menu index 43cad9d..4c054fb 100644 --- a/menu +++ b/menu @@ -12,7 +12,6 @@ # Description: # This script serves as the main entry point for ProxMenux, # a menu-driven tool designed for Proxmox VE management. -# # - Displays the ProxMenux logo on startup. # - Loads necessary configurations and language settings. # - Checks for available updates and installs them if confirmed. @@ -32,17 +31,20 @@ # Configuration ============================================ REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main" BASE_DIR="/usr/local/share/proxmenux" -LOCAL_SCRIPTS="$BASE_DIR/scripts" +LOCAL_SCRIPTS="$BASE_DIR/scripts" CONFIG_FILE="$BASE_DIR/config.json" CACHE_FILE="$BASE_DIR/cache.json" UTILS_FILE="$BASE_DIR/utils.sh" LOCAL_VERSION_FILE="$BASE_DIR/version.txt" VENV_PATH="/opt/googletrans-env" + if [[ -f "$UTILS_FILE" ]]; then source "$UTILS_FILE" fi -#: "${LOCAL_SCRIPTS:=/usr/local/share/proxmenux/scripts}" + + +: "${LOCAL_SCRIPTS:=/usr/local/share/proxmenux/scripts}" # ========================================================= @@ -60,33 +62,46 @@ check_updates() { local REMOTE_VERSION REMOTE_VERSION="$(curl "${CURL_OPTS[@]}" "$VERSION_URL" 2>/dev/null | head -n 1 || true)" - if [ -z "$REMOTE_VERSION" ]; then + + if [[ -z "$REMOTE_VERSION" ]]; then return 0 fi local LOCAL_VERSION="" - if [ -f "$LOCAL_VERSION_FILE" ]; then + if [[ -f "$LOCAL_VERSION_FILE" ]]; then LOCAL_VERSION="$(head -n 1 "$LOCAL_VERSION_FILE" 2>/dev/null || true)" fi - [ "$LOCAL_VERSION" = "$REMOTE_VERSION" ] && return 0 + [[ "$LOCAL_VERSION" = "$REMOTE_VERSION" ]] && return 0 - if whiptail --title "$(translate 'Update Available')" \ - --yesno "$(translate 'New version available') ($REMOTE_VERSION)\n\n$(translate 'Do you want to update now?')" \ + + + local TITLE MESSAGE + TITLE="$(translate 'Update Available')" + MESSAGE="$(translate 'New version available') ($REMOTE_VERSION)\n\n$(translate 'Do you want to update now?')" + + if whiptail --title "$TITLE" \ + --yesno "$MESSAGE" \ 10 60 --defaultno; then + msg_warn "$(translate 'Starting ProxMenux update...')" if curl "${CURL_OPTS[@]}" "$INSTALL_URL" -o "$INSTALL_SCRIPT"; then chmod +x "$INSTALL_SCRIPT" source "$INSTALL_SCRIPT" - + else + msg_warn "$(translate 'Unable to download the installer. Please try again later.')" fi + else + msg_warn "$(translate 'Update postponed. You can update later from the menu.')" fi } main_menu() { - exec bash "$LOCAL_SCRIPTS/menus/main_menu.sh" + local MAIN_MENU="$LOCAL_SCRIPTS/menus/main_menu.sh" + + exec bash "$MAIN_MENU" } load_language