Remove safe self-update and beta check functions

This commit is contained in:
MacRimi
2026-04-18 00:59:54 +02:00
committed by GitHub
parent 800a18ac60
commit 46edd4e3e4

123
menu
View File

@@ -55,57 +55,6 @@ check_updates() {
fi
}
# ── Safe self-update ──────────────────────────────────────
# Validates the downloaded installer and rolls back /usr/local/bin/menu
# if the post-install launcher fails to parse. Why: a corrupted download
# or CRLF contamination has already left users with an unusable launcher;
# without a rollback the only recovery is curl-reinstall by hand.
run_installer_safely() {
local installer_url="$1"
local installer_dest="$2"
local launcher="/usr/local/bin/menu"
local tmp_installer="/tmp/proxmenux_installer_$$.sh"
local menu_backup="/tmp/proxmenux_menu_backup_$$"
if ! curl -fsSL "$installer_url" -o "$tmp_installer"; then
msg_error "Failed to download installer from $installer_url"
return 1
fi
sed -i 's/\r$//' "$tmp_installer" 2>/dev/null || true
if ! bash -n "$tmp_installer" 2>/dev/null; then
msg_error "Downloaded installer has invalid syntax. Update aborted."
rm -f "$tmp_installer"
return 1
fi
[[ -f "$launcher" ]] && cp -f "$launcher" "$menu_backup"
chmod +x "$tmp_installer"
if [[ -n "$installer_dest" ]]; then
cp -f "$tmp_installer" "$installer_dest"
chmod +x "$installer_dest"
bash "$installer_dest" --update
else
bash "$tmp_installer"
fi
local rc=$?
if [[ -f "$launcher" ]] && ! bash -n "$launcher" 2>/dev/null; then
msg_error "New launcher is broken. Restoring previous version."
if [[ -f "$menu_backup" ]]; then
cp -f "$menu_backup" "$launcher"
sed -i 's/\r$//' "$launcher" 2>/dev/null || true
chmod +x "$launcher"
fi
rc=1
fi
rm -f "$tmp_installer" "$menu_backup"
return $rc
}
# ── Stable update check (main branch) ─────────────────────
check_updates_stable() {
local VERSION_URL="$REPO_MAIN/version.txt"
@@ -122,78 +71,6 @@ check_updates_stable() {
[[ -z "$LOCAL_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?')" \
10 60 --defaultno; then
msg_warn "$(translate 'Starting ProxMenux update...')"
run_installer_safely "$INSTALL_URL" "$INSTALL_SCRIPT"
fi
}
# ── Beta update check (develop branch) ────────────────────
# Beta users track BOTH channels independently: a new stable on main is
# still relevant to them (ends the beta cycle), and a new beta on develop
# is their normal update path. We prompt for each one in turn — declining
# stable doesn't skip the beta prompt.
check_updates_beta() {
local STABLE_VERSION_URL="$REPO_MAIN/version.txt"
local BETA_VERSION_URL="$REPO_DEVELOP/beta_version.txt"
local INSTALL_STABLE_URL="$REPO_MAIN/install_proxmenux.sh"
local INSTALL_BETA_URL="$REPO_DEVELOP/install_proxmenux_beta.sh"
local INSTALL_STABLE_SCRIPT="$BASE_DIR/install_proxmenux.sh"
local INSTALL_BETA_SCRIPT="$BASE_DIR/install_proxmenux_beta.sh"
local REMOTE_STABLE LOCAL_STABLE REMOTE_BETA LOCAL_BETA
REMOTE_STABLE="$(curl -fsSL "$STABLE_VERSION_URL" 2>/dev/null | head -n 1 | tr -d '[:space:]')"
LOCAL_STABLE="$(head -n 1 "$LOCAL_VERSION_FILE" 2>/dev/null | tr -d '[:space:]')"
REMOTE_BETA="$(curl -fsSL "$BETA_VERSION_URL" 2>/dev/null | head -n 1 | tr -d '[:space:]')"
LOCAL_BETA="$(head -n 1 "$BETA_VERSION_FILE" 2>/dev/null | tr -d '[:space:]')"
# ── 1. Stable release on main ──
if [[ -n "$LOCAL_STABLE" && -n "$REMOTE_STABLE" && "$LOCAL_STABLE" != "$REMOTE_STABLE" ]] && \
[[ "$(printf '%s\n%s\n' "$LOCAL_STABLE" "$REMOTE_STABLE" | sort -V | tail -1)" = "$REMOTE_STABLE" ]]; then
if whiptail --title "🎉 Stable Release Available" \
--yesno "A new ProxMenux stable release is available on main.\n\nInstalled stable : $LOCAL_STABLE\nNew stable : $REMOTE_STABLE\nYour beta : ${LOCAL_BETA:-n/a}\n\nInstall the stable release now?\n\n(Choosing 'No' keeps your beta — any beta update is offered next.)" \
15 70 --defaultno; then
msg_warn "Installing stable release $REMOTE_STABLE ..."
run_installer_safely "$INSTALL_STABLE_URL" "$INSTALL_STABLE_SCRIPT"
return 0
fi
fi
# ── 2. Beta build on develop ──
if [[ -n "$LOCAL_BETA" && -n "$REMOTE_BETA" && "$LOCAL_BETA" != "$REMOTE_BETA" ]] && \
[[ "$(printf '%s\n%s\n' "$LOCAL_BETA" "$REMOTE_BETA" | sort -V | tail -1)" = "$REMOTE_BETA" ]]; then
if whiptail --title "Beta Update Available" \
--yesno "A new beta build is available on the develop branch.\n\nInstalled beta : $LOCAL_BETA\nNew beta build : $REMOTE_BETA\n\nUpdate the beta now?" \
13 68 --defaultno; then
msg_warn "Updating to beta build $REMOTE_BETA ..."
run_installer_safely "$INSTALL_BETA_URL" "$INSTALL_BETA_SCRIPT"
fi
fi
}
# ── Main ───────────────────────────────────────────────────
main_menu() {
local MAIN_MENU="$LOCAL_SCRIPTS/menus/main_menu.sh"
exec bash "$MAIN_MENU"
}
load_language
initialize_cache
check_updates
main_menu
local REMOTE_VERSION LOCAL_VERSION
REMOTE_VERSION="$(curl -fsSL "$VERSION_URL" 2>/dev/null | head -n 1)"
[[ -z "$REMOTE_VERSION" ]] && return 0
LOCAL_VERSION="$(head -n 1 "$LOCAL_VERSION_FILE" 2>/dev/null)"
[[ -z "$LOCAL_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?')" \
10 60 --defaultno; then