diff --git a/meshmonitor/config.yaml b/meshmonitor/config.yaml index ee4aa94..eefff47 100644 --- a/meshmonitor/config.yaml +++ b/meshmonitor/config.yaml @@ -1,6 +1,6 @@ name: "MeshMonitor" description: "Web tool for monitoring a Meshtastic Node Deployment" -version: "3.9.5.1" +version: "3.9.5.2" slug: "meshmonitor" init: false arch: @@ -18,6 +18,14 @@ map: options: meshtastic_node_ip: "192.168.1.xxx" meshtastic_tcp_port: 4403 + admin_password: "changeme" + session_secret: "generate_a_random_string_here" + disable_anonymous: true + debug_level: "info" schema: meshtastic_node_ip: "str" - meshtastic_tcp_port: "int" \ No newline at end of file + meshtastic_tcp_port: "int" + admin_password: "str" + session_secret: "str" + disable_anonymous: "bool" + debug_level: "list(error|warn|info|debug)" \ No newline at end of file diff --git a/meshmonitor/run.sh b/meshmonitor/run.sh index 4063c4e..bba57bd 100644 --- a/meshmonitor/run.sh +++ b/meshmonitor/run.sh @@ -2,30 +2,33 @@ CONFIG_PATH=/data/options.json -# Extract options +# --- Mapping HA Options to MeshMonitor Env Vars --- export MESHTASTIC_NODE_IP=$(jq --raw-output '.meshtastic_node_ip' $CONFIG_PATH) export MESHTASTIC_TCP_PORT=$(jq --raw-output '.meshtastic_tcp_port // 4403' $CONFIG_PATH) +export ADMIN_PASSWORD=$(jq --raw-output '.admin_password // "changeme"' $CONFIG_PATH) +export SESSION_SECRET=$(jq --raw-output '.session_secret // "default_secret"' $CONFIG_PATH) +export DISABLE_ANONYMOUS=$(jq --raw-output '.disable_anonymous // true' $CONFIG_PATH) +export DEBUG_LEVEL=$(jq --raw-output '.debug_level // "info"' $CONFIG_PATH) -# Standard MeshMonitor variables +# --- Fixed Add-on Environment Settings --- export PORT=3001 export NODE_ENV=production - -# --- INGRESS SPECIFIC FIXES --- -# 1. Force the app to use relative paths for all assets +export DATABASE_PATH="/data/meshmonitor.db" +export TRUST_PROXY=true +export ALLOWED_ORIGINS="*" +export COOKIE_SECURE=false export BASE_URL="./" -# 2. Tell the Express server to trust the HA Proxy headers -export TRUST_PROXY=true +# --- Ingress Path Resolution Patch --- +# This ensures that the frontend assets (JS/CSS) are requested relative +# to the Home Assistant Ingress sub-path instead of the root IP. +echo "Applying Ingress path patches..." +find /app/dist/client -type f -name "*.html" -exec sed -i 's/src="\//src=".\//g' {} + +find /app/dist/client -type f -name "*.html" -exec sed -i 's/href="\//href=".\//g' {} + +find /app/dist/client -type f -name "*.js" -exec sed -i 's/\"\/assets\//\".\/assets\//g' {} + -# 3. Disable Secure Cookies (Ingress often fails if this is 'true' without valid SSL on the local IP) -export COOKIE_SECURE=false - -# 4. MeshMonitor specific: Allow the HA Ingress origin -export ALLOWED_ORIGINS="*" -# ------------------------------ - -echo "Starting MeshMonitor on port 3001 via Ingress..." +echo "Starting MeshMonitor on port $PORT..." +echo "Database located at $DATABASE_PATH" cd /app -# Start the server using the compiled distribution exec node dist/server/server.js \ No newline at end of file