From 2bb7ad6959b37f01b95b739b5d80602e40b188a3 Mon Sep 17 00:00:00 2001 From: Ultradesu Date: Mon, 8 Dec 2025 17:36:28 +0200 Subject: [PATCH] Reworked pasarguard nodes daemonset. --- .../pasarguard/configmap-scripts-ingress.yaml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml b/k8s/apps/pasarguard/configmap-scripts-ingress.yaml index c437f76..3ab93c3 100644 --- a/k8s/apps/pasarguard/configmap-scripts-ingress.yaml +++ b/k8s/apps/pasarguard/configmap-scripts-ingress.yaml @@ -251,15 +251,31 @@ data: ./main & MAIN_PID=$! + # Detect xray API port BEFORE starting monitoring loop + echo "Detecting xray API port..." + for i in $(seq 1 60); do + API_PORT=$(netstat -tlpn 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) + if [ -n "$API_PORT" ]; then + echo "Found xray API port: $API_PORT" + echo -n "$API_PORT" > /shared/xray-api-port + break + fi + echo "Waiting for xray to start... ($i/60)" + sleep 1 + done + + if [ -z "$API_PORT" ]; then + echo "WARNING: Could not detect xray API port after 60 seconds" + fi + # Start continuous port monitoring in background { - sleep 10 # Wait for xray to start initially - LAST_PORT="" + LAST_PORT="$API_PORT" while true; do - API_PORT=$(netstat -tlpn | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) + API_PORT=$(netstat -tlpn 2>/dev/null | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) if [ -n "$API_PORT" ] && [ "$API_PORT" != "$LAST_PORT" ]; then - echo "Found xray API port: $API_PORT" + echo "API port changed from $LAST_PORT to $API_PORT" echo -n "$API_PORT" > /shared/xray-api-port LAST_PORT="$API_PORT" fi