Core tests / core (push) Successful in 9m57s
Full verification / application (push) Failing after 5m16s
Full verification / local-brain (push) Failing after 6m15s
Realm simulation / simulated-live-world (push) Failing after 5m32s
WoW integration lab / real-worldserver (push) Canceled after 17m23s
Source branch: feature/ai-brain-router Source commit: c2a09e0460465201a58aaab56c71424e9a96405e
334 lines
12 KiB
Bash
334 lines
12 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
LAB_ROOT="${AZEROTHAI_PLAYABLE_ROOT:-$HOME/azerothai-playable}"
|
|
ACORE_ROOT="$LAB_ROOT/azerothcore"
|
|
RUNTIME_ENV="$LAB_ROOT/runtime.env"
|
|
DB_PASSWORD="${DOCKER_DB_ROOT_PASSWORD:-azerothai-local}"
|
|
AUTONOMOUS_BOT_COUNT="${AZEROTHAI_RANDOM_BOTS:-10}"
|
|
|
|
need(){ command -v "$1" >/dev/null 2>&1 || { echo "Missing required command: $1" >&2; exit 1; }; }
|
|
need git
|
|
need docker
|
|
need openssl
|
|
need python3
|
|
need curl
|
|
need jq
|
|
need unzip
|
|
docker compose version >/dev/null
|
|
|
|
detect_address(){
|
|
if command -v tailscale >/dev/null 2>&1; then
|
|
local ts
|
|
ts="$(tailscale ip -4 2>/dev/null | head -n1 || true)"
|
|
if [[ -n "$ts" ]]; then printf '%s' "$ts"; return; fi
|
|
fi
|
|
hostname -I 2>/dev/null | tr ' ' '\n' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$' | head -n1 || true
|
|
}
|
|
|
|
REALM_ADDRESS="${REALM_ADDRESS:-$(detect_address)}"
|
|
if [[ -z "$REALM_ADDRESS" ]]; then
|
|
echo "Could not determine a LAN/Tailscale IPv4 address. Re-run with REALM_ADDRESS=10.x.x.x" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! "$REALM_ADDRESS" =~ ^[A-Za-z0-9.-]+$ ]]; then
|
|
echo "REALM_ADDRESS must be an IPv4 address or simple hostname." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$LAB_ROOT"
|
|
chmod 700 "$LAB_ROOT"
|
|
|
|
if [[ -f "$RUNTIME_ENV" ]]; then
|
|
# shellcheck disable=SC1090
|
|
source "$RUNTIME_ENV"
|
|
else
|
|
ALE_BRIDGE_TOKEN="$(openssl rand -hex 32)"
|
|
ALE_OPERATOR_TOKEN="$(openssl rand -hex 32)"
|
|
AUTONOMY_TOKEN="$(openssl rand -hex 32)"
|
|
cat > "$RUNTIME_ENV" <<EOF
|
|
ALE_BRIDGE_TOKEN=$ALE_BRIDGE_TOKEN
|
|
ALE_OPERATOR_TOKEN=$ALE_OPERATOR_TOKEN
|
|
AUTONOMY_TOKEN=$AUTONOMY_TOKEN
|
|
DOCKER_DB_ROOT_PASSWORD=$DB_PASSWORD
|
|
EOF
|
|
chmod 600 "$RUNTIME_ENV"
|
|
fi
|
|
|
|
: "${ALE_BRIDGE_TOKEN:?Missing ALE_BRIDGE_TOKEN}"
|
|
: "${ALE_OPERATOR_TOKEN:?Missing ALE_OPERATOR_TOKEN}"
|
|
if [[ -z "${AUTONOMY_TOKEN:-}" ]]; then
|
|
AUTONOMY_TOKEN="$(openssl rand -hex 32)"
|
|
printf '\nAUTONOMY_TOKEN=%s\n' "$AUTONOMY_TOKEN" >> "$RUNTIME_ENV"
|
|
chmod 600 "$RUNTIME_ENV"
|
|
fi
|
|
|
|
echo "==> Preparing AzerothAI dashboard"
|
|
cd "$REPO_ROOT"
|
|
if command -v corepack >/dev/null 2>&1; then corepack enable >/dev/null 2>&1 || true; fi
|
|
need node
|
|
need pnpm
|
|
pnpm install --frozen-lockfile
|
|
pnpm build
|
|
node --import ./scripts/sites-env.mjs ./node_modules/wrangler/bin/wrangler.js d1 execute DB --local --config dist/server/wrangler.json --persist-to .wrangler/state --file drizzle/0000_old_deathbird.sql >/dev/null 2>&1 || true
|
|
|
|
python3 - "$REPO_ROOT/.dev.vars" "$ALE_BRIDGE_TOKEN" "$ALE_OPERATOR_TOKEN" "$AUTONOMY_TOKEN" <<'PY'
|
|
from pathlib import Path
|
|
import sys
|
|
p=Path(sys.argv[1])
|
|
updates={
|
|
"ALE_BRIDGE_TOKEN":sys.argv[2],
|
|
"ALE_OPERATOR_TOKEN":sys.argv[3],
|
|
"AUTONOMY_TOKEN":sys.argv[4],
|
|
"ALE_RAW_EXEC_ENABLED":"true",
|
|
"LLM_URL":"http://127.0.0.1:11434",
|
|
"SOAP_URL":"http://127.0.0.1:7878",
|
|
}
|
|
lines=p.read_text().splitlines() if p.exists() else []
|
|
seen=set()
|
|
out=[]
|
|
for line in lines:
|
|
if "=" in line and not line.lstrip().startswith("#"):
|
|
key=line.split("=",1)[0].strip()
|
|
if key in updates:
|
|
out.append(f"{key}={updates[key]}")
|
|
seen.add(key)
|
|
continue
|
|
out.append(line)
|
|
for key,value in updates.items():
|
|
if key not in seen:
|
|
out.append(f"{key}={value}")
|
|
p.write_text("\n".join(out).rstrip()+"\n")
|
|
PY
|
|
chmod 600 "$REPO_ROOT/.dev.vars"
|
|
|
|
if [[ -f "$LAB_ROOT/azerothai.pid" ]] && kill -0 "$(cat "$LAB_ROOT/azerothai.pid")" 2>/dev/null; then
|
|
echo "AzerothAI dashboard already running."
|
|
else
|
|
nohup pnpm start:lan >"$LAB_ROOT/azerothai.log" 2>&1 &
|
|
echo $! > "$LAB_ROOT/azerothai.pid"
|
|
fi
|
|
|
|
for _ in {1..60}; do
|
|
if curl -fsS http://127.0.0.1:8787/api/health >/dev/null 2>&1; then break; fi
|
|
sleep 1
|
|
done
|
|
curl -fsS http://127.0.0.1:8787/api/health >/dev/null || {
|
|
echo "AzerothAI did not start. See $LAB_ROOT/azerothai.log" >&2
|
|
exit 1
|
|
}
|
|
|
|
echo "==> Preparing Playerbots AzerothCore"
|
|
if [[ ! -d "$ACORE_ROOT/.git" ]]; then
|
|
git clone --depth 1 --branch Playerbot https://github.com/mod-playerbots/azerothcore-wotlk.git "$ACORE_ROOT"
|
|
else
|
|
git -C "$ACORE_ROOT" fetch --depth 1 origin Playerbot
|
|
git -C "$ACORE_ROOT" checkout -f FETCH_HEAD
|
|
fi
|
|
|
|
mkdir -p "$ACORE_ROOT/modules"
|
|
if [[ ! -d "$ACORE_ROOT/modules/mod-playerbots/.git" ]]; then
|
|
git clone --depth 1 --branch master https://github.com/mod-playerbots/mod-playerbots.git "$ACORE_ROOT/modules/mod-playerbots"
|
|
else
|
|
git -C "$ACORE_ROOT/modules/mod-playerbots" pull --ff-only
|
|
fi
|
|
if [[ ! -d "$ACORE_ROOT/modules/mod-ale/.git" ]]; then
|
|
git clone --depth 1 https://github.com/azerothcore/mod-ale.git "$ACORE_ROOT/modules/mod-ale"
|
|
else
|
|
git -C "$ACORE_ROOT/modules/mod-ale" pull --ff-only
|
|
fi
|
|
|
|
mkdir -p "$ACORE_ROOT/azerothai-lua"
|
|
cp "$REPO_ROOT/ale/azerothai_bridge.lua" "$ACORE_ROOT/azerothai-lua/azerothai_bridge.lua"
|
|
python3 - "$ACORE_ROOT/azerothai-lua/azerothai_bridge.lua" <<'PY'
|
|
from pathlib import Path
|
|
import sys
|
|
p=Path(sys.argv[1])
|
|
s=p.read_text()
|
|
s=s.replace('local POLL_MS = tonumber(GetConfigValue("AzerothAI.PollMs")) or 750','local POLL_MS = 750')
|
|
s=s.replace('local PROTECTED = GetConfigValue("AzerothAI.ProtectedCharacter")','local PROTECTED = "Zaku"')
|
|
p.write_text(s)
|
|
PY
|
|
|
|
cat > "$ACORE_ROOT/docker-compose.override.yml" <<YAML
|
|
services:
|
|
ac-worldserver:
|
|
extra_hosts:
|
|
- "host.docker.internal:host-gateway"
|
|
environment:
|
|
AC_SOAP_ENABLED: "1"
|
|
AC_SOAP_IP: "0.0.0.0"
|
|
AC_ALE_ENABLED: "1"
|
|
AC_ALE_TRACEBACK: "1"
|
|
AC_ALE_SCRIPTPATH: "lua_scripts"
|
|
AC_AI_PLAYERBOT_ENABLED: "1"
|
|
AC_AI_PLAYERBOT_RANDOM_BOT_AUTOLOGIN: "1"
|
|
AC_AI_PLAYERBOT_MIN_RANDOM_BOTS: "$AUTONOMOUS_BOT_COUNT"
|
|
AC_AI_PLAYERBOT_MAX_RANDOM_BOTS: "$AUTONOMOUS_BOT_COUNT"
|
|
AC_AI_PLAYERBOT_DISABLED_WITHOUT_REAL_PLAYER: "0"
|
|
AC_AI_PLAYERBOT_BOT_ACTIVE_ALONE: "100"
|
|
AC_AI_PLAYERBOT_BOT_ACTIVE_ALONE_SMART_SCALE: "0"
|
|
AC_AI_PLAYERBOT_RANDOM_BOTS_PER_INTERVAL: "12"
|
|
AC_AI_PLAYERBOT_AUTO_DO_QUESTS: "1"
|
|
AC_AI_PLAYERBOT_ENABLE_NEW_RPG_STRATEGY: "1"
|
|
AC_AI_PLAYERBOT_MIN_RANDOM_BOT_RANDOMIZE_TIME: "31104000"
|
|
AC_AI_PLAYERBOT_MAX_RANDOM_BOT_RANDOMIZE_TIME: "31104000"
|
|
AC_AI_PLAYERBOT_MIN_RANDOM_BOT_TELEPORT_INTERVAL: "31104000"
|
|
AC_AI_PLAYERBOT_MAX_RANDOM_BOT_TELEPORT_INTERVAL: "31104000"
|
|
AC_AI_PLAYERBOT_PERMANENTLY_IN_WORLD_TIME: "31104000"
|
|
AC_AI_PLAYERBOT_RANDOM_BOT_TALK: "1"
|
|
AC_AI_PLAYERBOT_RANDOM_BOT_EMOTE: "1"
|
|
AC_AI_PLAYERBOT_RANDOM_BOT_SAY_WITHOUT_MASTER: "1"
|
|
AC_AI_PLAYERBOT_RANDOM_BOT_JOIN_LFG: "1"
|
|
volumes:
|
|
- ./azerothai-lua:/azerothcore/lua_scripts:ro
|
|
- ./modules/mod-playerbots:/azerothcore/modules/mod-playerbots:ro
|
|
YAML
|
|
|
|
mkdir -p "$LAB_ROOT/client-data" "$LAB_ROOT/etc" "$LAB_ROOT/logs"
|
|
chmod 777 "$LAB_ROOT/client-data" "$LAB_ROOT/etc" "$LAB_ROOT/logs"
|
|
|
|
cat > "$ACORE_ROOT/.env" <<EOF
|
|
DOCKER_DB_ROOT_PASSWORD=$DB_PASSWORD
|
|
DOCKER_AUTH_EXTERNAL_PORT=3724
|
|
DOCKER_WORLD_EXTERNAL_PORT=8085
|
|
DOCKER_SOAP_EXTERNAL_PORT=127.0.0.1:7878
|
|
DOCKER_VOL_DATA=$LAB_ROOT/client-data
|
|
DOCKER_VOL_ETC=$LAB_ROOT/etc
|
|
DOCKER_VOL_LOGS=$LAB_ROOT/logs
|
|
EOF
|
|
|
|
echo "==> Building real WoW server (first build can take a while)"
|
|
cd "$ACORE_ROOT"
|
|
docker compose build ac-client-data-init ac-db-import ac-authserver ac-worldserver
|
|
docker compose up -d ac-database
|
|
|
|
echo "==> Waiting for database"
|
|
for _ in {1..120}; do
|
|
if docker exec ac-database mysqladmin ping -uroot -p"$DB_PASSWORD" --silent >/dev/null 2>&1; then break; fi
|
|
sleep 2
|
|
done
|
|
docker exec ac-database mysqladmin ping -uroot -p"$DB_PASSWORD" --silent >/dev/null
|
|
|
|
echo "==> Starting durable ALE relay before worldserver"
|
|
AZEROTHAI_PLAYABLE_ROOT="$LAB_ROOT" bash "$REPO_ROOT/deploy/playable/install-ale-relay-service.sh"
|
|
|
|
echo "==> Loading AzerothCore client data"
|
|
set +e
|
|
docker compose up --no-deps ac-client-data-init
|
|
CLIENT_DATA_RC=$?
|
|
set -e
|
|
if [[ "$CLIENT_DATA_RC" -ne 0 || ! -d "$LAB_ROOT/client-data/dbc" || ! -d "$LAB_ROOT/client-data/maps" ]]; then
|
|
echo "Official client-data initializer did not complete; applying fallback client data package."
|
|
rm -rf "$LAB_ROOT/client-data"/*
|
|
ASSET_URL="$(curl -fsSL https://api.github.com/repos/wowgaming/client-data/releases/latest | jq -r '.assets[] | select(.name=="Data.zip" or .name=="data.zip") | .browser_download_url' | head -1)"
|
|
if [[ -z "$ASSET_URL" || "$ASSET_URL" == "null" ]]; then
|
|
echo "Could not locate fallback client data archive." >&2
|
|
exit 1
|
|
fi
|
|
curl -fL --retry 3 "$ASSET_URL" -o "$LAB_ROOT/client-data.zip"
|
|
unzip -q "$LAB_ROOT/client-data.zip" -d "$LAB_ROOT/client-data"
|
|
rm -f "$LAB_ROOT/client-data.zip"
|
|
fi
|
|
test -d "$LAB_ROOT/client-data/dbc"
|
|
test -d "$LAB_ROOT/client-data/maps"
|
|
|
|
echo "==> Importing AzerothCore databases"
|
|
docker compose up --no-deps --abort-on-container-exit --exit-code-from ac-db-import ac-db-import
|
|
|
|
echo "==> Updating realm address"
|
|
for _ in {1..180}; do
|
|
if docker exec ac-database mysql -uroot -p"$DB_PASSWORD" -Nse "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='acore_auth' AND table_name='realmlist'" 2>/dev/null | grep -q '^1$'; then
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
docker exec ac-database mysql -uroot -p"$DB_PASSWORD" -Nse "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='acore_auth' AND table_name='realmlist'" | grep -q '^1$'
|
|
docker exec ac-database mysql -uroot -p"$DB_PASSWORD" acore_auth -e "UPDATE realmlist SET name='AzerothAI Lab', address='$REALM_ADDRESS', port=8085 WHERE id=1;"
|
|
|
|
echo "==> Starting authserver and worldserver"
|
|
docker compose up -d --no-deps ac-authserver
|
|
docker compose up -d --no-deps ac-worldserver
|
|
|
|
tcp_open(){
|
|
(echo >/dev/tcp/127.0.0.1/"$1") >/dev/null 2>&1
|
|
}
|
|
|
|
echo "==> Waiting for worldserver"
|
|
for _ in {1..180}; do
|
|
STATE="$(docker inspect --format='{{.State.Status}}' ac-worldserver 2>/dev/null || true)"
|
|
if [[ "$STATE" == "exited" || "$STATE" == "dead" ]]; then
|
|
docker compose logs --tail=250 ac-worldserver >&2 || true
|
|
exit 1
|
|
fi
|
|
if tcp_open 8085; then
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
if ! tcp_open 8085; then
|
|
docker compose logs --tail=250 ac-worldserver >&2 || true
|
|
echo "Worldserver did not open TCP 8085." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Waiting for authserver"
|
|
for _ in {1..90}; do
|
|
if tcp_open 3724; then
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
if ! tcp_open 3724; then
|
|
docker compose logs --tail=200 ac-authserver >&2 || true
|
|
echo "Authserver did not open TCP 3724." >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Waiting for ALE bridge heartbeat"
|
|
ALE_READY=0
|
|
for _ in {1..90}; do
|
|
if curl -fsS http://127.0.0.1:8787/api/world-monitor 2>/dev/null | jq -e '.ale.bridgeReady == true and .ale.activeRecently == true' >/dev/null 2>&1; then
|
|
ALE_READY=1
|
|
break
|
|
fi
|
|
sleep 2
|
|
done
|
|
if [[ "$ALE_READY" -ne 1 ]]; then
|
|
echo "Worldserver is running, but AzerothAI has not received a fresh ALE bridge.ready heartbeat." >&2
|
|
docker compose logs --tail=250 ac-worldserver >&2 || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Enabling persistent autonomous Playerbots and AzerothAI heartbeat"
|
|
AZEROTHAI_PLAYABLE_ROOT="$LAB_ROOT" AZEROTHAI_RANDOM_BOTS="$AUTONOMOUS_BOT_COUNT" bash "$REPO_ROOT/deploy/playable/enable-autonomous-world.sh"
|
|
|
|
echo
|
|
echo "============================================================"
|
|
echo " AzerothAI playable lab is LIVE"
|
|
echo "============================================================"
|
|
echo "Realm address : $REALM_ADDRESS"
|
|
echo "Dashboard : http://$REALM_ADDRESS:8787"
|
|
echo "Auth port : 3724/tcp"
|
|
echo "World port : 8085/tcp"
|
|
echo
|
|
echo "Next, create your account using the official worldserver console:"
|
|
echo " cd $ACORE_ROOT"
|
|
echo " docker attach ac-worldserver"
|
|
echo
|
|
echo "Then enter:"
|
|
echo " account create <USERNAME> <PASSWORD>"
|
|
echo " account set gmlevel <USERNAME> 3 -1"
|
|
echo
|
|
echo "Detach WITHOUT stopping worldserver: Ctrl-P then Ctrl-Q"
|
|
echo "Then connect that GM account to AzerothAI:"
|
|
echo " bash $REPO_ROOT/deploy/playable/set-gm-credentials.sh <USERNAME> <PASSWORD>"
|
|
echo
|
|
echo "In your WoW 3.3.5a client Data/enUS/realmlist.wtf use:"
|
|
echo " set realmlist $REALM_ADDRESS"
|
|
echo
|
|
echo "Logs:"
|
|
echo " AzerothAI : $LAB_ROOT/azerothai.log"
|
|
echo " WoW : cd $ACORE_ROOT && docker compose logs -f ac-worldserver"
|