mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-10-02 16:16:19 +00:00
Update AppImage
This commit is contained in:
41
AppImage/scripts/AppRun
Normal file
41
AppImage/scripts/AppRun
Normal file
@@ -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
|
@@ -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]
|
||||
|
@@ -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'''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>ProxMenux Monitor - Build Error</title></head>
|
||||
@@ -44,7 +52,7 @@ def serve_dashboard():
|
||||
<h1>🚨 ProxMenux Monitor - Build Error</h1>
|
||||
<p>Next.js application not found. The AppImage may not have been built correctly.</p>
|
||||
<p>Expected paths checked:</p>
|
||||
<ul>''' + ''.join([f'<li>{path}</li>' for path in index_paths]) + '''</ul>
|
||||
<ul>{''.join([f'<li>{path}</li>' for path in actual_paths])}</ul>
|
||||
<p>API endpoints are still available:</p>
|
||||
<ul>
|
||||
<li><a href="/api/system" style="color: #4f46e5;">/api/system</a></li>
|
||||
@@ -128,10 +136,13 @@ def serve_sw():
|
||||
def serve_next_static(filename):
|
||||
"""Serve Next.js static files"""
|
||||
try:
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
appimage_root = os.path.dirname(base_dir)
|
||||
|
||||
static_paths = [
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', '_next'), # Exportación estática
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', 'out', '_next'), # Fallback
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'static')
|
||||
os.path.join(appimage_root, 'web', '_next'), # Ruta principal
|
||||
os.path.join(appimage_root, 'web', 'out', '_next'), # Fallback
|
||||
os.path.join(base_dir, '..', 'web', '_next'), # Ruta relativa
|
||||
]
|
||||
|
||||
for static_dir in static_paths:
|
||||
@@ -147,12 +158,14 @@ def serve_next_static(filename):
|
||||
def serve_static_files(filename):
|
||||
"""Serve static files (icons, etc.)"""
|
||||
try:
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
appimage_root = os.path.dirname(base_dir)
|
||||
|
||||
public_paths = [
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web'), # Raíz web para exportación estática
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', 'out'), # Fallback
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', 'public'),
|
||||
os.path.join(os.path.dirname(__file__), '..', 'public'),
|
||||
os.path.join(os.path.dirname(__file__), '..', 'web', '.next', 'static')
|
||||
os.path.join(appimage_root, 'web'), # Raíz web para exportación estática
|
||||
os.path.join(appimage_root, 'web', 'out'), # Fallback
|
||||
os.path.join(base_dir, '..', 'web'), # Ruta relativa
|
||||
os.path.join(base_dir, '..', 'web', 'out'), # Fallback relativo
|
||||
]
|
||||
|
||||
for public_dir in public_paths:
|
||||
|
Reference in New Issue
Block a user