mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-25 08:56:21 +00:00
Update menu
This commit is contained in:
80
menu
80
menu
@@ -84,68 +84,56 @@ check_updates_stable() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Beta update check (develop branch) ────────────────────
|
||||
# ── Beta-mode update check (main + develop) ───────────────
|
||||
# When the beta program is active, check BOTH channels:
|
||||
# 1. main → prompt if a newer stable is available
|
||||
# 2. develop → prompt if a newer beta build is available
|
||||
# Stable check runs first. Declining it falls through to the beta check.
|
||||
check_updates_beta() {
|
||||
local BETA_VERSION_URL="$REPO_DEVELOP/beta_version.txt"
|
||||
local STABLE_VERSION_URL="$REPO_MAIN/version.txt"
|
||||
local INSTALL_BETA_URL="$REPO_DEVELOP/install_proxmenux_beta.sh"
|
||||
local INSTALL_STABLE_URL="$REPO_MAIN/install_proxmenux.sh"
|
||||
local INSTALL_SCRIPT="$BASE_DIR/install_proxmenux_beta.sh"
|
||||
# ── 1. Stable release on main ──
|
||||
if [[ -f "$LOCAL_VERSION_FILE" ]]; then
|
||||
local REMOTE_STABLE LOCAL_STABLE
|
||||
REMOTE_STABLE="$(curl -fsSL "$REPO_MAIN/version.txt" 2>/dev/null | head -n 1)"
|
||||
LOCAL_STABLE="$(head -n 1 "$LOCAL_VERSION_FILE" 2>/dev/null)"
|
||||
|
||||
# ── 1. Check if a stable release has superseded the beta ──
|
||||
# If main's version.txt exists and is newer than local beta_version.txt,
|
||||
# the beta cycle is over and we invite the user to switch to stable.
|
||||
local STABLE_VERSION BETA_LOCAL_VERSION
|
||||
STABLE_VERSION="$(curl -fsSL "$STABLE_VERSION_URL" 2>/dev/null | head -n 1)"
|
||||
BETA_LOCAL_VERSION="$(head -n 1 "$BETA_VERSION_FILE" 2>/dev/null)"
|
||||
if [[ -n "$REMOTE_STABLE" && -n "$LOCAL_STABLE" && "$LOCAL_STABLE" != "$REMOTE_STABLE" ]] && \
|
||||
[[ "$(printf '%s\n%s\n' "$LOCAL_STABLE" "$REMOTE_STABLE" | sort -V | tail -1)" = "$REMOTE_STABLE" ]]; then
|
||||
|
||||
if [[ -n "$STABLE_VERSION" && -n "$BETA_LOCAL_VERSION" ]]; then
|
||||
# Simple string comparison is enough if versions follow semver x.y.z
|
||||
if [[ "$STABLE_VERSION" != "$BETA_LOCAL_VERSION" ]] && \
|
||||
printf '%s\n' "$BETA_LOCAL_VERSION" "$STABLE_VERSION" | sort -V | tail -1 | grep -qx "$STABLE_VERSION"; then
|
||||
if whiptail --title "$(translate 'Update Available')" \
|
||||
--yesno "$(translate 'New version available') ($REMOTE_STABLE)\n\n$(translate 'Do you want to update now?')" \
|
||||
10 60 --defaultno; then
|
||||
|
||||
# Stable is newer — offer migration out of beta
|
||||
if whiptail --title "🎉 Stable Release Available" \
|
||||
--yesno "A stable release of ProxMenux is now available!\n\nStable version : $STABLE_VERSION\nYour beta : $BETA_LOCAL_VERSION\n\nThe beta program for this cycle is complete.\nWould you like to switch to the stable release now?\n\n(Choosing 'No' keeps you on the beta for now.)" \
|
||||
16 68; then
|
||||
msg_warn "$(translate 'Starting ProxMenux update...')"
|
||||
|
||||
msg_warn "Switching to stable release $STABLE_VERSION ..."
|
||||
|
||||
local tmp_installer="/tmp/install_proxmenux_stable_$$.sh"
|
||||
if curl -fsSL "$INSTALL_STABLE_URL" -o "$tmp_installer"; then
|
||||
chmod +x "$tmp_installer"
|
||||
bash "$tmp_installer"
|
||||
rm -f "$tmp_installer"
|
||||
else
|
||||
msg_error "Could not download the stable installer. Try manually:"
|
||||
echo
|
||||
echo " bash -c \"\$(wget -qLO - $INSTALL_STABLE_URL)\""
|
||||
echo
|
||||
local INSTALL_STABLE_SCRIPT="$BASE_DIR/install_proxmenux.sh"
|
||||
if curl -fsSL "$REPO_MAIN/install_proxmenux.sh" -o "$INSTALL_STABLE_SCRIPT"; then
|
||||
chmod +x "$INSTALL_STABLE_SCRIPT"
|
||||
bash "$INSTALL_STABLE_SCRIPT" --update
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
# User chose to stay on beta — continue normally
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 2. Check for a newer beta build on develop ─────────────
|
||||
# ── 2. Beta build on develop ──
|
||||
[[ ! -f "$BETA_VERSION_FILE" ]] && return 0
|
||||
|
||||
local REMOTE_BETA_VERSION
|
||||
REMOTE_BETA_VERSION="$(curl -fsSL "$BETA_VERSION_URL" 2>/dev/null | head -n 1)"
|
||||
[[ -z "$REMOTE_BETA_VERSION" ]] && return 0
|
||||
[[ "$BETA_LOCAL_VERSION" = "$REMOTE_BETA_VERSION" ]] && return 0
|
||||
local REMOTE_BETA LOCAL_BETA
|
||||
REMOTE_BETA="$(curl -fsSL "$REPO_DEVELOP/beta_version.txt" 2>/dev/null | head -n 1)"
|
||||
LOCAL_BETA="$(head -n 1 "$BETA_VERSION_FILE" 2>/dev/null)"
|
||||
[[ -z "$REMOTE_BETA" || -z "$LOCAL_BETA" || "$LOCAL_BETA" = "$REMOTE_BETA" ]] && return 0
|
||||
[[ "$(printf '%s\n%s\n' "$LOCAL_BETA" "$REMOTE_BETA" | sort -V | tail -1)" = "$REMOTE_BETA" ]] || return 0
|
||||
|
||||
if whiptail --title "Beta Update Available" \
|
||||
--yesno "A new beta build is available!\n\nInstalled beta : $BETA_LOCAL_VERSION\nNew beta build : $REMOTE_BETA_VERSION\n\nThis is a pre-release build from the develop branch.\nDo you want to update now?" \
|
||||
13 64 --defaultno; then
|
||||
--yesno "A new beta build is available!\n\nInstalled beta : $LOCAL_BETA\nNew beta build : $REMOTE_BETA\n\nDo you want to update now?" \
|
||||
12 64 --defaultno; then
|
||||
|
||||
msg_warn "Updating to beta build $REMOTE_BETA_VERSION ..."
|
||||
msg_warn "Updating to beta build $REMOTE_BETA ..."
|
||||
|
||||
if curl -fsSL "$INSTALL_BETA_URL" -o "$INSTALL_SCRIPT"; then
|
||||
chmod +x "$INSTALL_SCRIPT"
|
||||
bash "$INSTALL_SCRIPT" --update
|
||||
local INSTALL_BETA_SCRIPT="$BASE_DIR/install_proxmenux_beta.sh"
|
||||
if curl -fsSL "$REPO_DEVELOP/install_proxmenux_beta.sh" -o "$INSTALL_BETA_SCRIPT"; then
|
||||
chmod +x "$INSTALL_BETA_SCRIPT"
|
||||
bash "$INSTALL_BETA_SCRIPT" --update
|
||||
else
|
||||
msg_error "Could not download the beta installer from the develop branch."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user