Update menu

This commit is contained in:
MacRimi
2025-11-14 21:30:58 +01:00
parent bd0ea1379f
commit acdb0d2838

28
menu
View File

@@ -29,7 +29,6 @@
# for managing Proxmox VE using ProxMenux. # for managing Proxmox VE using ProxMenux.
# ========================================================== # ==========================================================
# Configuration ============================================ # Configuration ============================================
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main" REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
BASE_DIR="/usr/local/share/proxmenux" BASE_DIR="/usr/local/share/proxmenux"
@@ -47,9 +46,19 @@ fi
check_updates() { check_updates() {
local INSTALL_SCRIPT="$BASE_DIR/install_proxmenux.sh" local INSTALL_SCRIPT="$BASE_DIR/install_proxmenux.sh"
local VERSION_URL="$REPO_URL/version.txt"
local INSTALL_URL="$REPO_URL/install_proxmenux.sh"
local CURL_OPTS=(
-fsSL
--connect-timeout 3
--max-time 5
)
local REMOTE_VERSION local REMOTE_VERSION
REMOTE_VERSION=$(curl -fsSL "$REPO_URL/version.txt" | head -n 1) REMOTE_VERSION="$(curl "${CURL_OPTS[@]}" "$VERSION_URL" 2>/dev/null | head -n 1 || true)"
if [ -z "$REMOTE_VERSION" ]; then if [ -z "$REMOTE_VERSION" ]; then
@@ -57,8 +66,10 @@ check_updates() {
fi fi
local LOCAL_VERSION local LOCAL_VERSION=""
LOCAL_VERSION=$(head -n 1 "$LOCAL_VERSION_FILE") 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
@@ -67,25 +78,26 @@ check_updates() {
if whiptail --title "$(translate "Update Available")" \ if whiptail --title "$(translate "Update Available")" \
--yesno "$(translate "New version available") ($REMOTE_VERSION)\n\n$(translate "Do you want to update now?")" \ --yesno "$(translate "New version available") ($REMOTE_VERSION)\n\n$(translate "Do you want to update now?")" \
10 60 --defaultno; then 10 60 --defaultno; then
msg_warn "$(translate "Starting ProxMenux update...")" msg_warn "$(translate "Starting ProxMenux update...")"
if wget -qO "$INSTALL_SCRIPT" "$REPO_URL/install_proxmenux.sh"; then
if curl "${CURL_OPTS[@]}" "$INSTALL_URL" -o "$INSTALL_SCRIPT"; then
chmod +x "$INSTALL_SCRIPT" chmod +x "$INSTALL_SCRIPT"
source "$INSTALL_SCRIPT" source "$INSTALL_SCRIPT"
else
msg_warn "$(translate "Unable to download the installer. Please try again later.")"
fi fi
else else
msg_warn "$(translate "Update postponed. You can update later from the menu.")" msg_warn "$(translate "Update postponed. You can update later from the menu.")"
fi fi
} }
main_menu() { main_menu() {
exec bash "$LOCAL_SCRIPTS/menus/main_menu.sh" exec bash "$LOCAL_SCRIPTS/menus/main_menu.sh"
} }
load_language load_language
initialize_cache initialize_cache
check_updates check_updates