asd
This commit is contained in:
@@ -28,3 +28,9 @@ BOARD_URL=http://10.60.0.1
|
|||||||
TEAM_TOKEN=your_team_token
|
TEAM_TOKEN=your_team_token
|
||||||
NUM_TEAMS=10
|
NUM_TEAMS=10
|
||||||
IP_TEAM_BASE=10.60.
|
IP_TEAM_BASE=10.60.
|
||||||
|
|
||||||
|
# Packmate Configuration
|
||||||
|
PACKMATE_LOCAL_IP=10.60.1.2
|
||||||
|
NET_INTERFACE=eth0
|
||||||
|
PACKMATE_WEB_LOGIN=admin
|
||||||
|
PACKMATE_WEB_PASSWORD=admin123
|
||||||
137
setuper/setup.sh
137
setuper/setup.sh
@@ -66,6 +66,8 @@ setup_packmate() {
|
|||||||
BOARD_URL=$(grep '^BOARD_URL=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
BOARD_URL=$(grep '^BOARD_URL=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
PACKMATE_LOCAL_IP=$(grep '^PACKMATE_LOCAL_IP=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
PACKMATE_LOCAL_IP=$(grep '^PACKMATE_LOCAL_IP=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
NET_INTERFACE=$(grep '^NET_INTERFACE=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
NET_INTERFACE=$(grep '^NET_INTERFACE=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
|
PACKMATE_WEB_LOGIN=$(grep '^PACKMATE_WEB_LOGIN=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
|
PACKMATE_WEB_PASSWORD=$(grep '^PACKMATE_WEB_PASSWORD=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
# Defaults if not set
|
# Defaults if not set
|
||||||
if [ -z "$PACKMATE_LOCAL_IP" ]; then
|
if [ -z "$PACKMATE_LOCAL_IP" ]; then
|
||||||
PACKMATE_LOCAL_IP="10.60.1.2"
|
PACKMATE_LOCAL_IP="10.60.1.2"
|
||||||
@@ -73,14 +75,20 @@ setup_packmate() {
|
|||||||
if [ -z "$NET_INTERFACE" ]; then
|
if [ -z "$NET_INTERFACE" ]; then
|
||||||
NET_INTERFACE="eth0"
|
NET_INTERFACE="eth0"
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$PACKMATE_WEB_LOGIN" ]; then
|
||||||
|
PACKMATE_WEB_LOGIN="admin"
|
||||||
|
fi
|
||||||
|
if [ -z "$PACKMATE_WEB_PASSWORD" ]; then
|
||||||
|
PACKMATE_WEB_PASSWORD="admin123"
|
||||||
|
fi
|
||||||
# .env and config generation (minimal)
|
# .env and config generation (minimal)
|
||||||
cat > .env <<ENVEOF
|
cat > .env <<ENVEOF
|
||||||
BUILD_TAG=latest
|
BUILD_TAG=latest
|
||||||
PACKMATE_DB_PASSWORD=K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb
|
PACKMATE_DB_PASSWORD=K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb
|
||||||
NET_INTERFACE=$NET_INTERFACE
|
NET_INTERFACE=$NET_INTERFACE
|
||||||
PACKMATE_LOCAL_IP=$PACKMATE_LOCAL_IP
|
PACKMATE_LOCAL_IP=$PACKMATE_LOCAL_IP
|
||||||
WEB_LOGIN=admin
|
WEB_LOGIN=$PACKMATE_WEB_LOGIN
|
||||||
WEB_PASSWORD=admin123
|
WEB_PASSWORD=$PACKMATE_WEB_PASSWORD
|
||||||
POSTGRES_USER=packmate
|
POSTGRES_USER=packmate
|
||||||
POSTGRES_PASSWORD=K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb
|
POSTGRES_PASSWORD=K604YnL3G1hp2RDkCZNjGpxbyNpNHTRb
|
||||||
POSTGRES_DB=packmate
|
POSTGRES_DB=packmate
|
||||||
@@ -134,6 +142,8 @@ services:
|
|||||||
DCEOF
|
DCEOF
|
||||||
echo "Starting Packmate containers..."
|
echo "Starting Packmate containers..."
|
||||||
docker compose up -d --no-build
|
docker compose up -d --no-build
|
||||||
|
echo "Waiting for Packmate to be ready..."
|
||||||
|
sleep 5
|
||||||
echo "Registering Packmate with controller..."
|
echo "Registering Packmate with controller..."
|
||||||
call_api "/services" "POST" "{\"name\": \"packmate\", \"path\": \"$packmate_dir\", \"git_url\": \"https://gitlab.com/packmate/Packmate.git\"}"
|
call_api "/services" "POST" "{\"name\": \"packmate\", \"path\": \"$packmate_dir\", \"git_url\": \"https://gitlab.com/packmate/Packmate.git\"}"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -182,38 +192,23 @@ ENVEOF
|
|||||||
setup_firegex() {
|
setup_firegex() {
|
||||||
echo "=== Setting up Firegex ==="
|
echo "=== Setting up Firegex ==="
|
||||||
local firegex_dir="$ROOT_DIR/firegex"
|
local firegex_dir="$ROOT_DIR/firegex"
|
||||||
if [ -d "$firegex_dir" ]; then
|
|
||||||
echo "Firegex directory already exists, updating..."
|
|
||||||
cd "$firegex_dir"
|
|
||||||
git pull
|
|
||||||
else
|
|
||||||
echo "Cloning Firegex..."
|
|
||||||
git clone https://github.com/Pwnzer0tt1/firegex.git "$firegex_dir"
|
|
||||||
cd "$firegex_dir"
|
|
||||||
fi
|
|
||||||
# Read config from parent .env
|
# Read config from parent .env
|
||||||
BOARD_URL=$(grep '^BOARD_URL=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
BOARD_URL=$(grep '^BOARD_URL=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
TEAM_TOKEN=$(grep '^TEAM_TOKEN=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
TEAM_TOKEN=$(grep '^TEAM_TOKEN=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
cat > .env <<ENVEOF
|
|
||||||
TEAM_TOKEN=$TEAM_TOKEN
|
# Export environment variables for installer
|
||||||
SCOREBOARD_URL=$BOARD_URL
|
export SCOREBOARD_URL="$BOARD_URL"
|
||||||
FIREGEX_PORT=5000
|
export TEAM_TOKEN="$TEAM_TOKEN"
|
||||||
ENVEOF
|
export FIREGEX_PORT="5000"
|
||||||
if [ ! -f "docker-compose.yml" ]; then
|
export DOCKER_MODE="true"
|
||||||
cat > docker-compose.yml <<'DCEOF'
|
|
||||||
services:
|
mkdir -p "$firegex_dir"
|
||||||
firegex:
|
cd "$firegex_dir"
|
||||||
image: ghcr.io/pwnzer0tt1/firegex:latest
|
|
||||||
env_file:
|
echo "Installing Firegex using official installer..."
|
||||||
- .env
|
sh -c "$(curl -sLf https://pwnzer0tt1.it/firegex.sh)"
|
||||||
container_name: firegex-app
|
|
||||||
restart: always
|
|
||||||
ports:
|
|
||||||
- "5000:5000"
|
|
||||||
DCEOF
|
|
||||||
fi
|
|
||||||
echo "Starting Firegex containers..."
|
|
||||||
docker compose up -d --no-build
|
|
||||||
echo "Registering Firegex with controller..."
|
echo "Registering Firegex with controller..."
|
||||||
call_api "/services" "POST" "{\"name\": \"firegex\", \"path\": \"$firegex_dir\", \"git_url\": \"https://github.com/Pwnzer0tt1/firegex.git\"}"
|
call_api "/services" "POST" "{\"name\": \"firegex\", \"path\": \"$firegex_dir\", \"git_url\": \"https://github.com/Pwnzer0tt1/firegex.git\"}"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
@@ -222,13 +217,75 @@ DCEOF
|
|||||||
# Start all game services from SERVICES_DIR
|
# Start all game services from SERVICES_DIR
|
||||||
start_game_services() {
|
start_game_services() {
|
||||||
echo "=== Starting all game services from $SERVICES_DIR ==="
|
echo "=== Starting all game services from $SERVICES_DIR ==="
|
||||||
if [ -f "$SERVICES_DIR/docker-compose.yml" ]; then
|
|
||||||
cd "$SERVICES_DIR"
|
# Read Packmate config from .env
|
||||||
docker compose up -d
|
PACKMATE_LOCAL_IP=$(grep '^PACKMATE_LOCAL_IP=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
cd "$SCRIPT_DIR"
|
PACKMATE_WEB_LOGIN=$(grep '^PACKMATE_WEB_LOGIN=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
else
|
PACKMATE_WEB_PASSWORD=$(grep '^PACKMATE_WEB_PASSWORD=' "$ENV_FILE" | cut -d'=' -f2- | tr -d '"' | xargs)
|
||||||
echo "No docker-compose.yml found in $SERVICES_DIR, skipping game services startup."
|
if [ -z "$PACKMATE_LOCAL_IP" ]; then
|
||||||
|
PACKMATE_LOCAL_IP="10.60.1.2"
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$PACKMATE_WEB_LOGIN" ]; then
|
||||||
|
PACKMATE_WEB_LOGIN="admin"
|
||||||
|
fi
|
||||||
|
if [ -z "$PACKMATE_WEB_PASSWORD" ]; then
|
||||||
|
PACKMATE_WEB_PASSWORD="admin123"
|
||||||
|
fi
|
||||||
|
# Create base64 auth string
|
||||||
|
PACKMATE_AUTH=$(echo -n "$PACKMATE_WEB_LOGIN:$PACKMATE_WEB_PASSWORD" | base64)
|
||||||
|
|
||||||
|
# Resolve SERVICES_DIR to absolute path
|
||||||
|
if [ "${SERVICES_DIR:0:1}" != "/" ]; then
|
||||||
|
SERVICES_DIR="$ROOT_DIR/$SERVICES_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$SERVICES_DIR" ]; then
|
||||||
|
echo "Services directory $SERVICES_DIR does not exist, skipping game services startup."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Find all subdirectories with docker-compose.yml
|
||||||
|
echo "Scanning for services in $SERVICES_DIR..."
|
||||||
|
local service_count=0
|
||||||
|
|
||||||
|
for service_dir in "$SERVICES_DIR"/*/ ; do
|
||||||
|
if [ -f "$service_dir/docker-compose.yml" ]; then
|
||||||
|
service_name=$(basename "$service_dir")
|
||||||
|
echo "Starting service: $service_name"
|
||||||
|
cd "$service_dir"
|
||||||
|
docker compose up -d --no-build
|
||||||
|
|
||||||
|
# Extract ports from docker-compose.yml
|
||||||
|
local service_ports=$(grep -E '^\s*-\s*"?[0-9]+:[0-9]+' "$service_dir/docker-compose.yml" | sed 's/.*"\?\([0-9]*\):[0-9]*.*/\1/' | tr '\n' ',' | sed 's/,$//')
|
||||||
|
|
||||||
|
# Register service with controller and send ports
|
||||||
|
echo "Registering $service_name with controller..."
|
||||||
|
local ports_json="[$service_ports]"
|
||||||
|
ports_json=$(echo "$ports_json" | sed 's/,/,/g')
|
||||||
|
call_api "/services" "POST" "{\"name\": \"$service_name\", \"path\": \"$service_dir\", \"ports\": $ports_json}"
|
||||||
|
|
||||||
|
# Add service to Packmate if Packmate is running
|
||||||
|
if [ -n "$service_ports" ]; then
|
||||||
|
echo "Adding $service_name to Packmate..."
|
||||||
|
PACKMATE_URL="http://${PACKMATE_LOCAL_IP}:65000"
|
||||||
|
# Try to add each port to Packmate
|
||||||
|
IFS=',' read -ra PORTS <<< "$service_ports"
|
||||||
|
for port in "${PORTS[@]}"; do
|
||||||
|
curl -s -X POST "${PACKMATE_URL}/api/service/" \
|
||||||
|
-H "Accept: application/json" \
|
||||||
|
-H "Authorization: Basic $PACKMATE_AUTH" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"name\": \"$service_name\", \"port\": $port}" || true
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
service_count=$((service_count + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Started and registered $service_count game service(s)"
|
||||||
|
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main setup flow
|
# Main setup flow
|
||||||
@@ -239,13 +296,13 @@ main() {
|
|||||||
read -p "Setup moded_distructive_farm? (y/n): " setup_fm
|
read -p "Setup moded_distructive_farm? (y/n): " setup_fm
|
||||||
read -p "Setup Firegex? (y/n): " setup_fg
|
read -p "Setup Firegex? (y/n): " setup_fg
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$setup_pm" = "y" ]; then
|
if [ "$setup_pm" != "n" ]; then
|
||||||
setup_packmate
|
setup_packmate
|
||||||
fi
|
fi
|
||||||
if [ "$setup_fm" = "y" ]; then
|
if [ "$setup_fm" != "n" ]; then
|
||||||
setup_farm
|
setup_farm
|
||||||
fi
|
fi
|
||||||
if [ "$setup_fg" = "y" ]; then
|
if [ "$setup_fg" != "n" ]; then
|
||||||
setup_firegex
|
setup_firegex
|
||||||
fi
|
fi
|
||||||
start_game_services
|
start_game_services
|
||||||
|
|||||||
Reference in New Issue
Block a user