feat: switch to local file installation and improve monitor setup

- Replaced remote file downloads with local file copying for more reliable installation
- Added proper cleanup of existing monitor service before reinstallation
- Enhanced error handling and logging for monitor service startup
- Improved SHA256 verification for monitor AppImage
- Added copying of install script and all utility scripts to base directory
- Updated progress messages to be more descriptive and accurate
- Increased monitor
This commit is contained in:
code78
2025-11-01 23:47:45 +00:00
parent 10603900df
commit 05e81053e0

96
install_proxmenux.sh Normal file → Executable file
View File

@@ -34,8 +34,8 @@
# ========================================================== # ==========================================================
# Configuration ============================================ # Configuration ============================================
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main" LOCAL_SCRIPTS="/usr/local/share/proxmenux/scripts"
UTILS_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main/scripts/utils.sh" # UTILS_URL - No longer used in local version (now loaded from ./scripts/utils.sh)
INSTALL_DIR="/usr/local/bin" INSTALL_DIR="/usr/local/bin"
BASE_DIR="/usr/local/share/proxmenux" BASE_DIR="/usr/local/share/proxmenux"
CONFIG_FILE="$BASE_DIR/config.json" CONFIG_FILE="$BASE_DIR/config.json"
@@ -51,8 +51,11 @@ MONITOR_INSTALL_PATH="$BASE_DIR/ProxMenux-Monitor.AppImage"
MONITOR_SERVICE_FILE="/etc/systemd/system/proxmenux-monitor.service" MONITOR_SERVICE_FILE="/etc/systemd/system/proxmenux-monitor.service"
MONITOR_PORT=8008 MONITOR_PORT=8008
if ! source <(curl -sSf "$UTILS_URL"); then # Load utils.sh from local repository
echo "Error: Could not load utils.sh from $UTILS_URL" if [[ -f "./scripts/utils.sh" ]]; then
source "./scripts/utils.sh"
else
echo "Error: Could not load utils.sh from local path"
exit 1 exit 1
fi fi
@@ -315,6 +318,8 @@ get_server_ip() {
} }
install_proxmenux_monitor() { install_proxmenux_monitor() {
systemctl stop proxmenux-monitor 2>/dev/null || true
# Check if URL is accessible # Check if URL is accessible
if ! wget --spider -q "$MONITOR_APPIMAGE_URL" 2>/dev/null; then if ! wget --spider -q "$MONITOR_APPIMAGE_URL" 2>/dev/null; then
msg_warn "ProxMenux Monitor AppImage not available at: $MONITOR_APPIMAGE_URL" msg_warn "ProxMenux Monitor AppImage not available at: $MONITOR_APPIMAGE_URL"
@@ -323,7 +328,7 @@ install_proxmenux_monitor() {
fi fi
# Download AppImage silently # Download AppImage silently
if ! wget -q -O "$MONITOR_INSTALL_PATH" "$MONITOR_APPIMAGE_URL" 2>&1; then if ! wget -q -O "$MONITOR_INSTALL_PATH" "$MONITOR_APPIMAGE_URL" 2>/dev/null; then
msg_warn "Failed to download ProxMenux Monitor from GitHub." msg_warn "Failed to download ProxMenux Monitor from GitHub."
msg_info "You can install it manually later when available." msg_info "You can install it manually later when available."
return 1 return 1
@@ -337,7 +342,7 @@ install_proxmenux_monitor() {
rm -f "$sha256_file" rm -f "$sha256_file"
else else
# Verify SHA256 silently # Verify SHA256 silently
local expected_hash=$(cat "$sha256_file" | awk '{print $1}') local expected_hash=$(cat "$sha256_file" | grep -Eo '^[a-f0-9]+' | tr -d '\n')
local actual_hash=$(sha256sum "$MONITOR_INSTALL_PATH" | awk '{print $1}') local actual_hash=$(sha256sum "$MONITOR_INSTALL_PATH" | awk '{print $1}')
if [ "$expected_hash" != "$actual_hash" ]; then if [ "$expected_hash" != "$actual_hash" ]; then
@@ -386,7 +391,7 @@ EOF
systemctl start proxmenux-monitor.service > /dev/null 2>&1 systemctl start proxmenux-monitor.service > /dev/null 2>&1
# Wait a moment for service to start # Wait a moment for service to start
sleep 2 sleep 3
# Check if service is running # Check if service is running
if systemctl is-active --quiet proxmenux-monitor.service; then if systemctl is-active --quiet proxmenux-monitor.service; then
@@ -394,7 +399,10 @@ EOF
update_config "proxmenux_monitor" "installed" update_config "proxmenux_monitor" "installed"
return 0 return 0
else else
msg_warn "ProxMenux Monitor service failed to start. Check logs with: journalctl -u proxmenux-monitor" msg_warn "ProxMenux Monitor service failed to start."
msg_info "Check logs with: journalctl -u proxmenux-monitor -n 20"
msg_info "Check status with: systemctl status proxmenux-monitor"
update_config "proxmenux_monitor" "failed"
return 1 return 1
fi fi
} }
@@ -404,7 +412,7 @@ install_normal_version() {
local total_steps=4 # Increased from 3 to 4 for monitor installation local total_steps=4 # Increased from 3 to 4 for monitor installation
local current_step=1 local current_step=1
show_progress $current_step $total_steps "Installing basic dependencies" show_progress $current_step $total_steps "Installing basic dependencies."
if ! dpkg -l | grep -qw "jq"; then if ! dpkg -l | grep -qw "jq"; then
msg_info "Installing jq..." msg_info "Installing jq..."
@@ -454,25 +462,21 @@ install_normal_version() {
msg_ok "Directories and configuration created." msg_ok "Directories and configuration created."
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Downloading necessary files" show_progress $current_step $total_steps "Copying necessary files"
FILES=( # Note: Previous version downloaded from GitHub, now using local files
"$UTILS_FILE $REPO_URL/scripts/utils.sh" ### Copy files from local scripts directory
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT" cp "./scripts/utils.sh" "$UTILS_FILE"
"$LOCAL_VERSION_FILE $REPO_URL/version.txt" cp "./menu" "$INSTALL_DIR/$MENU_SCRIPT"
) cp "./version.txt" "$LOCAL_VERSION_FILE"
cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh"
for file in "${FILES[@]}"; do mkdir -p "$BASE_DIR/scripts"
IFS=" " read -r dest url <<< "$file" cp -r "./scripts/"* "$BASE_DIR/scripts/"
msg_info "Downloading ${dest##*/}..." chmod -R +x "$BASE_DIR/scripts/"
sleep 2 chmod +x "$BASE_DIR/install_proxmenux.sh"
if wget -qO "$dest" "$url"; then msg_ok "Necessary files created."
msg_ok "${dest##*/} downloaded successfully." ###
else
msg_error "Failed to download ${dest##*/}. Check your Internet connection."
return 1
fi
done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT" chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
@@ -482,6 +486,8 @@ install_normal_version() {
if install_proxmenux_monitor; then if install_proxmenux_monitor; then
create_monitor_service create_monitor_service
fi fi
msg_ok "ProxMenux Normal Version installation completed successfully."
} }
#################################################### ####################################################
@@ -575,32 +581,26 @@ install_translation_version() {
deactivate deactivate
((current_step++)) ((current_step++))
show_progress $current_step $total_steps "Downloading necessary files" show_progress $current_step $total_steps "Copying necessary files"
mkdir -p "$BASE_DIR" mkdir -p "$BASE_DIR"
mkdir -p "$INSTALL_DIR" mkdir -p "$INSTALL_DIR"
FILES=( ### Copy files from local scripts directory
"$CACHE_FILE $REPO_URL/json/cache.json" cp "./json/cache.json" "$CACHE_FILE"
"$UTILS_FILE $REPO_URL/scripts/utils.sh" msg_ok "Cache file copied with translations."
"$INSTALL_DIR/$MENU_SCRIPT $REPO_URL/$MENU_SCRIPT"
"$LOCAL_VERSION_FILE $REPO_URL/version.txt"
)
for file in "${FILES[@]}"; do cp "./scripts/utils.sh" "$UTILS_FILE"
IFS=" " read -r dest url <<< "$file" cp "./menu" "$INSTALL_DIR/$MENU_SCRIPT"
msg_info "Downloading ${dest##*/}..." cp "./version.txt" "$LOCAL_VERSION_FILE"
sleep 2 cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh"
if wget -qO "$dest" "$url"; then
msg_ok "${dest##*/} downloaded successfully." mkdir -p "$BASE_DIR/scripts"
if [[ "$dest" == "$CACHE_FILE" ]]; then cp -r "./scripts/"* "$BASE_DIR/scripts/"
msg_ok "Cache file updated with latest translations." chmod -R +x "$BASE_DIR/scripts/"
fi chmod +x "$BASE_DIR/install_proxmenux.sh"
else msg_ok "Necessary files created."
msg_error "Failed to download ${dest##*/}. Check your Internet connection." ###
return 1
fi
done
chmod +x "$INSTALL_DIR/$MENU_SCRIPT" chmod +x "$INSTALL_DIR/$MENU_SCRIPT"
@@ -610,6 +610,8 @@ install_translation_version() {
if install_proxmenux_monitor; then if install_proxmenux_monitor; then
create_monitor_service create_monitor_service
fi fi
msg_ok "ProxMenux Translation Version installation completed successfully."
} }
#################################################### ####################################################