Update Install ProxMenux

This commit is contained in:
MacRimi
2025-10-31 22:44:59 +01:00
parent 5fd7df69fd
commit 45f6a0ec02
2 changed files with 286 additions and 53 deletions

View File

@@ -41,11 +41,16 @@ BASE_DIR="/usr/local/share/proxmenux"
CONFIG_FILE="$BASE_DIR/config.json"
CACHE_FILE="$BASE_DIR/cache.json"
UTILS_FILE="$BASE_DIR/utils.sh"
#EMERGENCY_FILE="$BASE_DIR/emergency_repair.sh"
LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
MENU_SCRIPT="menu"
VENV_PATH="/opt/googletrans-env"
MONITOR_APPIMAGE_URL="https://github.com/MacRimi/ProxMenux/raw/refs/heads/main/AppImage/ProxMenux-1.0.0.AppImage"
MONITOR_SHA256_URL="https://github.com/MacRimi/ProxMenux/raw/refs/heads/main/AppImage/ProxMenux-Monitor.AppImage.sha256"
MONITOR_INSTALL_PATH="$BASE_DIR/ProxMenux-Monitor.AppImage"
MONITOR_SERVICE_FILE="/etc/systemd/system/proxmenux-monitor.service"
MONITOR_PORT=8008
if ! source <(curl -sSf "$UTILS_URL"); then
echo "Error: Could not load utils.sh from $UTILS_URL"
exit 1
@@ -193,7 +198,7 @@ update_config() {
local status="$2"
local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
local tracked_components=("dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans")
local tracked_components=("dialog" "curl" "jq" "python3" "python3-venv" "python3-pip" "virtual_environment" "pip" "googletrans" "proxmenux_monitor")
if [[ " ${tracked_components[@]} " =~ " ${component} " ]]; then
mkdir -p "$(dirname "$CONFIG_FILE")"
@@ -274,7 +279,7 @@ show_installation_confirmation() {
case "$install_type" in
"1")
if whiptail --title "ProxMenux - Normal Version Installation" \
--yesno "ProxMenux Normal Version will install:\n\n• dialog (interactive menus) - Official Debian package\n• curl (file downloads) - Official Debian package\n• jq (JSON processing) - Official Debian package\n• ProxMenux core files (/usr/local/share/proxmenux)\n\nThis is a lightweight installation with minimal dependencies.\n\nProceed with installation?" 18 70; then
--yesno "ProxMenux Normal Version will install:\n\n• dialog (interactive menus) - Official Debian package\n• curl (file downloads) - Official Debian package\n• jq (JSON processing) - Official Debian package\n• ProxMenux core files (/usr/local/share/proxmenux)\n• ProxMenux Monitor (Web dashboard on port 8008)\n\nThis is a lightweight installation with minimal dependencies.\n\nProceed with installation?" 20 70; then
return 0
else
return 1
@@ -282,7 +287,7 @@ show_installation_confirmation() {
;;
"2")
if whiptail --title "ProxMenux - Translation Version Installation" \
--yesno "ProxMenux Translation Version will install:\n\n• dialog (interactive menus)\n• curl (file downloads)\n• jq (JSON processing)\n• python3 + python3-venv + python3-pip\n• Google Translate library (googletrans)\n• Virtual environment (/opt/googletrans-env)\n• Translation cache system\n• ProxMenux core files\n\nThis version requires more dependencies for translation support.\n\nProceed with installation?" 18 70; then
--yesno "ProxMenux Translation Version will install:\n\n• dialog (interactive menus)\n• curl (file downloads)\n• jq (JSON processing)\n• python3 + python3-venv + python3-pip\n• Google Translate library (googletrans)\n• Virtual environment (/opt/googletrans-env)\n• Translation cache system\n• ProxMenux core files\n• ProxMenux Monitor (Web dashboard on port 8008)\n\nThis version requires more dependencies for translation support.\n\nProceed with installation?" 20 70; then
return 0
else
return 1
@@ -291,9 +296,112 @@ show_installation_confirmation() {
esac
}
get_server_ip() {
local ip
# Try to get the primary IP address
ip=$(ip route get 1.1.1.1 2>/dev/null | grep -oP 'src \K\S+')
if [ -z "$ip" ]; then
# Fallback: get first non-loopback IP
ip=$(hostname -I | awk '{print $1}')
fi
if [ -z "$ip" ]; then
# Last resort: use localhost
ip="localhost"
fi
echo "$ip"
}
install_proxmenux_monitor() {
# Check if URL is accessible
if ! wget --spider -q "$MONITOR_APPIMAGE_URL" 2>/dev/null; then
msg_warn "ProxMenux Monitor AppImage not available at: $MONITOR_APPIMAGE_URL"
msg_info "The monitor will be available in future releases."
return 1
fi
# Download AppImage silently
if ! wget -q -O "$MONITOR_INSTALL_PATH" "$MONITOR_APPIMAGE_URL" 2>&1; then
msg_warn "Failed to download ProxMenux Monitor from GitHub."
msg_info "You can install it manually later when available."
return 1
fi
# Download SHA256 checksum silently
local sha256_file="/tmp/proxmenux-monitor.sha256"
if ! wget -q -O "$sha256_file" "$MONITOR_SHA256_URL" 2>/dev/null; then
msg_warn "SHA256 checksum file not available. Skipping verification."
msg_info "AppImage downloaded but integrity cannot be verified."
rm -f "$sha256_file"
else
# Verify SHA256 silently
local expected_hash=$(cat "$sha256_file" | awk '{print $1}')
local actual_hash=$(sha256sum "$MONITOR_INSTALL_PATH" | awk '{print $1}')
if [ "$expected_hash" != "$actual_hash" ]; then
msg_error "SHA256 verification failed! AppImage may be corrupted."
msg_info "Expected: $expected_hash"
msg_info "Got: $actual_hash"
rm -f "$MONITOR_INSTALL_PATH" "$sha256_file"
return 1
fi
rm -f "$sha256_file"
fi
# Make executable
chmod +x "$MONITOR_INSTALL_PATH"
# Show single success message at the end
msg_ok "ProxMenux Monitor installed and activated successfully."
return 0
}
create_monitor_service() {
msg_info "Creating ProxMenux Monitor service..."
cat > "$MONITOR_SERVICE_FILE" << EOF
[Unit]
Description=ProxMenux Monitor - Web Dashboard
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=$BASE_DIR
ExecStart=$MONITOR_INSTALL_PATH
Restart=on-failure
RestartSec=10
Environment="PORT=$MONITOR_PORT"
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd, enable and start service
systemctl daemon-reload
systemctl enable proxmenux-monitor.service > /dev/null 2>&1
systemctl start proxmenux-monitor.service > /dev/null 2>&1
# Wait a moment for service to start
sleep 2
# Check if service is running
if systemctl is-active --quiet proxmenux-monitor.service; then
msg_ok "ProxMenux Monitor service started successfully."
update_config "proxmenux_monitor" "installed"
return 0
else
msg_warn "ProxMenux Monitor service failed to start. Check logs with: journalctl -u proxmenux-monitor"
return 1
fi
}
####################################################
install_normal_version() {
local total_steps=3
local total_steps=4 # Increased from 3 to 4 for monitor installation
local current_step=1
show_progress $current_step $total_steps "Installing basic dependencies"
@@ -350,7 +458,6 @@ install_normal_version() {
FILES=(
"$UTILS_FILE $REPO_URL/scripts/utils.sh"
# "$EMERGENCY_FILE $REPO_URL/scripts/emergency_repair.sh"
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
)
@@ -368,12 +475,18 @@ install_normal_version() {
done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
# chmod +x "$EMERGENCY_FILE"
((current_step++))
show_progress $current_step $total_steps "Installing ProxMenux Monitor"
if install_proxmenux_monitor; then
create_monitor_service
fi
}
####################################################
install_translation_version() {
local total_steps=4
local total_steps=5 # Increased from 4 to 5 for monitor installation
local current_step=1
show_progress $current_step $total_steps "Language selection"
@@ -470,7 +583,6 @@ install_translation_version() {
FILES=(
"$CACHE_FILE $REPO_URL/json/cache.json"
"$UTILS_FILE $REPO_URL/scripts/utils.sh"
# "$EMERGENCY_FILE $REPO_URL/scripts/emergency_repair.sh"
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
)
@@ -491,7 +603,13 @@ install_translation_version() {
done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
#chmod +x "$EMERGENCY_FILE"
((current_step++))
show_progress $current_step $total_steps "Installing ProxMenux Monitor"
if install_proxmenux_monitor; then
create_monitor_service
fi
}
####################################################
@@ -518,9 +636,6 @@ show_installation_options() {
esac
fi
if [[ "$pve_version" -ge 9 ]]; then
INSTALL_TYPE=$(whiptail --backtitle "ProxMenux" --title "$menu_title" --menu "\n$menu_text" 14 70 2 \
"1" "Normal Version (English only)" 3>&1 1>&2 2>&3)
@@ -541,8 +656,6 @@ show_installation_options() {
exit 1
fi
fi
if [ -z "$INSTALL_TYPE" ]; then
show_proxmenux_logo
@@ -587,6 +700,13 @@ install_proxmenu() {
esac
msg_title "$(translate "ProxMenux has been installed successfully")"
if systemctl is-active --quiet proxmenux-monitor.service; then
local server_ip=$(get_server_ip)
echo -e "${GN}🌐 $(translate "ProxMenux Monitor activated")${CL}: ${BL}http://${server_ip}:${MONITOR_PORT}${CL}"
echo
fi
echo -ne "${GN}"
type_text "$(translate "To run ProxMenux, simply execute this command in the console or terminal:")"
echo -e "${YWB} menu${CL}"

View File

@@ -19,6 +19,7 @@ LOCAL_VERSION_FILE="$BASE_DIR/version.txt"
INSTALL_DIR="/usr/local/bin"
MENU_SCRIPT="menu"
VENV_PATH="/opt/googletrans-env"
MONITOR_SERVICE="proxmenux-monitor.service"
if [[ -f "$UTILS_FILE" ]]; then
source "$UTILS_FILE"
@@ -33,12 +34,12 @@ detect_installation_type() {
local has_venv=false
local has_language=false
# Check if virtual environment exists
if [ -d "$VENV_PATH" ] && [ -f "$VENV_PATH/bin/activate" ]; then
has_venv=true
fi
# Check if language is configured
if [ -f "$CONFIG_FILE" ]; then
local current_language=$(jq -r '.language // empty' "$CONFIG_FILE" 2>/dev/null)
if [[ -n "$current_language" && "$current_language" != "null" && "$current_language" != "empty" ]]; then
@@ -53,6 +54,89 @@ detect_installation_type() {
fi
}
check_monitor_status() {
if systemctl list-unit-files | grep -q "$MONITOR_SERVICE"; then
if systemctl is-active --quiet "$MONITOR_SERVICE"; then
echo "active"
else
echo "inactive"
fi
else
echo "not_installed"
fi
}
toggle_monitor_service() {
local status=$(check_monitor_status)
if [ "$status" = "not_installed" ]; then
dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "ProxMenux Monitor")" \
--msgbox "\n\n$(translate "ProxMenux Monitor is not installed.")" 10 50
return
fi
if [ "$status" = "active" ]; then
if dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "Deactivate Monitor")" \
--yesno "\n$(translate "Do you want to deactivate ProxMenux Monitor?")" 8 60; then
systemctl stop "$MONITOR_SERVICE" 2>/dev/null
systemctl disable "$MONITOR_SERVICE" 2>/dev/null
dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "Monitor Deactivated")" \
--msgbox "\n\n$(translate "ProxMenux Monitor has been deactivated.")" 10 50
fi
else
if dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "Activate Monitor")" \
--yesno "\n$(translate "Do you want to activate ProxMenux Monitor?")" 8 60; then
systemctl enable "$MONITOR_SERVICE" 2>/dev/null
systemctl start "$MONITOR_SERVICE" 2>/dev/null
dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "Monitor Activated")" \
--msgbox "\n\n$(translate "ProxMenux Monitor has been activated.")" 10 50
fi
fi
}
show_monitor_status() {
clear
show_proxmenux_logo
msg_title "$(translate "ProxMenux Monitor Service Verification")"
echo ""
local status=$(check_monitor_status)
if [ "$status" = "not_installed" ]; then
msg_warn "$(translate "ProxMenux Monitor is not installed")"
echo ""
msg_info2 "$(translate "To install the monitor, reinstall ProxMenux with the latest version")"
else
msg_info2 "$(translate "Service Status"): $MONITOR_SERVICE"
echo ""
if [ "$status" = "active" ]; then
msg_ok "$(translate "Service is active and running")"
local server_ip=$(hostname -I | awk '{print $1}')
if [ -n "$server_ip" ]; then
echo -e "${TAB}${GN}🌐 $(translate "Monitor URL")${CL}: ${BL}http://${server_ip}:8008${CL}"
fi
else
msg_warn "$(translate "Service is inactive")"
fi
echo ""
msg_info2 "$(translate "Detailed service information"):"
echo ""
systemctl status "$MONITOR_SERVICE" --no-pager -l
fi
echo ""
msg_success "$(translate "Press Enter to continue...")"
read -r
}
# ==========================================================
show_config_menu() {
local install_type
@@ -62,39 +146,68 @@ show_config_menu() {
local menu_options=()
local option_actions=()
if [ "$install_type" = "translation" ]; then
menu_options+=("1" "$(translate "Change Language")")
option_actions[1]="change_language"
local monitor_status=$(check_monitor_status)
local option_num=1
if [ "$monitor_status" != "not_installed" ]; then
if [ "$monitor_status" = "active" ]; then
menu_options+=("$option_num" "$(translate "Deactivate ProxMenux Monitor")")
option_actions[$option_num]="toggle_monitor"
else
menu_options+=("$option_num" "$(translate "Activate ProxMenux Monitor")")
option_actions[$option_num]="toggle_monitor"
fi
((option_num++))
menu_options+=("2" "$(translate "Show Version Information")")
option_actions[2]="show_version_info"
menu_options+=("3" "$(translate "Uninstall ProxMenux")")
option_actions[3]="uninstall_proxmenu"
menu_options+=("4" "$(translate "Return to Main Menu")")
option_actions[4]="return_main"
else
menu_options+=("1" "Show Version Information")
option_actions[1]="show_version_info"
menu_options+=("2" "Uninstall ProxMenux")
option_actions[2]="uninstall_proxmenu"
menu_options+=("3" "Return to Main Menu")
option_actions[3]="return_main"
menu_options+=("$option_num" "$(translate "Show Monitor Service Status")")
option_actions[$option_num]="show_monitor_status"
((option_num++))
fi
# Build menu based on installation type
if [ "$install_type" = "translation" ]; then
menu_options+=("$option_num" "$(translate "Change Language")")
option_actions[$option_num]="change_language"
((option_num++))
menu_options+=("$option_num" "$(translate "Show Version Information")")
option_actions[$option_num]="show_version_info"
((option_num++))
menu_options+=("$option_num" "$(translate "Uninstall ProxMenux")")
option_actions[$option_num]="uninstall_proxmenu"
((option_num++))
menu_options+=("$option_num" "$(translate "Return to Main Menu")")
option_actions[$option_num]="return_main"
else
# Normal version (English only)
menu_options+=("$option_num" "Show Version Information")
option_actions[$option_num]="show_version_info"
((option_num++))
menu_options+=("$option_num" "Uninstall ProxMenux")
option_actions[$option_num]="uninstall_proxmenu"
((option_num++))
menu_options+=("$option_num" "Return to Main Menu")
option_actions[$option_num]="return_main"
fi
# Show menu
OPTION=$(dialog --clear --backtitle "ProxMenux Configuration" \
--title "$(translate "Configuration Menu")" \
--menu "$(translate "Select an option:")" 20 70 10 \
"${menu_options[@]}" 3>&1 1>&2 2>&3)
# Execute selected action
case "${option_actions[$OPTION]}" in
"toggle_monitor")
toggle_monitor_service
;;
"show_monitor_status")
show_monitor_status
;;
"change_language")
change_language
;;
@@ -131,7 +244,7 @@ change_language() {
return
fi
# Update language in config file
if [ -f "$CONFIG_FILE" ]; then
tmp=$(mktemp)
jq --arg lang "$new_language" '.language = $lang' "$CONFIG_FILE" > "$tmp" && mv "$tmp" "$CONFIG_FILE"
@@ -143,7 +256,7 @@ change_language() {
--title "$(translate "Language Change")" \
--msgbox "\n\n$(translate "Language changed to") $new_language" 10 50
# Reload menu with new language
TMP_FILE=$(mktemp)
curl -s "$REPO_URL/scripts/menus/config_menu.sh" > "$TMP_FILE"
chmod +x "$TMP_FILE"
@@ -164,7 +277,7 @@ show_version_info() {
info_message+="$(translate "Current ProxMenux version:") $version\n\n"
# Show installation type
info_message+="$(translate "Installation type:")\n"
if [ "$install_type" = "translation" ]; then
info_message+="$(translate "Translation Version (Multi-language support)")\n"
@@ -203,7 +316,7 @@ show_version_info() {
[ -f "$CONFIG_FILE" ] && info_message+="✓ config.json → $CONFIG_FILE\n" || info_message+="✗ config.json\n"
[ -f "$LOCAL_VERSION_FILE" ] && info_message+="✓ version.txt → $LOCAL_VERSION_FILE\n" || info_message+="✗ version.txt\n"
# Show translation-specific files
if [ "$install_type" = "translation" ]; then
[ -f "$CACHE_FILE" ] && info_message+="✓ cache.json → $CACHE_FILE\n" || info_message+="✗ cache.json\n"
@@ -222,7 +335,7 @@ show_version_info() {
info_message+="\n$(translate "Language:")\nEnglish (Fixed)\n"
fi
# Display information in a scrollable text box
tmpfile=$(mktemp)
echo -e "$info_message" > "$tmpfile"
dialog --clear --backtitle "ProxMenux Configuration" \
@@ -244,7 +357,7 @@ uninstall_proxmenu() {
local deps_to_remove=""
# Show different dependency options based on installation type
if [ "$install_type" = "translation" ]; then
deps_to_remove=$(dialog --clear --backtitle "ProxMenux Configuration" \
--title "Remove Dependencies" \
@@ -263,12 +376,12 @@ uninstall_proxmenu() {
3>&1 1>&2 2>&3)
fi
# Perform uninstallation with progress bar
(
echo "10" ; echo "Removing ProxMenu files..."
sleep 1
# Remove googletrans and virtual environment if exists
if [ -f "$VENV_PATH/bin/activate" ]; then
echo "30" ; echo "Removing googletrans and virtual environment..."
source "$VENV_PATH/bin/activate"
@@ -281,7 +394,7 @@ uninstall_proxmenu() {
rm -f "$INSTALL_DIR/$MENU_SCRIPT"
rm -rf "$BASE_DIR"
# Remove selected dependencies
if [ -n "$deps_to_remove" ]; then
echo "70" ; echo "Removing selected dependencies..."
read -r -a DEPS_ARRAY <<< "$(echo "$deps_to_remove" | tr -d '"')"
@@ -293,7 +406,7 @@ uninstall_proxmenu() {
fi
echo "90" ; echo "Restoring system files..."
# Restore .bashrc and motd
[ -f /root/.bashrc.bak ] && mv /root/.bashrc.bak /root/.bashrc
if [ -f /etc/motd.bak ]; then
mv /etc/motd.bak /etc/motd
@@ -308,7 +421,7 @@ uninstall_proxmenu() {
--title "Uninstalling ProxMenux" \
--gauge "Starting uninstallation..." 10 60 0
# Show completion message
local final_message="ProxMenux has been uninstalled successfully.\n\n"
if [ -n "$deps_to_remove" ]; then
final_message+="The following dependencies were removed:\n$deps_to_remove\n\n"
@@ -324,4 +437,4 @@ uninstall_proxmenu() {
# ==========================================================
# Main execution
show_config_menu
show_config_menu