From ee6df7df3233367b6424f743e079c9d51bc3f7f6 Mon Sep 17 00:00:00 2001 From: ilyastar9999 Date: Tue, 2 Dec 2025 20:37:52 +0300 Subject: [PATCH] Update setup.sh --- setuper/setup.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/setuper/setup.sh b/setuper/setup.sh index 690880f..67aff9b 100644 --- a/setuper/setup.sh +++ b/setuper/setup.sh @@ -283,9 +283,9 @@ start_game_services() { compose_file="compose.yml" fi - # Get actual exposed ports from docker ps, excluding 3333, 4444, 65000, 65001, 5432 + # Get actual exposed ports from docker ps, excluding 3333, 4444, 65000, 65001, 5432, and remove duplicates container_name="${service_name}-app" - service_ports=$(docker ps --filter "name=$container_name" --format "{{.Ports}}" | grep -oE '[0-9]+->' | sed 's/->//' | grep -Ev '^(3333|4444|65000|65001|5432)$' | tr '\n' ',' | sed 's/,$//') + service_ports=$(docker ps --filter "name=$container_name" --format "{{.Ports}}" | grep -oE '[0-9]+->' | sed 's/->//' | grep -Ev '^(3333|4444|65000|65001|5432)$' | sort -u | tr '\n' ',' | sed 's/,$//') echo "Exposed ports for $service_name: $service_ports" # Register service with controller and send ports, except for Firegex, farm, and packmate @@ -327,6 +327,51 @@ start_game_services() { done fi + # If service is firegex, add and start each port using Firegex API + if [ "$service_name" = "firegex" ]; then + FIREGEX_API="http://5.129.246.129:4444/api/nfregex/services" + FIREGEX_TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRfaW4iOnRydWV9.67yI3kSfR2KvzmxmY-jwMA58Njeb0bJAgVOMg54YZXE" + FIREGEX_COOKIE="JSESSIONID=44D35DA9395B6A4EF09F6D8B27B06BD6; session=eyJsb2dnZWRfaW4iOnRydWV9.aS8Y2Q.eOgREAZvWC2mc_9TnNDzd8mAa9A" + FIREGEX_IP="5.129.246.129" + for port in $(echo "$service_ports" | tr ',' ' '); do + # Add port to Firegex + add_response=$(curl -s "$FIREGEX_API" \ + -H "Accept: */*" \ + -H "Accept-Language: ru,en;q=0.9,en-GB;q=0.8,en-US;q=0.7" \ + -H "Authorization: Bearer $FIREGEX_TOKEN" \ + -H "Cache-Control: max-age=0" \ + -H "Content-Type: application/json" \ + -b "$FIREGEX_COOKIE" \ + -H "Origin: http://$FIREGEX_IP:4444" \ + -H "Proxy-Connection: keep-alive" \ + -H "Referer: http://$FIREGEX_IP:4444/nfregex" \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" \ + --data-raw "{\"name\":\"$service_name\",\"port\":$port,\"proto\":\"tcp\",\"ip_int\":\"$FIREGEX_IP\",\"fail_open\":false}" \ + --insecure) + service_id=$(echo "$add_response" | grep -oE '"id":"[^"]+"' | sed 's/"id":"//;s/"//') + echo "Firegex add response: $add_response" + if [ -n "$service_id" ]; then + # Start service in Firegex + start_response=$(curl -s "$FIREGEX_API/$service_id/start" \ + -X "POST" \ + -H "Accept: */*" \ + -H "Accept-Language: ru,en;q=0.9,en-GB;q=0.8,en-US;q=0.7" \ + -H "Authorization: Bearer $FIREGEX_TOKEN" \ + -H "Cache-Control: max-age=0" \ + -H "Content-Length: 0" \ + -b "$FIREGEX_COOKIE" \ + -H "Origin: http://$FIREGEX_IP:4444" \ + -H "Proxy-Connection: keep-alive" \ + -H "Referer: http://$FIREGEX_IP:4444/nfregex" \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0" \ + --insecure) + echo "Firegex start response: $start_response" + else + echo "Could not parse Firegex service ID for port $port." + fi + done + fi + service_count=$((service_count + 1)) fi done