Update setup.sh

This commit is contained in:
ilyastar9999
2025-12-02 20:28:53 +03:00
parent d229ab5519
commit c2c282e3dd

View File

@@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
# New Setuper script for A/D Infrastructure # New Setuper script for A/D Infrastructure
# Downloads Packmate, moded_distructive_farm, Firegex OUTSIDE SERVICES_DIR, starts them, then starts all game services from SERVICES_DIR, and registers only Packmate and Firegex with controller. # Downloads Packmate, moded_distructive_farm, Firegex OUTSIDE SERVICES_DIR, starts them, then starts all game services from SERVICES_DIR, and registers only Packmate and Firegex with controller.
@@ -284,14 +283,14 @@ start_game_services() {
compose_file="compose.yml" compose_file="compose.yml"
fi fi
# Extract ports from docker-compose file # Extract ports from docker-compose file (robust for quoted/unquoted, spaces)
local service_ports=$(grep -E '^\s*-\s*"?[0-9]+:[0-9]+' "$compose_file" | sed 's/.*"\?\([0-9]*\):[0-9]*.*/\1/' | tr '\n' ',' | sed 's/,$//') service_ports=$(grep -E '^[[:space:]]*-?[[:space:]]*"?[0-9]+:[0-9]+"?' "$compose_file" | sed -E 's/.*"?([0-9]+):[0-9]+"?.*/\1/' | tr '\n' ',' | sed 's/,$//')
echo "Exposed ports for $service_name: $service_ports" echo "Exposed ports for $service_name: $service_ports"
# Register service with controller and send ports, except for Firegex, farm, and packmate # Register service with controller and send ports, except for Firegex, farm, and packmate
if [[ "$service_name" != "firegex" && "$service_name" != "farm" && "$service_name" != "packmate" ]]; then if [ "$service_name" != "firegex" ] && [ "$service_name" != "farm" ] && [ "$service_name" != "packmate" ]; then
echo "Registering $service_name with controller..." echo "Registering $service_name with controller..."
local ports_json="[$service_ports]" ports_json="[$service_ports]"
ports_json=$(echo "$ports_json" | sed 's/,/,/g') ports_json=$(echo "$ports_json" | sed 's/,/,/g')
call_api "/services" "POST" "{\"name\": \"$service_name\", \"path\": \"$service_rel_path\", \"ports\": $ports_json}" call_api "/services" "POST" "{\"name\": \"$service_name\", \"path\": \"$service_rel_path\", \"ports\": $ports_json}"
else else