From ffe8f4acc62b4fbe2fdd6bfd0482c64113024440 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Mon, 29 Sep 2025 18:58:53 +0200 Subject: [PATCH] Update AppImage --- AppImage/scripts/AppRun | 41 ++++++++++++++++++ AppImage/scripts/build_appimage.sh | 67 ++++-------------------------- AppImage/scripts/flask_server.py | 51 ++++++++++++++--------- 3 files changed, 82 insertions(+), 77 deletions(-) create mode 100644 AppImage/scripts/AppRun diff --git a/AppImage/scripts/AppRun b/AppImage/scripts/AppRun new file mode 100644 index 0000000..6e6d01d --- /dev/null +++ b/AppImage/scripts/AppRun @@ -0,0 +1,41 @@ +#!/bin/bash + +# ProxMenux Monitor AppImage Entry Point +# This script is executed when the AppImage is run + +# Get the directory where this AppImage is mounted +APPDIR="$(dirname "$(readlink -f "${0}")")" + +# Set up environment +export PATH="${APPDIR}/usr/bin:${PATH}" +export LD_LIBRARY_PATH="${APPDIR}/usr/lib:${LD_LIBRARY_PATH}" + +# Change to the AppImage directory +cd "${APPDIR}" + +# Debug: Print directory structure for troubleshooting +echo "[v0] AppImage mounted at: ${APPDIR}" +echo "[v0] Contents of AppImage root:" +ls -la "${APPDIR}/" || echo "[v0] Cannot list AppImage root" + +echo "[v0] Contents of web directory:" +ls -la "${APPDIR}/web/" || echo "[v0] Web directory not found" + +echo "[v0] Looking for index.html:" +find "${APPDIR}" -name "index.html" -type f || echo "[v0] No index.html found" + +# Check for translation argument +if [[ "$1" == "--translate" ]]; then + echo "🌐 Starting ProxMenux Translation Service..." + exec python3 "${APPDIR}/scripts/translator.py" "${@:2}" +else + echo "🚀 Starting ProxMenux Monitor Dashboard..." + echo "📊 Dashboard will be available at: http://localhost:8008" + echo "🔌 API endpoints at: http://localhost:8008/api/" + echo "" + echo "Press Ctrl+C to stop the server" + echo "" + + # Start the Flask server + exec python3 "${APPDIR}/scripts/flask_server.py" +fi diff --git a/AppImage/scripts/build_appimage.sh b/AppImage/scripts/build_appimage.sh index 02ead85..0e731e8 100644 --- a/AppImage/scripts/build_appimage.sh +++ b/AppImage/scripts/build_appimage.sh @@ -229,66 +229,17 @@ else exit 1 fi -# Create AppRun script -cat > "$APP_DIR/AppRun" << 'EOF' -#!/bin/bash - -# Get the directory where this AppImage is located -HERE="$(dirname "$(readlink -f "${0}")")" - -# Set Python path -export PYTHONPATH="$HERE/usr/lib/python3/dist-packages:$PYTHONPATH" -export PATH="$HERE/usr/bin:$PATH" - -# Check if translation mode is requested -if [ "$1" = "--translate" ]; then - shift - exec python3 "$HERE/usr/bin/translate_cli.py" "$@" +# Copy AppRun script +echo "📋 Copying AppRun script..." +if [ -f "$SCRIPT_DIR/AppRun" ]; then + cp "$SCRIPT_DIR/AppRun" "$APP_DIR/AppRun" + chmod +x "$APP_DIR/AppRun" + echo "✅ AppRun script copied successfully" +else + echo "❌ Error: AppRun script not found at $SCRIPT_DIR/AppRun" + exit 1 fi -# Start Flask server in background -echo "🚀 Starting ProxMenux Monitor..." -echo "📊 Dashboard will be available at: http://localhost:8008" - -cd "$HERE" -python3 "$HERE/usr/bin/flask_server.py" & -FLASK_PID=$! - -# Function to cleanup on exit -cleanup() { - echo "🛑 Stopping ProxMenux Monitor..." - kill $FLASK_PID 2>/dev/null || true - exit 0 -} - -# Set trap for cleanup -trap cleanup SIGINT SIGTERM EXIT - -# Wait for Flask to start -sleep 3 - -# Try to open browser -if command -v xdg-open > /dev/null; then - xdg-open "http://localhost:8008" 2>/dev/null || true -elif command -v firefox > /dev/null; then - firefox "http://localhost:8008" 2>/dev/null || true -elif command -v chromium > /dev/null; then - chromium "http://localhost:8008" 2>/dev/null || true -elif command -v google-chrome > /dev/null; then - google-chrome "http://localhost:8008" 2>/dev/null || true -fi - -echo "✅ ProxMenux Monitor is running!" -echo "📝 Press Ctrl+C to stop" -echo "🌐 Access dashboard at: http://localhost:8008" -echo "🌍 Translation available with: ./ProxMenux-Monitor.AppImage --translate" - -# Keep the script running -wait $FLASK_PID -EOF - -chmod +x "$APP_DIR/AppRun" - # Create desktop file cat > "$APP_DIR/proxmenux-monitor.desktop" << EOF [Desktop Entry] diff --git a/AppImage/scripts/flask_server.py b/AppImage/scripts/flask_server.py index 497d25b..c9972c2 100644 --- a/AppImage/scripts/flask_server.py +++ b/AppImage/scripts/flask_server.py @@ -23,20 +23,28 @@ CORS(app) # Enable CORS for Next.js frontend def serve_dashboard(): """Serve the main dashboard page from Next.js build""" try: + base_dir = os.path.dirname(os.path.abspath(__file__)) + appimage_root = os.path.dirname(base_dir) # Subir un nivel desde scripts/ + index_paths = [ - os.path.join(os.path.dirname(__file__), '..', 'web', 'index.html'), # Exportación estática - os.path.join(os.path.dirname(__file__), '..', 'web', 'out', 'index.html'), # Fallback - os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'server', 'app', 'page.html'), - os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'server', 'pages', 'index.html'), - os.path.join(os.path.dirname(__file__), '..', 'web', 'dist', 'index.html') + os.path.join(appimage_root, 'web', 'index.html'), # Ruta principal para exportación estática + os.path.join(appimage_root, 'web', 'out', 'index.html'), # Fallback si está en subcarpeta + os.path.join(base_dir, '..', 'web', 'index.html'), # Ruta relativa alternativa + os.path.join(base_dir, '..', 'web', 'out', 'index.html'), # Fallback relativo ] - for index_path in index_paths: - if os.path.exists(index_path): - return send_file(index_path) + print(f"[v0] Flask server looking for index.html in:") + for path in index_paths: + abs_path = os.path.abspath(path) + exists = os.path.exists(abs_path) + print(f"[v0] {abs_path} - {'EXISTS' if exists else 'NOT FOUND'}") + if exists: + print(f"[v0] Found index.html, serving from: {abs_path}") + return send_file(abs_path) - # If no Next.js build found, return error message - return ''' + # If no Next.js build found, return error message with actual paths checked + actual_paths = [os.path.abspath(path) for path in index_paths] + return f''' ProxMenux Monitor - Build Error @@ -44,7 +52,7 @@ def serve_dashboard():

🚨 ProxMenux Monitor - Build Error

Next.js application not found. The AppImage may not have been built correctly.

Expected paths checked:

- +

API endpoints are still available: