From 0b3624dbd5d44852142893fa05e669f19d264505 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Thu, 26 Mar 2026 00:32:52 +0100 Subject: [PATCH] Update notification service --- AppImage/scripts/health_persistence.py | 2 +- AppImage/scripts/notification_templates.py | 2 +- install_proxmenux_beta.sh | 1081 ++++++++++---------- 3 files changed, 526 insertions(+), 559 deletions(-) diff --git a/AppImage/scripts/health_persistence.py b/AppImage/scripts/health_persistence.py index 65a0aee3..70a81170 100644 --- a/AppImage/scripts/health_persistence.py +++ b/AppImage/scripts/health_persistence.py @@ -1093,7 +1093,7 @@ class HealthPersistence: conn.commit() conn.close() - # ─── System Capabilities Cache ───────────────────��─────────── + # ─── System Capabilities Cache ─────────────────────────────── def get_capability(self, cap_key: str) -> Optional[str]: """ diff --git a/AppImage/scripts/notification_templates.py b/AppImage/scripts/notification_templates.py index d7ff43a2..897556f0 100644 --- a/AppImage/scripts/notification_templates.py +++ b/AppImage/scripts/notification_templates.py @@ -314,7 +314,7 @@ def _format_vzdump_body(parsed: Dict[str, Any], is_success: bool) -> str: return '\n'.join(parts) -# ──�� Severity Icons ────────────────────────────────────────────── +# ─── Severity Icons ────────────────────────────────────────────── SEVERITY_ICONS = { 'CRITICAL': '\U0001F534', diff --git a/install_proxmenux_beta.sh b/install_proxmenux_beta.sh index 129ca0e7..271e5270 100644 --- a/install_proxmenux_beta.sh +++ b/install_proxmenux_beta.sh @@ -1,271 +1,271 @@ -#!/bin/bash - -# ========================================================== -# ProxMenux Monitor - Beta Program Installer -# ========================================================== -# Author : MacRimi -# Subproject : ProxMenux Monitor Beta -# Copyright : (c) 2024-2025 MacRimi -# License : GPL-3.0 (https://github.com/MacRimi/ProxMenux/blob/main/LICENSE) -# Version : Beta -# Branch : develop -# ========================================================== -# Description: -# This script installs the BETA version of ProxMenux Monitor -# from the develop branch on GitHub. -# -# Beta testers are expected to: -# - Report bugs and unexpected behavior via GitHub Issues -# - Provide feedback to help improve the final release -# -# Installs: -# • dialog, curl, jq, git (system dependencies) -# • ProxMenux core files (/usr/local/share/proxmenux) -# • ProxMenux Monitor AppImage (Web dashboard on port 8008) -# • Systemd service (auto-start on boot) -# -# Notes: -# - Clones from the 'develop' branch -# - Beta version file: beta_version.txt in the repository -# - Transition to stable: re-run the official installer -# ========================================================== - -# ── Configuration ────────────────────────────────────────── -INSTALL_DIR="/usr/local/bin" -BASE_DIR="/usr/local/share/proxmenux" -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" -BETA_VERSION_FILE="$BASE_DIR/beta_version.txt" -MENU_SCRIPT="menu" - -MONITOR_INSTALL_DIR="$BASE_DIR" -MONITOR_SERVICE_FILE="/etc/systemd/system/proxmenux-monitor.service" -MONITOR_PORT=8008 - -REPO_URL="https://github.com/MacRimi/ProxMenux.git" -REPO_BRANCH="develop" -TEMP_DIR="/tmp/proxmenux-beta-install-$$" - -# ── Colors ───────────────────────────────────────────────── -RESET="\033[0m" -BOLD="\033[1m" -WHITE="\033[38;5;15m" -NEON_PURPLE_BLUE="\033[38;5;99m" -DARK_GRAY="\033[38;5;244m" -ORANGE="\033[38;5;208m" -GN="\033[1;92m" -YW="\033[33m" -YWB="\033[1;33m" -RD="\033[01;31m" -BL="\033[36m" -CL="\033[m" -BGN="\e[1;32m" -TAB=" " -BFR="\\r\\033[K" -HOLD="-" -BOR=" | " -CM="${GN}✓ ${CL}" - -SPINNER_PID="" - -# ── Spinner ──────────────────────────────────────────────── -spinner() { - local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') - local spin_i=0 - printf "\e[?25l" - while true; do - printf "\r ${YW}%s${CL}" "${frames[spin_i]}" - spin_i=$(( (spin_i + 1) % ${#frames[@]} )) - sleep 0.1 - done -} - -type_text() { - local text="$1" - local delay=0.04 - for ((i=0; i<${#text}; i++)); do - echo -n "${text:$i:1}" - sleep $delay - done - echo -} - -msg_info() { - local msg="$1" - echo -ne "${TAB}${YW}${HOLD}${msg}" - spinner & - SPINNER_PID=$! -} - -msg_ok() { - if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then - kill $SPINNER_PID > /dev/null 2>&1 - SPINNER_PID="" - fi - printf "\e[?25h" - echo -e "${BFR}${TAB}${CM}${GN}${1}${CL}" -} - -msg_error() { - if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then - kill $SPINNER_PID > /dev/null 2>&1 - SPINNER_PID="" - fi - printf "\e[?25h" - echo -e "${BFR}${TAB}${RD}[ERROR] ${1}${CL}" -} - -msg_warn() { - if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then - kill $SPINNER_PID > /dev/null 2>&1 - SPINNER_PID="" - fi - printf "\e[?25h" - echo -e "${BFR}${TAB}${YWB}${1}${CL}" -} - -msg_title() { - echo -e "\n" - echo -e "${TAB}${BOLD}${HOLD}${BOR}${1}${BOR}${HOLD}${CL}" - echo -e "\n" -} - -show_progress() { - echo -e "\n${BOLD}${BL}${TAB}Installing ProxMenux Beta: Step ${1} of ${2}${CL}" - echo - echo -e "${TAB}${BOLD}${YW}${HOLD}${3}${CL}" -} - -# ── Cleanup ──────────────────────────────────────────────── -cleanup() { - if [ -d "$TEMP_DIR" ]; then - rm -rf "$TEMP_DIR" - fi -} -trap cleanup EXIT - -# ── Logo ─────────────────────────────────────────────────── -show_proxmenux_logo() { - clear - - if [[ -z "$SSH_TTY" && -z "$(who am i | awk '{print $NF}' | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}')" ]]; then - -LOGO=$(cat << "EOF" -\e[0m\e[38;2;61;61;61m▆\e[38;2;60;60;60m▄\e[38;2;54;54;54m▂\e[0m \e[38;2;0;0;0m \e[0m \e[38;2;54;54;54m▂\e[38;2;60;60;60m▄\e[38;2;61;61;61m▆\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[38;2;61;61;61;48;2;37;37;37m▇\e[0m\e[38;2;60;60;60m▅\e[38;2;56;56;56m▃\e[38;2;37;37;37m▁ \e[38;2;36;36;36m▁\e[38;2;56;56;56m▃\e[38;2;60;60;60m▅\e[38;2;61;61;61;48;2;37;37;37m▇\e[48;2;62;62;62m \e[0m\e[7m\e[38;2;60;60;60m▁\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[7m\e[38;2;61;61;61m▂\e[0m\e[38;2;62;62;62;48;2;61;61;61m┈\e[48;2;62;62;62m \e[48;2;61;61;61m┈\e[0m\e[38;2;60;60;60m▆\e[38;2;57;57;57m▄\e[38;2;48;48;48m▂\e[0m \e[38;2;47;47;47m▂\e[38;2;57;57;57m▄\e[38;2;60;60;60m▆\e[38;2;62;62;62;48;2;61;61;61m┈\e[48;2;62;62;62m \e[48;2;61;61;61m┈\e[0m\e[7m\e[38;2;60;60;60m▂\e[38;2;57;57;57m▄\e[38;2;47;47;47m▆\e[0m \e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[7m\e[38;2;39;39;39m▇\e[38;2;57;57;57m▅\e[38;2;60;60;60m▃\e[0m\e[38;2;40;40;40;48;2;61;61;61m▁\e[48;2;62;62;62m \e[38;2;54;54;54;48;2;61;61;61m┊\e[48;2;62;62;62m \e[38;2;39;39;39;48;2;61;61;61m▁\e[0m\e[7m\e[38;2;60;60;60m▃\e[38;2;57;57;57m▅\e[38;2;38;38;38m▇\e[0m \e[38;2;193;60;2m▃\e[38;2;217;67;2m▅\e[38;2;225;70;2m▇\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[0m \e[38;2;203;63;2m▄\e[38;2;147;45;1m▂\e[0m \e[7m\e[38;2;55;55;55m▆\e[38;2;60;60;60m▄\e[38;2;61;61;61m▂\e[38;2;60;60;60m▄\e[38;2;55;55;55m▆\e[0m \e[38;2;144;44;1m▂\e[38;2;202;62;2m▄\e[38;2;219;68;2m▆\e[38;2;231;72;3;48;2;226;70;2m┈\e[48;2;231;72;3m \e[48;2;225;70;2m▉\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[7m\e[38;2;121;37;1m▉\e[0m\e[38;2;0;0;0;48;2;231;72;3m \e[0m\e[38;2;221;68;2m▇\e[38;2;208;64;2m▅\e[38;2;212;66;2m▂\e[38;2;123;37;0m▁\e[38;2;211;65;2m▂\e[38;2;207;64;2m▅\e[38;2;220;68;2m▇\e[48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m┈\e[0m\e[7m\e[38;2;221;68;2m▂\e[0m\e[38;2;44;13;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[0m \e[7m\e[38;2;190;59;2m▅\e[38;2;216;67;2m▃\e[38;2;225;70;2m▁\e[0m\e[38;2;95;29;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;230;71;2m┈\e[48;2;231;72;3m \e[0m\e[7m\e[38;2;225;70;2m▁\e[38;2;216;67;2m▃\e[38;2;191;59;2m▅\e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏ \e[0m \e[7m\e[38;2;172;53;1m▆\e[38;2;213;66;2m▄\e[38;2;219;68;2m▂\e[38;2;213;66;2m▄\e[38;2;174;54;2m▆\e[0m \e[38;2;0;0;0m \e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m -\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏ \e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m -\e[7m\e[38;2;52;52;52m▆\e[38;2;59;59;59m▄\e[38;2;61;61;61m▂\e[0m\e[38;2;31;31;31m▏ \e[0m \e[7m\e[38;2;228;71;2m▂\e[38;2;221;69;2m▄\e[38;2;196;60;2m▆\e[0m -EOF -) - TEXT=( - "" - "" - "${BOLD}ProxMenux${RESET}" - "" - "${BOLD}${NEON_PURPLE_BLUE}An Interactive Menu for${RESET}" - "${BOLD}${NEON_PURPLE_BLUE}Proxmox VE management${RESET}" - "" - "${BOLD}${YW} ★ BETA PROGRAM ★${RESET}" - "" - "" - ) - mapfile -t logo_lines <<< "$LOGO" - for i in {0..9}; do - echo -e "${TAB}${logo_lines[i]} ${WHITE}│${RESET} ${TEXT[i]}" - done - echo -e - - else - - TEXT=( - "" "" "" "" - "${BOLD}ProxMenux${RESET}" - "" - "${BOLD}${NEON_PURPLE_BLUE}An Interactive Menu for${RESET}" - "${BOLD}${NEON_PURPLE_BLUE}Proxmox VE management${RESET}" - "" - "${BOLD}${YW} ★ BETA PROGRAM ★${RESET}" - "" "" "" - ) - LOGO=( - "${DARK_GRAY}░░░░ ░░░░${RESET}" - "${DARK_GRAY}░░░░░░░ ░░░░░░ ${RESET}" - "${DARK_GRAY}░░░░░░░░░░░ ░░░░░░░ ${RESET}" - "${DARK_GRAY}░░░░ ░░░░░░ ░░░░░░ ${ORANGE}░░${RESET}" - "${DARK_GRAY}░░░░ ░░░░░░░ ${ORANGE}░░▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ░░░ ${ORANGE}░▒▒▒▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒░ ░▒▒▒▒▒▒▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}░▒▒▒▒▒ ▒▒▒▒▒░░ ▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}░░▒▒▒▒▒▒▒░░ ▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}░░░ ▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒▒${RESET}" - "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒░${RESET}" - "${DARK_GRAY} ░░ ${ORANGE}░░ ${RESET}" - ) - for i in {0..12}; do - echo -e "${TAB}${LOGO[i]} │${RESET} ${TEXT[i]}" - done - echo -e - fi -} - -# ── Beta welcome message ─────────────────────────────────── -show_beta_welcome() { - local width=62 - local line - line=$(printf '─%.0s' $(seq 1 $width)) - - echo -e "${TAB}${BOLD}${YW}┌${line}┐${CL}" - echo -e "${TAB}${BOLD}${YW}│${CL}${BOLD} Welcome to the ProxMenux Monitor Beta Program ${YW}│${CL}" - echo -e "${TAB}${BOLD}${YW}└${line}┘${CL}" - echo - echo -e "${TAB}${WHITE}You are about to install a ${BOLD}pre-release (beta)${RESET}${WHITE} version of${CL}" - echo -e "${TAB}${WHITE}ProxMenux Monitor, built from the ${BOLD}develop${RESET}${WHITE} branch.${CL}" - echo - echo -e "${TAB}${BOLD}${GN}What this means for you:${CL}" - echo -e "${TAB} ${GN}•${CL} You'll get the latest features before the official release." - echo -e "${TAB} ${GN}•${CL} Some things may not work perfectly — that's expected." - echo -e "${TAB} ${GN}•${CL} Your feedback is what makes the final version better." - echo - echo -e "${TAB}${BOLD}${YW}How to report issues:${CL}" - echo -e "${TAB} ${YW}→${CL} Open a GitHub Issue at:" - echo -e "${TAB} ${BL}https://github.com/MacRimi/ProxMenux/issues${CL}" - echo -e "${TAB} ${YW}→${CL} Describe what happened, what you expected, and any" - echo -e "${TAB} error messages you saw. Logs help a lot:" - echo -e "${TAB} ${DARK_GRAY}journalctl -u proxmenux-monitor -n 50${CL}" - echo - echo -e "${TAB}${BOLD}${NEON_PURPLE_BLUE}Thank you for being part of the beta program!${CL}" - echo -e "${TAB}${DARK_GRAY}Your help is essential to deliver a stable and polished release.${CL}" - echo - echo -e "${TAB}${BOLD}${YW}┌${line}┐${CL}" - echo -e "${TAB}${BOLD}${YW}│${CL} ${YW}│${CL}" - echo -e "${TAB}${BOLD}${YW}│${CL} Press ${BOLD}${GN}[Enter]${CL} to continue with the beta installation, ${YW}│${CL}" - echo -e "${TAB}${BOLD}${YW}│${CL} or ${BOLD}${RD}[Ctrl+C]${CL} to cancel and exit. ${YW}│${CL}" - echo -e "${TAB}${BOLD}${YW}│${CL} ${YW}│${CL}" - echo -e "${TAB}${BOLD}${YW}└${line}┘${CL}" - echo - - read -r -p "" - echo -} - -# ── Helpers ──────────────────────────────────────────────── -get_server_ip() { - local ip - ip=$(ip route get 1.1.1.1 2>/dev/null | grep -oP 'src \K\S+') - [ -z "$ip" ] && ip=$(hostname -I | awk '{print $1}') - [ -z "$ip" ] && ip="localhost" - echo "$ip" -} - +#!/bin/bash + +# ========================================================== +# ProxMenux Monitor - Beta Program Installer +# ========================================================== +# Author : MacRimi +# Subproject : ProxMenux Monitor Beta +# Copyright : (c) 2024-2025 MacRimi +# License : GPL-3.0 (https://github.com/MacRimi/ProxMenux/blob/main/LICENSE) +# Version : Beta +# Branch : develop +# ========================================================== +# Description: +# This script installs the BETA version of ProxMenux Monitor +# from the develop branch on GitHub. +# +# Beta testers are expected to: +# - Report bugs and unexpected behavior via GitHub Issues +# - Provide feedback to help improve the final release +# +# Installs: +# • dialog, curl, jq, git (system dependencies) +# • ProxMenux core files (/usr/local/share/proxmenux) +# • ProxMenux Monitor AppImage (Web dashboard on port 8008) +# • Systemd service (auto-start on boot) +# +# Notes: +# - Clones from the 'develop' branch +# - Beta version file: beta_version.txt in the repository +# - Transition to stable: re-run the official installer +# ========================================================== + +# ── Configuration ────────────────────────────────────────── +INSTALL_DIR="/usr/local/bin" +BASE_DIR="/usr/local/share/proxmenux" +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" +BETA_VERSION_FILE="$BASE_DIR/beta_version.txt" +MENU_SCRIPT="menu" + +MONITOR_INSTALL_DIR="$BASE_DIR" +MONITOR_SERVICE_FILE="/etc/systemd/system/proxmenux-monitor.service" +MONITOR_PORT=8008 + +REPO_URL="https://github.com/MacRimi/ProxMenux.git" +REPO_BRANCH="develop" +TEMP_DIR="/tmp/proxmenux-beta-install-$$" + +# ── Colors ───────────────────────────────────────────────── +RESET="\033[0m" +BOLD="\033[1m" +WHITE="\033[38;5;15m" +NEON_PURPLE_BLUE="\033[38;5;99m" +DARK_GRAY="\033[38;5;244m" +ORANGE="\033[38;5;208m" +GN="\033[1;92m" +YW="\033[33m" +YWB="\033[1;33m" +RD="\033[01;31m" +BL="\033[36m" +CL="\033[m" +BGN="\e[1;32m" +TAB=" " +BFR="\\r\\033[K" +HOLD="-" +BOR=" | " +CM="${GN}✓ ${CL}" + +SPINNER_PID="" + +# ── Spinner ──────────────────────────────────────────────── +spinner() { + local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') + local spin_i=0 + printf "\e[?25l" + while true; do + printf "\r ${YW}%s${CL}" "${frames[spin_i]}" + spin_i=$(( (spin_i + 1) % ${#frames[@]} )) + sleep 0.1 + done +} + +type_text() { + local text="$1" + local delay=0.04 + for ((i=0; i<${#text}; i++)); do + echo -n "${text:$i:1}" + sleep $delay + done + echo +} + +msg_info() { + local msg="$1" + echo -ne "${TAB}${YW}${HOLD}${msg}" + spinner & + SPINNER_PID=$! +} + +msg_ok() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then + kill $SPINNER_PID > /dev/null 2>&1 + SPINNER_PID="" + fi + printf "\e[?25h" + echo -e "${BFR}${TAB}${CM}${GN}${1}${CL}" +} + +msg_error() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then + kill $SPINNER_PID > /dev/null 2>&1 + SPINNER_PID="" + fi + printf "\e[?25h" + echo -e "${BFR}${TAB}${RD}[ERROR] ${1}${CL}" +} + +msg_warn() { + if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null 2>&1; then + kill $SPINNER_PID > /dev/null 2>&1 + SPINNER_PID="" + fi + printf "\e[?25h" + echo -e "${BFR}${TAB}${YWB}${1}${CL}" +} + +msg_title() { + echo -e "\n" + echo -e "${TAB}${BOLD}${HOLD}${BOR}${1}${BOR}${HOLD}${CL}" + echo -e "\n" +} + +show_progress() { + echo -e "\n${BOLD}${BL}${TAB}Installing ProxMenux Beta: Step ${1} of ${2}${CL}" + echo + echo -e "${TAB}${BOLD}${YW}${HOLD}${3}${CL}" +} + +# ── Cleanup ──────────────────────────────────────────────── +cleanup() { + if [ -d "$TEMP_DIR" ]; then + rm -rf "$TEMP_DIR" + fi +} +trap cleanup EXIT + +# ── Logo ─────────────────────────────────────────────────── +show_proxmenux_logo() { + clear + + if [[ -z "$SSH_TTY" && -z "$(who am i | awk '{print $NF}' | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}')" ]]; then + +LOGO=$(cat << "EOF" +\e[0m\e[38;2;61;61;61m▆\e[38;2;60;60;60m▄\e[38;2;54;54;54m▂\e[0m \e[38;2;0;0;0m \e[0m \e[38;2;54;54;54m▂\e[38;2;60;60;60m▄\e[38;2;61;61;61m▆\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[38;2;61;61;61;48;2;37;37;37m▇\e[0m\e[38;2;60;60;60m▅\e[38;2;56;56;56m▃\e[38;2;37;37;37m▁ \e[38;2;36;36;36m▁\e[38;2;56;56;56m▃\e[38;2;60;60;60m▅\e[38;2;61;61;61;48;2;37;37;37m▇\e[48;2;62;62;62m \e[0m\e[7m\e[38;2;60;60;60m▁\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[7m\e[38;2;61;61;61m▂\e[0m\e[38;2;62;62;62;48;2;61;61;61m┈\e[48;2;62;62;62m \e[48;2;61;61;61m┈\e[0m\e[38;2;60;60;60m▆\e[38;2;57;57;57m▄\e[38;2;48;48;48m▂\e[0m \e[38;2;47;47;47m▂\e[38;2;57;57;57m▄\e[38;2;60;60;60m▆\e[38;2;62;62;62;48;2;61;61;61m┈\e[48;2;62;62;62m \e[48;2;61;61;61m┈\e[0m\e[7m\e[38;2;60;60;60m▂\e[38;2;57;57;57m▄\e[38;2;47;47;47m▆\e[0m \e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[7m\e[38;2;39;39;39m▇\e[38;2;57;57;57m▅\e[38;2;60;60;60m▃\e[0m\e[38;2;40;40;40;48;2;61;61;61m▁\e[48;2;62;62;62m \e[38;2;54;54;54;48;2;61;61;61m┊\e[48;2;62;62;62m \e[38;2;39;39;39;48;2;61;61;61m▁\e[0m\e[7m\e[38;2;60;60;60m▃\e[38;2;57;57;57m▅\e[38;2;38;38;38m▇\e[0m \e[38;2;193;60;2m▃\e[38;2;217;67;2m▅\e[38;2;225;70;2m▇\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[0m \e[38;2;203;63;2m▄\e[38;2;147;45;1m▂\e[0m \e[7m\e[38;2;55;55;55m▆\e[38;2;60;60;60m▄\e[38;2;61;61;61m▂\e[38;2;60;60;60m▄\e[38;2;55;55;55m▆\e[0m \e[38;2;144;44;1m▂\e[38;2;202;62;2m▄\e[38;2;219;68;2m▆\e[38;2;231;72;3;48;2;226;70;2m┈\e[48;2;231;72;3m \e[48;2;225;70;2m▉\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[7m\e[38;2;121;37;1m▉\e[0m\e[38;2;0;0;0;48;2;231;72;3m \e[0m\e[38;2;221;68;2m▇\e[38;2;208;64;2m▅\e[38;2;212;66;2m▂\e[38;2;123;37;0m▁\e[38;2;211;65;2m▂\e[38;2;207;64;2m▅\e[38;2;220;68;2m▇\e[48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m┈\e[0m\e[7m\e[38;2;221;68;2m▂\e[0m\e[38;2;44;13;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏\e[0m \e[7m\e[38;2;190;59;2m▅\e[38;2;216;67;2m▃\e[38;2;225;70;2m▁\e[0m\e[38;2;95;29;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;230;71;2m┈\e[48;2;231;72;3m \e[0m\e[7m\e[38;2;225;70;2m▁\e[38;2;216;67;2m▃\e[38;2;191;59;2m▅\e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏ \e[0m \e[7m\e[38;2;172;53;1m▆\e[38;2;213;66;2m▄\e[38;2;219;68;2m▂\e[38;2;213;66;2m▄\e[38;2;174;54;2m▆\e[0m \e[38;2;0;0;0m \e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m +\e[38;2;59;59;59;48;2;62;62;62m▏ \e[0m\e[38;2;32;32;32m▏ \e[0m \e[38;2;0;0;0;48;2;231;72;3m \e[38;2;231;72;3;48;2;225;70;2m▉\e[0m +\e[7m\e[38;2;52;52;52m▆\e[38;2;59;59;59m▄\e[38;2;61;61;61m▂\e[0m\e[38;2;31;31;31m▏ \e[0m \e[7m\e[38;2;228;71;2m▂\e[38;2;221;69;2m▄\e[38;2;196;60;2m▆\e[0m +EOF +) + TEXT=( + "" + "" + "${BOLD}ProxMenux${RESET}" + "" + "${BOLD}${NEON_PURPLE_BLUE}An Interactive Menu for${RESET}" + "${BOLD}${NEON_PURPLE_BLUE}Proxmox VE management${RESET}" + "" + "${BOLD}${YW} ★ BETA PROGRAM ★${RESET}" + "" + "" + ) + mapfile -t logo_lines <<< "$LOGO" + for i in {0..9}; do + echo -e "${TAB}${logo_lines[i]} ${WHITE}│${RESET} ${TEXT[i]}" + done + echo -e + + else + + TEXT=( + "" "" "" "" + "${BOLD}ProxMenux${RESET}" + "" + "${BOLD}${NEON_PURPLE_BLUE}An Interactive Menu for${RESET}" + "${BOLD}${NEON_PURPLE_BLUE}Proxmox VE management${RESET}" + "" + "${BOLD}${YW} ★ BETA PROGRAM ★${RESET}" + "" "" "" + ) + LOGO=( + "${DARK_GRAY}░░░░ ░░░░${RESET}" + "${DARK_GRAY}░░░░░░░ ░░░░░░ ${RESET}" + "${DARK_GRAY}░░░░░░░░░░░ ░░░░░░░ ${RESET}" + "${DARK_GRAY}░░░░ ░░░░░░ ░░░░░░ ${ORANGE}░░${RESET}" + "${DARK_GRAY}░░░░ ░░░░░░░ ${ORANGE}░░▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ░░░ ${ORANGE}░▒▒▒▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒░ ░▒▒▒▒▒▒▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}░▒▒▒▒▒ ▒▒▒▒▒░░ ▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}░░▒▒▒▒▒▒▒░░ ▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}░░░ ▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒▒${RESET}" + "${DARK_GRAY}░░░░ ${ORANGE}▒▒▒░${RESET}" + "${DARK_GRAY} ░░ ${ORANGE}░░ ${RESET}" + ) + for i in {0..12}; do + echo -e "${TAB}${LOGO[i]} │${RESET} ${TEXT[i]}" + done + echo -e + fi +} + +# ── Beta welcome message ─────────────────────────────────── +show_beta_welcome() { + local width=62 + local line + line=$(printf '─%.0s' $(seq 1 $width)) + + echo -e "${TAB}${BOLD}${YW}┌${line}┐${CL}" + echo -e "${TAB}${BOLD}${YW}│${CL}${BOLD} Welcome to the ProxMenux Monitor Beta Program ${YW}│${CL}" + echo -e "${TAB}${BOLD}${YW}└${line}┘${CL}" + echo + echo -e "${TAB}${WHITE}You are about to install a ${BOLD}pre-release (beta)${RESET}${WHITE} version of${CL}" + echo -e "${TAB}${WHITE}ProxMenux Monitor, built from the ${BOLD}develop${RESET}${WHITE} branch.${CL}" + echo + echo -e "${TAB}${BOLD}${GN}What this means for you:${CL}" + echo -e "${TAB} ${GN}•${CL} You'll get the latest features before the official release." + echo -e "${TAB} ${GN}•${CL} Some things may not work perfectly — that's expected." + echo -e "${TAB} ${GN}•${CL} Your feedback is what makes the final version better." + echo + echo -e "${TAB}${BOLD}${YW}How to report issues:${CL}" + echo -e "${TAB} ${YW}→${CL} Open a GitHub Issue at:" + echo -e "${TAB} ${BL}https://github.com/MacRimi/ProxMenux/issues${CL}" + echo -e "${TAB} ${YW}→${CL} Describe what happened, what you expected, and any" + echo -e "${TAB} error messages you saw. Logs help a lot:" + echo -e "${TAB} ${DARK_GRAY}journalctl -u proxmenux-monitor -n 50${CL}" + echo + echo -e "${TAB}${BOLD}${NEON_PURPLE_BLUE}Thank you for being part of the beta program!${CL}" + echo -e "${TAB}${DARK_GRAY}Your help is essential to deliver a stable and polished release.${CL}" + echo + echo -e "${TAB}${BOLD}${YW}┌${line}┐${CL}" + echo -e "${TAB}${BOLD}${YW}│${CL} ${YW}│${CL}" + echo -e "${TAB}${BOLD}${YW}│${CL} Press ${BOLD}${GN}[Enter]${CL} to continue with the beta installation, ${YW}│${CL}" + echo -e "${TAB}${BOLD}${YW}│${CL} or ${BOLD}${RD}[Ctrl+C]${CL} to cancel and exit. ${YW}│${CL}" + echo -e "${TAB}${BOLD}${YW}│${CL} ${YW}│${CL}" + echo -e "${TAB}${BOLD}${YW}└${line}┘${CL}" + echo + + read -r -p "" + echo +} + +# ── Helpers ──────────────────────────────────────────────── +get_server_ip() { + local ip + ip=$(ip route get 1.1.1.1 2>/dev/null | grep -oP 'src \K\S+') + [ -z "$ip" ] && ip=$(hostname -I | awk '{print $1}') + [ -z "$ip" ] && ip="localhost" + echo "$ip" +} + update_config() { local component="$1" local status="$2" @@ -297,67 +297,67 @@ reset_update_flag() { fi [ -f "$tmp_file" ] && rm -f "$tmp_file" } - -cleanup_corrupted_files() { - if [ -f "$CONFIG_FILE" ] && ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then - rm -f "$CONFIG_FILE" - fi - if [ -f "$CACHE_FILE" ] && ! jq empty "$CACHE_FILE" >/dev/null 2>&1; then - rm -f "$CACHE_FILE" - fi -} - -detect_latest_appimage() { - local appimage_dir="$TEMP_DIR/AppImage" - [ ! -d "$appimage_dir" ] && return 1 - local latest - latest=$(find "$appimage_dir" -name "ProxMenux-*.AppImage" -type f | sort -V | tail -1) - [ -z "$latest" ] && return 1 - echo "$latest" -} - -get_appimage_version() { - local filename - filename=$(basename "$1") - echo "$filename" | grep -oP 'ProxMenux-\K[0-9]+\.[0-9]+\.[0-9]+' -} - -# ── Monitor install ──────────────────────────────────────── -install_proxmenux_monitor() { - local appimage_source - appimage_source=$(detect_latest_appimage) - - if [ -z "$appimage_source" ] || [ ! -f "$appimage_source" ]; then - msg_error "ProxMenux Monitor AppImage not found in $TEMP_DIR/AppImage/" - msg_warn "Make sure the AppImage directory exists in the develop branch." - update_config "proxmenux_monitor" "appimage_not_found" - return 1 - fi - - local appimage_version - appimage_version=$(get_appimage_version "$appimage_source") - - systemctl is-active --quiet proxmenux-monitor.service 2>/dev/null && \ - systemctl stop proxmenux-monitor.service - - local service_exists=false - [ -f "$MONITOR_SERVICE_FILE" ] && service_exists=true - - local sha256_file="$TEMP_DIR/AppImage/ProxMenux-Monitor.AppImage.sha256" - if [ -f "$sha256_file" ]; then - msg_info "Verifying AppImage integrity..." - local expected_hash actual_hash - expected_hash=$(grep -Eo '^[a-f0-9]+' "$sha256_file" | tr -d '\n') - actual_hash=$(sha256sum "$appimage_source" | awk '{print $1}') - if [ "$expected_hash" != "$actual_hash" ]; then - msg_error "SHA256 verification failed! The AppImage may be corrupted." - return 1 - fi - msg_ok "SHA256 verification passed." - else - msg_warn "SHA256 checksum file not found. Skipping verification." - fi - + +cleanup_corrupted_files() { + if [ -f "$CONFIG_FILE" ] && ! jq empty "$CONFIG_FILE" >/dev/null 2>&1; then + rm -f "$CONFIG_FILE" + fi + if [ -f "$CACHE_FILE" ] && ! jq empty "$CACHE_FILE" >/dev/null 2>&1; then + rm -f "$CACHE_FILE" + fi +} + +detect_latest_appimage() { + local appimage_dir="$TEMP_DIR/AppImage" + [ ! -d "$appimage_dir" ] && return 1 + local latest + latest=$(find "$appimage_dir" -name "ProxMenux-*.AppImage" -type f | sort -V | tail -1) + [ -z "$latest" ] && return 1 + echo "$latest" +} + +get_appimage_version() { + local filename + filename=$(basename "$1") + echo "$filename" | grep -oP 'ProxMenux-\K[0-9]+\.[0-9]+\.[0-9]+' +} + +# ── Monitor install ──────────────────────────────────────── +install_proxmenux_monitor() { + local appimage_source + appimage_source=$(detect_latest_appimage) + + if [ -z "$appimage_source" ] || [ ! -f "$appimage_source" ]; then + msg_error "ProxMenux Monitor AppImage not found in $TEMP_DIR/AppImage/" + msg_warn "Make sure the AppImage directory exists in the develop branch." + update_config "proxmenux_monitor" "appimage_not_found" + return 1 + fi + + local appimage_version + appimage_version=$(get_appimage_version "$appimage_source") + + systemctl is-active --quiet proxmenux-monitor.service 2>/dev/null && \ + systemctl stop proxmenux-monitor.service + + local service_exists=false + [ -f "$MONITOR_SERVICE_FILE" ] && service_exists=true + + local sha256_file="$TEMP_DIR/AppImage/ProxMenux-Monitor.AppImage.sha256" + if [ -f "$sha256_file" ]; then + msg_info "Verifying AppImage integrity..." + local expected_hash actual_hash + expected_hash=$(grep -Eo '^[a-f0-9]+' "$sha256_file" | tr -d '\n') + actual_hash=$(sha256sum "$appimage_source" | awk '{print $1}') + if [ "$expected_hash" != "$actual_hash" ]; then + msg_error "SHA256 verification failed! The AppImage may be corrupted." + return 1 + fi + msg_ok "SHA256 verification passed." + else + msg_warn "SHA256 checksum file not found. Skipping verification." + fi + msg_info "Installing ProxMenux Monitor (beta)..." mkdir -p "$MONITOR_INSTALL_DIR" local target_path="$MONITOR_INSTALL_DIR/ProxMenux-Monitor.AppImage" @@ -368,42 +368,9 @@ install_proxmenux_monitor() { local shutdown_script_src="$TEMP_DIR/Scripts/shutdown-notify.sh" mkdir -p "$MONITOR_INSTALL_DIR/scripts" local shutdown_script_dst="$MONITOR_INSTALL_DIR/scripts/shutdown-notify.sh" - if [ -f "$shutdown_script_src" ]; then - cp "$shutdown_script_src" "$shutdown_script_dst" - chmod +x "$shutdown_script_dst" - msg_ok "Shutdown notification script installed." - else - msg_warn "Shutdown script not found, creating default..." - cat > "$shutdown_script_dst" << 'SHUTDOWN_EOF' -#!/bin/bash -# ProxMenux Monitor - Shutdown Notification Script -LOG_FILE="/var/log/proxmenux-shutdown.log" -PORT="${PORT:-8008}" -log() { echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE" 2>/dev/null || true; } -log "=== Shutdown notification script started ===" -is_reboot=false -systemctl is-active --quiet reboot.target 2>/dev/null && is_reboot=true -if [ "$is_reboot" = true ]; then - event_type="system_reboot" - reason="The system is rebooting." -else - event_type="system_shutdown" - reason="The system is shutting down." -fi -hostname=$(hostname) -log "Event: $event_type, Host: $hostname" -response=$(curl -s -w "\n%{http_code}" -X POST "http://127.0.0.1:$PORT/api/internal/shutdown-event" \ - -H "Content-Type: application/json" \ - -d "{\"event_type\": \"$event_type\", \"hostname\": \"$hostname\", \"reason\": \"$reason\"}" \ - --max-time 10 2>&1) -log "Response: $response" -sleep 3 -pkill -TERM -f "flask_server" 2>/dev/null || true -log "=== Shutdown script completed ===" -exit 0 -SHUTDOWN_EOF - chmod +x "$shutdown_script_dst" - fi + cp "$shutdown_script_src" "$shutdown_script_dst" + chmod +x "$shutdown_script_dst" + msg_ok "Shutdown notification script installed." msg_ok "ProxMenux Monitor beta v${appimage_version} installed." if [ "$service_exists" = false ]; then @@ -459,15 +426,15 @@ EOF systemctl daemon-reload msg_ok "Service configuration updated." } - -create_monitor_service() { - msg_info "Creating ProxMenux Monitor service..." - local exec_path="$MONITOR_INSTALL_DIR/ProxMenux-Monitor.AppImage" - - if [ -f "$TEMP_DIR/systemd/proxmenux-monitor.service" ]; then - sed "s|ExecStart=.*|ExecStart=$exec_path|g" \ - "$TEMP_DIR/systemd/proxmenux-monitor.service" > "$MONITOR_SERVICE_FILE" - msg_ok "Service file loaded from repository." + +create_monitor_service() { + msg_info "Creating ProxMenux Monitor service..." + local exec_path="$MONITOR_INSTALL_DIR/ProxMenux-Monitor.AppImage" + + if [ -f "$TEMP_DIR/systemd/proxmenux-monitor.service" ]; then + sed "s|ExecStart=.*|ExecStart=$exec_path|g" \ + "$TEMP_DIR/systemd/proxmenux-monitor.service" > "$MONITOR_SERVICE_FILE" + msg_ok "Service file loaded from repository." else cat > "$MONITOR_SERVICE_FILE" << EOF [Unit] @@ -494,143 +461,143 @@ WantedBy=multi-user.target EOF msg_ok "Default service file created." fi - - systemctl daemon-reload - systemctl enable proxmenux-monitor.service > /dev/null 2>&1 - systemctl start proxmenux-monitor.service > /dev/null 2>&1 - sleep 3 - - if systemctl is-active --quiet proxmenux-monitor.service; then - msg_ok "ProxMenux Monitor service started successfully." - update_config "proxmenux_monitor" "beta_installed" - return 0 - else - msg_warn "ProxMenux Monitor service failed to start." - echo -e "${TAB}${DARK_GRAY}Check logs : journalctl -u proxmenux-monitor -n 20${CL}" - echo -e "${TAB}${DARK_GRAY}Check status: systemctl status proxmenux-monitor${CL}" - update_config "proxmenux_monitor" "failed" - return 1 - fi -} - -# ── Main install ─────────────────────────────────────────── -install_beta() { - local total_steps=4 - local current_step=1 - - # ── Step 1: Dependencies ────────────────────────────── - show_progress $current_step $total_steps "Installing system dependencies" - - if ! command -v jq > /dev/null 2>&1; then - apt-get update > /dev/null 2>&1 - if apt-get install -y jq > /dev/null 2>&1 && command -v jq > /dev/null 2>&1; then - update_config "jq" "installed" - else - local jq_url="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64" - if wget -q -O /usr/local/bin/jq "$jq_url" 2>/dev/null && chmod +x /usr/local/bin/jq \ - && command -v jq > /dev/null 2>&1; then - update_config "jq" "installed_from_github" - else - msg_error "Failed to install jq. Please install it manually and re-run." - update_config "jq" "failed" - return 1 - fi - fi - else - update_config "jq" "already_installed" - fi - - local BASIC_DEPS=("dialog" "curl" "git") - if [ -z "${APT_UPDATED:-}" ]; then - apt-get update -y > /dev/null 2>&1 || true - APT_UPDATED=1 - fi - - for pkg in "${BASIC_DEPS[@]}"; do - if ! dpkg -l | grep -qw "$pkg"; then - if apt-get install -y "$pkg" > /dev/null 2>&1; then - update_config "$pkg" "installed" - else - msg_error "Failed to install $pkg. Please install it manually." - update_config "$pkg" "failed" - return 1 - fi - else - update_config "$pkg" "already_installed" - fi - done - - msg_ok "Dependencies installed: jq, dialog, curl, git." - - # ── Step 2: Clone develop branch ───────────────────── - ((current_step++)) - show_progress $current_step $total_steps "Cloning ProxMenux develop branch" - - msg_info "Cloning branch '${REPO_BRANCH}' from repository..." - if ! git clone --depth 1 --branch "$REPO_BRANCH" "$REPO_URL" "$TEMP_DIR" 2>/dev/null; then - msg_error "Failed to clone branch '$REPO_BRANCH' from $REPO_URL" - exit 1 - fi - msg_ok "Repository cloned successfully (branch: ${REPO_BRANCH})." - - # Read beta version if available - local beta_version="unknown" - if [ -f "$TEMP_DIR/beta_version.txt" ]; then - beta_version=$(cat "$TEMP_DIR/beta_version.txt" | tr -d '[:space:]') - fi - - cd "$TEMP_DIR" - - # ── Step 3: Files ───────────────────────────────────── - ((current_step++)) - show_progress $current_step $total_steps "Creating directories and copying files" - - mkdir -p "$BASE_DIR" "$INSTALL_DIR" - [ ! -f "$CONFIG_FILE" ] && echo '{}' > "$CONFIG_FILE" - - # Preserve user/runtime directories that must never be overwritten - mkdir -p "$BASE_DIR/oci" - - cp "./scripts/utils.sh" "$UTILS_FILE" - cp "./menu" "$INSTALL_DIR/$MENU_SCRIPT" - cp "./version.txt" "$LOCAL_VERSION_FILE" 2>/dev/null || true - - # Store beta version marker - if [ -f "$TEMP_DIR/beta_version.txt" ]; then - cp "$TEMP_DIR/beta_version.txt" "$BETA_VERSION_FILE" - else - echo "$beta_version" > "$BETA_VERSION_FILE" - fi - - cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh" 2>/dev/null || true - cp "./install_proxmenux_beta.sh" "$BASE_DIR/install_proxmenux_beta.sh" 2>/dev/null || true - - mkdir -p "$BASE_DIR/scripts" - cp -r "./scripts/"* "$BASE_DIR/scripts/" - chmod -R +x "$BASE_DIR/scripts/" - - if [ -d "./oci" ]; then - mkdir -p "$BASE_DIR/oci" - cp -r "./oci/"* "$BASE_DIR/oci/" 2>/dev/null || true - fi - chmod +x "$INSTALL_DIR/$MENU_SCRIPT" - [ -f "$BASE_DIR/install_proxmenux.sh" ] && chmod +x "$BASE_DIR/install_proxmenux.sh" - [ -f "$BASE_DIR/install_proxmenux_beta.sh" ] && chmod +x "$BASE_DIR/install_proxmenux_beta.sh" - - # Store beta flag in config - update_config "beta_program" "active" - update_config "beta_version" "$beta_version" - update_config "install_branch" "$REPO_BRANCH" - - msg_ok "Files installed. Beta version: ${beta_version}." - - # ── Step 4: Monitor ─────────────────────────────────── - ((current_step++)) - show_progress $current_step $total_steps "Installing ProxMenux Monitor (beta)" - - install_proxmenux_monitor - local monitor_status=$? - + + systemctl daemon-reload + systemctl enable proxmenux-monitor.service > /dev/null 2>&1 + systemctl start proxmenux-monitor.service > /dev/null 2>&1 + sleep 3 + + if systemctl is-active --quiet proxmenux-monitor.service; then + msg_ok "ProxMenux Monitor service started successfully." + update_config "proxmenux_monitor" "beta_installed" + return 0 + else + msg_warn "ProxMenux Monitor service failed to start." + echo -e "${TAB}${DARK_GRAY}Check logs : journalctl -u proxmenux-monitor -n 20${CL}" + echo -e "${TAB}${DARK_GRAY}Check status: systemctl status proxmenux-monitor${CL}" + update_config "proxmenux_monitor" "failed" + return 1 + fi +} + +# ── Main install ─────────────────────────────────────────── +install_beta() { + local total_steps=4 + local current_step=1 + + # ── Step 1: Dependencies ────────────────────────────── + show_progress $current_step $total_steps "Installing system dependencies" + + if ! command -v jq > /dev/null 2>&1; then + apt-get update > /dev/null 2>&1 + if apt-get install -y jq > /dev/null 2>&1 && command -v jq > /dev/null 2>&1; then + update_config "jq" "installed" + else + local jq_url="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64" + if wget -q -O /usr/local/bin/jq "$jq_url" 2>/dev/null && chmod +x /usr/local/bin/jq \ + && command -v jq > /dev/null 2>&1; then + update_config "jq" "installed_from_github" + else + msg_error "Failed to install jq. Please install it manually and re-run." + update_config "jq" "failed" + return 1 + fi + fi + else + update_config "jq" "already_installed" + fi + + local BASIC_DEPS=("dialog" "curl" "git") + if [ -z "${APT_UPDATED:-}" ]; then + apt-get update -y > /dev/null 2>&1 || true + APT_UPDATED=1 + fi + + for pkg in "${BASIC_DEPS[@]}"; do + if ! dpkg -l | grep -qw "$pkg"; then + if apt-get install -y "$pkg" > /dev/null 2>&1; then + update_config "$pkg" "installed" + else + msg_error "Failed to install $pkg. Please install it manually." + update_config "$pkg" "failed" + return 1 + fi + else + update_config "$pkg" "already_installed" + fi + done + + msg_ok "Dependencies installed: jq, dialog, curl, git." + + # ── Step 2: Clone develop branch ───────────────────── + ((current_step++)) + show_progress $current_step $total_steps "Cloning ProxMenux develop branch" + + msg_info "Cloning branch '${REPO_BRANCH}' from repository..." + if ! git clone --depth 1 --branch "$REPO_BRANCH" "$REPO_URL" "$TEMP_DIR" 2>/dev/null; then + msg_error "Failed to clone branch '$REPO_BRANCH' from $REPO_URL" + exit 1 + fi + msg_ok "Repository cloned successfully (branch: ${REPO_BRANCH})." + + # Read beta version if available + local beta_version="unknown" + if [ -f "$TEMP_DIR/beta_version.txt" ]; then + beta_version=$(cat "$TEMP_DIR/beta_version.txt" | tr -d '[:space:]') + fi + + cd "$TEMP_DIR" + + # ── Step 3: Files ───────────────────────────────────── + ((current_step++)) + show_progress $current_step $total_steps "Creating directories and copying files" + + mkdir -p "$BASE_DIR" "$INSTALL_DIR" + [ ! -f "$CONFIG_FILE" ] && echo '{}' > "$CONFIG_FILE" + + # Preserve user/runtime directories that must never be overwritten + mkdir -p "$BASE_DIR/oci" + + cp "./scripts/utils.sh" "$UTILS_FILE" + cp "./menu" "$INSTALL_DIR/$MENU_SCRIPT" + cp "./version.txt" "$LOCAL_VERSION_FILE" 2>/dev/null || true + + # Store beta version marker + if [ -f "$TEMP_DIR/beta_version.txt" ]; then + cp "$TEMP_DIR/beta_version.txt" "$BETA_VERSION_FILE" + else + echo "$beta_version" > "$BETA_VERSION_FILE" + fi + + cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh" 2>/dev/null || true + cp "./install_proxmenux_beta.sh" "$BASE_DIR/install_proxmenux_beta.sh" 2>/dev/null || true + + mkdir -p "$BASE_DIR/scripts" + cp -r "./scripts/"* "$BASE_DIR/scripts/" + chmod -R +x "$BASE_DIR/scripts/" + + if [ -d "./oci" ]; then + mkdir -p "$BASE_DIR/oci" + cp -r "./oci/"* "$BASE_DIR/oci/" 2>/dev/null || true + fi + chmod +x "$INSTALL_DIR/$MENU_SCRIPT" + [ -f "$BASE_DIR/install_proxmenux.sh" ] && chmod +x "$BASE_DIR/install_proxmenux.sh" + [ -f "$BASE_DIR/install_proxmenux_beta.sh" ] && chmod +x "$BASE_DIR/install_proxmenux_beta.sh" + + # Store beta flag in config + update_config "beta_program" "active" + update_config "beta_version" "$beta_version" + update_config "install_branch" "$REPO_BRANCH" + + msg_ok "Files installed. Beta version: ${beta_version}." + + # ── Step 4: Monitor ─────────────────────────────────── + ((current_step++)) + show_progress $current_step $total_steps "Installing ProxMenux Monitor (beta)" + + install_proxmenux_monitor + local monitor_status=$? + if [ $monitor_status -eq 0 ]; then create_monitor_service elif [ $monitor_status -eq 2 ]; then @@ -642,50 +609,50 @@ install_beta() { msg_ok "Beta installation completed." } - -# ── Stable transition notice ─────────────────────────────── -check_stable_available() { - # Called if a stable version is detected (future use by update logic) - # When main's version.txt > beta_version.txt, the menu/updater can call this - echo -e "\n${TAB}${BOLD}${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}" - echo -e "${TAB}${BOLD}${GN} A stable release is now available!${CL}" - echo -e "${TAB}${WHITE} To leave the beta program and switch to the stable version,${CL}" - echo -e "${TAB}${WHITE} run the official installer:${CL}" - echo -e "" - echo -e "${TAB} ${YWB}bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/MacRimi/ProxMenux/main/install_proxmenux.sh)\"${CL}" - echo -e "" - echo -e "${TAB}${DARK_GRAY} This will cleanly replace your beta install with the stable release.${CL}" - echo -e "${TAB}${BOLD}${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}\n" -} - -# ── Entry point ──────────────────────────────────────────── -if [ "$(id -u)" -ne 0 ]; then - echo -e "${RD}[ERROR] This script must be run as root.${CL}" - exit 1 -fi - -cleanup_corrupted_files -show_proxmenux_logo -show_beta_welcome - -msg_title "Installing ProxMenux Beta — branch: develop" -install_beta - -# Load utils if available -[ -f "$UTILS_FILE" ] && source "$UTILS_FILE" - -msg_title "ProxMenux Beta installed successfully" - -if systemctl is-active --quiet proxmenux-monitor.service; then - local_ip=$(get_server_ip) - echo -e "${GN}🌐 ProxMenux Monitor (beta) is running${CL}: ${BL}http://${local_ip}:${MONITOR_PORT}${CL}" - echo -fi - -echo -ne "${GN}" -type_text "To run ProxMenux, execute this command in your terminal:" -echo -e "${YWB} menu${CL}" -echo -echo -e "${TAB}${DARK_GRAY}Report issues at: https://github.com/MacRimi/ProxMenux/issues${CL}" -echo + +# ── Stable transition notice ─────────────────────────────── +check_stable_available() { + # Called if a stable version is detected (future use by update logic) + # When main's version.txt > beta_version.txt, the menu/updater can call this + echo -e "\n${TAB}${BOLD}${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}" + echo -e "${TAB}${BOLD}${GN} A stable release is now available!${CL}" + echo -e "${TAB}${WHITE} To leave the beta program and switch to the stable version,${CL}" + echo -e "${TAB}${WHITE} run the official installer:${CL}" + echo -e "" + echo -e "${TAB} ${YWB}bash -c \"\$(wget -qLO - https://raw.githubusercontent.com/MacRimi/ProxMenux/main/install_proxmenux.sh)\"${CL}" + echo -e "" + echo -e "${TAB}${DARK_GRAY} This will cleanly replace your beta install with the stable release.${CL}" + echo -e "${TAB}${BOLD}${GN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${CL}\n" +} + +# ── Entry point ──────────────────────────────────────────── +if [ "$(id -u)" -ne 0 ]; then + echo -e "${RD}[ERROR] This script must be run as root.${CL}" + exit 1 +fi + +cleanup_corrupted_files +show_proxmenux_logo +show_beta_welcome + +msg_title "Installing ProxMenux Beta — branch: develop" +install_beta + +# Load utils if available +[ -f "$UTILS_FILE" ] && source "$UTILS_FILE" + +msg_title "ProxMenux Beta installed successfully" + +if systemctl is-active --quiet proxmenux-monitor.service; then + local_ip=$(get_server_ip) + echo -e "${GN}🌐 ProxMenux Monitor (beta) is running${CL}: ${BL}http://${local_ip}:${MONITOR_PORT}${CL}" + echo +fi + +echo -ne "${GN}" +type_text "To run ProxMenux, execute this command in your terminal:" +echo -e "${YWB} menu${CL}" +echo +echo -e "${TAB}${DARK_GRAY}Report issues at: https://github.com/MacRimi/ProxMenux/issues${CL}" +echo exit 0