From d8696d2ab448744bb3e429a615b4f0311eead91f Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Fri, 24 Oct 2025 22:49:44 -0400 Subject: [PATCH] cleanup: Update paths and builds --- .env.template | 15 +-- .gitignore | 2 +- README.md | 6 +- cleanup.sh | 10 +- deploy.sh | 10 +- compose.yml => docker-compose.yml | 4 +- scripts/deploy-tools.sh | 2 +- scripts/manage-modules.sh | 37 ++++--- scripts/migrate-stack.sh | 7 +- scripts/rebuild-with-modules.sh | 27 ++++- scripts/setup-source.sh | 59 ++++++----- setup.sh | 164 +++++++++++++++++++++++++++--- verify-deployment.sh | 4 +- 13 files changed, 261 insertions(+), 86 deletions(-) rename compose.yml => docker-compose.yml (99%) diff --git a/.env.template b/.env.template index 26af028..d51a498 100644 --- a/.env.template +++ b/.env.template @@ -1,5 +1,5 @@ # Copy this file to .env and adjust values for your environment. -# Docker Compose will auto-load .env in the same folder as compose.yml. +# Docker Compose will auto-load .env in the same folder as docker-compose.yml. # Template for acore-compose profiles-based compose # Project name @@ -9,6 +9,7 @@ COMPOSE_PROJECT_NAME=acore-compose # Storage & Timezone # ===================== STORAGE_PATH=./storage +STORAGE_PATH_LOCAL=./local-storage HOST_ZONEINFO_PATH=/usr/share/zoneinfo TZ=UTC @@ -57,7 +58,7 @@ AC_WORLDSERVER_IMAGE_PLAYERBOTS=uprightbass360/azerothcore-wotlk-playerbots:worl AC_CLIENT_DATA_IMAGE=acore/ac-wotlk-client-data:14.0.0-dev AC_CLIENT_DATA_IMAGE_PLAYERBOTS=uprightbass360/azerothcore-wotlk-playerbots:client-data-Playerbot CLIENT_DATA_VERSION=v17 -CLIENT_DATA_CACHE_PATH=./client-data-cache +CLIENT_DATA_CACHE_PATH=${STORAGE_PATH_LOCAL:-./local-storage}/client-data-cache CLIENT_DATA_VOLUME=ac-client-data # ===================== @@ -81,14 +82,8 @@ REALM_PORT=8215 # ===================== PLAYERBOT_ENABLED=0 PLAYERBOT_MAX_BOTS=40 - -# ===================== -# Git for ac-modules (optional) -# ===================== - -# Playerbot runtime flags PLAYERBOT_ENABLED=0 -PLAYERBOT_MAX_BOTS=40 +PLAYERBOT_MAX_BOTS=1000 # ===================== # Module toggles (0/1) @@ -153,7 +148,7 @@ MODULE_BLACK_MARKET_AUCTION_HOUSE=0 # ===================== AUTO_REBUILD_ON_DEPLOY=0 # Default AzerothCore source checkout used for module rebuilds -MODULES_REBUILD_SOURCE_PATH=./source/azerothcore +MODULES_REBUILD_SOURCE_PATH=${STORAGE_PATH_LOCAL:-./local-storage}/source/azerothcore # ===================== # Eluna runtime (worldserver.conf overrides) diff --git a/.gitignore b/.gitignore index 36ebf77..3f62a5e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ source/* local-data-tools/ storage/ source/ +local-storage/ .claude/ images/ node_modules/ @@ -14,4 +15,3 @@ node_modules/ .env package-lock.json package.json - diff --git a/README.md b/README.md index c2b014d..01fdb98 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ Use this workflow to build locally, then push the same stack to a remote host: --user sam \ --project-dir /home/sam/src/acore-compose ``` - (Exports rebuilt images to `images/acore-modules-images.tar`, including both `acore/...:modules-latest` and `uprightbass360/...:Playerbot` tags, then syncs `storage/` unless `--skip-storage` is provided.) + (Exports rebuilt images to `local-storage/images/acore-modules-images.tar`, including both `acore/...:modules-latest` and `uprightbass360/...:Playerbot` tags, then syncs `storage/` unless `--skip-storage` is provided.) 3. **Deploy on Remote Host** ```bash ssh docker-server ' @@ -328,7 +328,7 @@ storage/ └── backups/ # Automated database backups ``` -`ac-client-data` keeps unpacked game assets in the `${CLIENT_DATA_VOLUME:-ac-client-data}` Docker volume so reads stay on the local host, while download archives are cached under `${CLIENT_DATA_CACHE_PATH:-./client-data-cache}` on fast local storage even when `${STORAGE_PATH}` points to remote or NFS storage. +`ac-client-data` keeps unpacked game assets in the `${CLIENT_DATA_VOLUME:-ac-client-data}` Docker volume so reads stay on the local host, while download archives are cached under `${CLIENT_DATA_CACHE_PATH}` on fast local storage even when `${STORAGE_PATH}` points to remote or NFS storage. --- @@ -712,7 +712,7 @@ docker logs ac-db-import docker logs ac-modules | grep -A20 -B5 "rebuild" # Verify source path exists -ls -la ./source/azerothcore/ +ls -la "${STORAGE_PATH_LOCAL:-./local-storage}/source/azerothcore/" # Force source setup ./scripts/setup-source.sh diff --git a/cleanup.sh b/cleanup.sh index b903946..1d722e0 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -11,7 +11,7 @@ set -e # Resolve project dir and compose SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="${SCRIPT_DIR}" -COMPOSE_FILE="${PROJECT_DIR}/compose.yml" +COMPOSE_FILE="${PROJECT_DIR}/docker-compose.yml" ENV_FILE="${PROJECT_DIR}/.env" # Colors @@ -120,10 +120,12 @@ show_resources() { # Load env for STORAGE_PATH etc. STORAGE_PATH_DEFAULT="${PROJECT_DIR}/storage" +STORAGE_PATH_LOCAL_DEFAULT="${PROJECT_DIR}/local-storage" if [ -f "$ENV_FILE" ]; then set -a; source "$ENV_FILE"; set +a fi STORAGE_PATH="${STORAGE_PATH:-$STORAGE_PATH_DEFAULT}" +STORAGE_PATH_LOCAL="${STORAGE_PATH_LOCAL:-$STORAGE_PATH_LOCAL_DEFAULT}" PROJECT_NAME="${COMPOSE_PROJECT_NAME:-ac-compose}" remove_storage_dir(){ @@ -211,13 +213,15 @@ nuclear_cleanup() { if [ -d "${STORAGE_PATH}/backups" ]; then execute_command "Staging backups" "mkdir -p '${TMP_PRESERVE}' && cp -a '${STORAGE_PATH}/backups' '${TMP_PRESERVE}/'" fi - execute_command "Removing storage" "remove_storage_dir '${STORAGE_PATH}'" + execute_command "Removing main storage" "remove_storage_dir '${STORAGE_PATH}'" + execute_command "Removing local storage" "remove_storage_dir '${STORAGE_PATH_LOCAL}'" if [ -d "${TMP_PRESERVE}/backups" ]; then execute_command "Restoring backups" "mkdir -p '${STORAGE_PATH}' && mv '${TMP_PRESERVE}/backups' '${STORAGE_PATH}/backups' && rm -rf '${TMP_PRESERVE}'" print_status SUCCESS "Backups preserved at ${STORAGE_PATH}/backups" fi else - execute_command "Removing storage and local backups" "remove_storage_dir '${STORAGE_PATH}'; remove_storage_dir '${PROJECT_DIR}/backups'" + execute_command "Removing main storage and backups" "remove_storage_dir '${STORAGE_PATH}'; remove_storage_dir '${PROJECT_DIR}/backups'" + execute_command "Removing local storage" "remove_storage_dir '${STORAGE_PATH_LOCAL}'" fi # Optional system prune for project context diff --git a/deploy.sh b/deploy.sh index 7467369..0ca6647 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,7 +9,7 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -COMPOSE_FILE="$ROOT_DIR/compose.yml" +COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" ENV_PATH="$ROOT_DIR/.env" TARGET_PROFILE="" WATCH_LOGS=1 @@ -111,9 +111,13 @@ compose(){ ensure_source_repo(){ local module_playerbots module_playerbots="$(read_env MODULE_PLAYERBOTS "0")" - local default_source="./source/azerothcore" + local local_root + local_root="$(read_env STORAGE_PATH_LOCAL "./local-storage")" + local_root="${local_root%/}" + [ -z "$local_root" ] && local_root="." + local default_source="${local_root}/source/azerothcore" if [ "$module_playerbots" = "1" ]; then - default_source="./source/azerothcore-playerbots" + default_source="${local_root}/source/azerothcore-playerbots" fi local src_path diff --git a/compose.yml b/docker-compose.yml similarity index 99% rename from compose.yml rename to docker-compose.yml index c18b84a..b8bfa0d 100644 --- a/compose.yml +++ b/docker-compose.yml @@ -183,7 +183,7 @@ services: user: "0:0" volumes: - ac-client-data:/azerothcore/data - - ${CLIENT_DATA_CACHE_PATH:-./client-data-cache}:/cache + - ${CLIENT_DATA_CACHE_PATH:-${STORAGE_PATH_LOCAL:-./local-storage}/client-data-cache}:/cache - ./scripts:/tmp/scripts:ro working_dir: /tmp environment: @@ -218,7 +218,7 @@ services: user: "0:0" volumes: - ac-client-data:/azerothcore/data - - ${CLIENT_DATA_CACHE_PATH:-./client-data-cache}:/cache + - ${CLIENT_DATA_CACHE_PATH:-${STORAGE_PATH_LOCAL:-./local-storage}/client-data-cache}:/cache - ./scripts:/tmp/scripts:ro working_dir: /tmp environment: diff --git a/scripts/deploy-tools.sh b/scripts/deploy-tools.sh index ec1db8f..a063b8c 100755 --- a/scripts/deploy-tools.sh +++ b/scripts/deploy-tools.sh @@ -5,7 +5,7 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." -COMPOSE_FILE="$ROOT_DIR/compose.yml" +COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" ENV_FILE="$ROOT_DIR/.env" BLUE='\033[0;34m' diff --git a/scripts/manage-modules.sh b/scripts/manage-modules.sh index c55cdcd..02282ab 100755 --- a/scripts/manage-modules.sh +++ b/scripts/manage-modules.sh @@ -8,15 +8,13 @@ git config --global user.email "${GIT_EMAIL:-noreply@azerothcore.org}" # PAT not needed for public repositories echo 'Initializing module management...' -cd /modules +if [ "$MODULES_LOCAL_RUN" != "1" ]; then + cd /modules +fi echo 'Cleaning up disabled modules...' -# Remove modules if disabled -if [ "$MODULE_PLAYERBOTS" != "1" ] && [ -d "mod-playerbots" ]; then - echo 'Removing mod-playerbots (disabled)...' - rm -rf mod-playerbots -fi +# Playerbots are integrated into the source - no separate module to remove if [ "$MODULE_AOE_LOOT" != "1" ] && [ -d "mod-aoe-loot" ]; then echo 'Removing mod-aoe-loot (disabled)...' @@ -227,15 +225,14 @@ fi echo 'Installing enabled modules...' -# Install Playerbots if enabled -if [ "$MODULE_PLAYERBOTS" = "1" ] && [ ! -d "mod-playerbots" ]; then - echo '🤖 Installing mod-playerbots...' - echo ' 📖 Project: https://github.com/uprightbass360/mod-playerbots' - echo ' 🚨 CRITICAL: REQUIRES Custom AzerothCore branch (uprightbass360/azerothcore-wotlk-playerbots/tree/Playerbot)' - echo ' 🚨 INCOMPATIBLE with standard AzerothCore - module will not function properly' - echo ' 🔧 REBUILD REQUIRED: Container must be rebuilt with source-based compilation' +# Playerbots handling - integrated into custom AzerothCore branch +if [ "$MODULE_PLAYERBOTS" = "1" ]; then + echo '🤖 Playerbots module enabled...' + echo ' 📖 Playerbots are integrated into the uprightbass360/azerothcore-wotlk-playerbots source' + echo ' â„šī¸ No separate module repository needed - functionality built into core' + echo ' 🔧 REBUILD REQUIRED: Container must be rebuilt with playerbots source' echo ' 📋 POST-INSTALL: Requires manual account/character configuration' - git clone https://github.com/uprightbass360/mod-playerbots.git mod-playerbots + # No git clone needed - playerbots are integrated into the source tree fi # Install AOE Loot if enabled @@ -707,7 +704,11 @@ fi # Module state tracking and rebuild logic echo 'Checking for module changes that require rebuild...' -MODULES_STATE_FILE="/modules/.modules_state" +if [ "$MODULES_LOCAL_RUN" = "1" ]; then + MODULES_STATE_FILE="./.modules_state" +else + MODULES_STATE_FILE="/modules/.modules_state" +fi CURRENT_STATE="" REBUILD_REQUIRED=0 @@ -804,7 +805,11 @@ fi echo 'Module management complete.' -REBUILD_SENTINEL="/modules/.requires_rebuild" +if [ "$MODULES_LOCAL_RUN" = "1" ]; then + REBUILD_SENTINEL="./.requires_rebuild" +else + REBUILD_SENTINEL="/modules/.requires_rebuild" +fi if [ "$SQL_EXECUTION_FAILED" = "1" ]; then echo "âš ī¸ SQL execution encountered issues; review logs above." fi diff --git a/scripts/migrate-stack.sh b/scripts/migrate-stack.sh index 7ea415a..d2ca7e9 100755 --- a/scripts/migrate-stack.sh +++ b/scripts/migrate-stack.sh @@ -15,7 +15,7 @@ Options: --port PORT SSH port (default: 22) --identity PATH SSH private key (passed to scp/ssh) --project-dir DIR Remote project directory (default: ~/acore-compose) - --tarball PATH Output path for the image tar (default: ./images/acore-modules-images.tar) + --tarball PATH Output path for the image tar (default: ./local-storage/images/acore-modules-images.tar) --storage PATH Remote storage directory (default: /storage) --skip-storage Do not sync the storage directory --help Show this help @@ -54,7 +54,10 @@ fi PROJECT_DIR="${PROJECT_DIR:-/home/${USER}/acore-compose}" REMOTE_STORAGE="${REMOTE_STORAGE:-${PROJECT_DIR}/storage}" -TARBALL="${TARBALL:-$(pwd)/images/acore-modules-images.tar}" +LOCAL_STORAGE_ROOT="${STORAGE_PATH_LOCAL:-./local-storage}" +LOCAL_STORAGE_ROOT="${LOCAL_STORAGE_ROOT%/}" +[ -z "$LOCAL_STORAGE_ROOT" ] && LOCAL_STORAGE_ROOT="." +TARBALL="${TARBALL:-${LOCAL_STORAGE_ROOT}/images/acore-modules-images.tar}" SCP_OPTS=(-P "$PORT") SSH_OPTS=(-p "$PORT") diff --git a/scripts/rebuild-with-modules.sh b/scripts/rebuild-with-modules.sh index fa9c6e2..8219310 100755 --- a/scripts/rebuild-with-modules.sh +++ b/scripts/rebuild-with-modules.sh @@ -35,6 +35,9 @@ read_env(){ if [ -f "$env_path" ]; then value="$(grep -E "^${key}=" "$env_path" | tail -n1 | cut -d'=' -f2- | tr -d '\r')" fi + if [ -z "$value" ]; then + value="${!key:-}" + fi if [ -z "$value" ]; then value="$default" fi @@ -44,10 +47,16 @@ read_env(){ default_source_path(){ local module_playerbots module_playerbots="$(read_env MODULE_PLAYERBOTS "0")" + local local_root + local_root="$(read_env STORAGE_PATH_LOCAL "./local-storage")" + local_root="${local_root%/}" + if [[ -z "$local_root" ]]; then + local_root="." + fi if [ "$module_playerbots" = "1" ]; then - echo "./source/azerothcore-playerbots" + echo "${local_root}/source/azerothcore-playerbots" else - echo "./source/azerothcore" + echo "${local_root}/source/azerothcore" fi } @@ -125,6 +134,20 @@ fi REBUILD_SOURCE_PATH="$(realpath "$REBUILD_SOURCE_PATH" 2>/dev/null || echo "$REBUILD_SOURCE_PATH")" +# Check for modules in source directory first, then fall back to shared storage +LOCAL_MODULES_DIR="$REBUILD_SOURCE_PATH/modules" +SHARED_MODULES_DIR="$STORAGE_PATH/modules" + +if [ -d "$LOCAL_MODULES_DIR" ]; then + echo "🔧 Using modules from source directory: $LOCAL_MODULES_DIR" + MODULES_DIR="$LOCAL_MODULES_DIR" + SENTINEL_FILE="$LOCAL_MODULES_DIR/.requires_rebuild" +else + echo "🔧 Using modules from shared storage: $SHARED_MODULES_DIR" + MODULES_DIR="$SHARED_MODULES_DIR" + SENTINEL_FILE="$SHARED_MODULES_DIR/.requires_rebuild" +fi + SOURCE_COMPOSE="$REBUILD_SOURCE_PATH/docker-compose.yml" if [ ! -f "$SOURCE_COMPOSE" ]; then echo "❌ Source docker-compose.yml not found at $SOURCE_COMPOSE" diff --git a/scripts/setup-source.sh b/scripts/setup-source.sh index 5a3b3f1..6064a2e 100755 --- a/scripts/setup-source.sh +++ b/scripts/setup-source.sh @@ -1,6 +1,6 @@ #!/bin/bash # ac-compose source repository setup -set -e +set -euo pipefail echo '🔧 Setting up AzerothCore source repository...' @@ -14,8 +14,9 @@ PROJECT_ROOT="$(pwd)" # Default values MODULE_PLAYERBOTS="${MODULE_PLAYERBOTS:-0}" -DEFAULT_STANDARD_PATH="./source/azerothcore" -DEFAULT_PLAYERBOTS_PATH="./source/azerothcore-playerbots" +LOCAL_STORAGE_ROOT="${STORAGE_PATH_LOCAL:-./local-storage}" +DEFAULT_STANDARD_PATH="${LOCAL_STORAGE_ROOT%/}/source/azerothcore" +DEFAULT_PLAYERBOTS_PATH="${LOCAL_STORAGE_ROOT%/}/source/azerothcore-playerbots" SOURCE_PATH_DEFAULT="$DEFAULT_STANDARD_PATH" if [ "$MODULE_PLAYERBOTS" = "1" ]; then @@ -30,7 +31,11 @@ else STORAGE_PATH_ABS="$STORAGE_PATH_VALUE" fi -DEFAULT_SOURCE_ABS="$PROJECT_ROOT/${SOURCE_PATH_DEFAULT#./}" +if [[ "$SOURCE_PATH_DEFAULT" != /* ]]; then + DEFAULT_SOURCE_ABS="$PROJECT_ROOT/${SOURCE_PATH_DEFAULT#./}" +else + DEFAULT_SOURCE_ABS="$SOURCE_PATH_DEFAULT" +fi # Convert to absolute path if relative and ensure we stay local if [[ "$SOURCE_PATH" != /* ]]; then @@ -62,36 +67,38 @@ echo "📍 Repository: $REPO_URL" echo "đŸŒŋ Branch: $BRANCH" echo "📂 Source path: $SOURCE_PATH" -# Create source directory if it doesn't exist +# Ensure destination directories exist +echo "📂 Preparing local workspace at $(dirname "$SOURCE_PATH")" mkdir -p "$(dirname "$SOURCE_PATH")" # Clone or update repository if [ -d "$SOURCE_PATH/.git" ]; then - echo "📂 Existing repository found, updating..." - cd "$SOURCE_PATH" + echo "📂 Existing repository found, updating..." + cd "$SOURCE_PATH" - # Check if we're on the correct repository - CURRENT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "") - if [ "$CURRENT_REMOTE" != "$REPO_URL" ]; then - echo "🔄 Repository URL changed, re-cloning..." - cd .. - rm -rf "$(basename "$SOURCE_PATH")" - git clone "$REPO_URL" "$(basename "$SOURCE_PATH")" - cd "$(basename "$SOURCE_PATH")" - fi - - # Fetch latest changes - git fetch origin - - # Switch to target branch + # Check if we're on the correct repository + CURRENT_REMOTE=$(git remote get-url origin 2>/dev/null || echo "") + if [ "$CURRENT_REMOTE" != "$REPO_URL" ]; then + echo "🔄 Repository URL changed, re-cloning..." + cd .. + rm -rf "$(basename "$SOURCE_PATH")" + echo "âŗ Cloning $REPO_URL (branch $BRANCH) into $(basename "$SOURCE_PATH")" + git clone -b "$BRANCH" "$REPO_URL" "$(basename "$SOURCE_PATH")" + cd "$(basename "$SOURCE_PATH")" + else + echo "🔄 Fetching latest changes from origin..." + git fetch origin --progress + echo "🔀 Switching to branch $BRANCH..." git checkout "$BRANCH" - git pull origin "$BRANCH" - + echo "âŦ‡ī¸ Pulling latest commits..." + git pull --ff-only origin "$BRANCH" echo "✅ Repository updated to latest $BRANCH" + fi else - echo "đŸ“Ĩ Cloning repository..." - git clone -b "$BRANCH" "$REPO_URL" "$SOURCE_PATH" - echo "✅ Repository cloned successfully" + echo "đŸ“Ĩ Cloning repository..." + echo "âŗ Cloning $REPO_URL (branch $BRANCH) into $SOURCE_PATH" + git clone -b "$BRANCH" "$REPO_URL" "$SOURCE_PATH" + echo "✅ Repository cloned successfully" fi cd "$SOURCE_PATH" diff --git a/setup.sh b/setup.sh index 2974ce8..45f7f4f 100755 --- a/setup.sh +++ b/setup.sh @@ -92,6 +92,62 @@ normalize_module_name(){ declare -A MODULE_ENABLE_SET=() +declare -a COMPOSE_CMD=() + +resolve_compose_command(){ + if [ ${#COMPOSE_CMD[@]} -gt 0 ]; then + return 0 + fi + if command -v docker >/dev/null 2>&1; then + if docker compose version >/dev/null 2>&1; then + COMPOSE_CMD=(docker compose) + return 0 + fi + fi + if command -v docker-compose >/dev/null 2>&1; then + COMPOSE_CMD=(docker-compose) + return 0 + fi + COMPOSE_CMD=() + return 1 +} + +modules_directory_has_content(){ + local dir="$1" + [ -d "$dir" ] || return 1 + local first_entry + first_entry="$(find "$dir" -mindepth 1 -maxdepth 1 -type d -print -quit 2>/dev/null)" + [ -n "$first_entry" ] +} + +ensure_modules_staged(){ + local storage_abs="$1" needs_cxx="$2" run_now="$3" + if [ "$needs_cxx" != "1" ] || [ "$run_now" != "1" ]; then + return 0 + fi + + local modules_dir="${storage_abs}/modules" + local config_dir="${storage_abs}/config" + mkdir -p "$modules_dir" "$config_dir" + + if modules_directory_has_content "$modules_dir"; then + return 0 + fi + + if ! resolve_compose_command; then + say WARNING "Docker Compose not detected; skipping automatic module staging." + return 1 + fi + + say INFO "Staging module repositories via ${COMPOSE_CMD[*]} run --rm --no-deps ac-modules" + if ! "${COMPOSE_CMD[@]}" --profile modules run --rm --no-deps ac-modules; then + say WARNING "Module staging failed; repositories may be incomplete." + return 1 + fi + + return 0 +} + KNOWN_MODULE_VARS=( MODULE_PLAYERBOTS MODULE_AOE_LOOT @@ -168,12 +224,37 @@ apply_module_preset(){ DEFAULT_PRESET_SUGGESTED="suggested-modules" DEFAULT_PRESET_PLAYERBOTS="playerbots-suggested-modules" -show_wow_header(){ - echo -e "\n${BLUE} âš”ī¸ AZEROTHCORE DEPLOYMENT SYSTEM âš”ī¸${NC}" - echo -e "${BLUE} ═══════════════════════════════════════${NC}" - echo -e "${BLUE} 🏰 Build Your Own WoW Server 🏰${NC}\n" +show_wow_header() { + clear + echo -e "${RED}" + cat <<'EOF' + + db 888888888888 88888888888 88888888ba ,ad8888ba, 888888888888 88 88 ,ad8888ba, ,ad8888ba, 88888888ba 88888888888 + d88b ,88 88 88 "8b d8"' `"8b 88 88 88 d8"' `"8b d8"' `"8b 88 "8b 88 + d8'`8b ,88" 88 88 ,8P d8' `8b 88 88 88 d8' d8' `8b 88 ,8P 88 + d8' `8b ,88" 88aaaaa 88aaaaaa8P' 88 88 88 88aaaaaaaa88 88 88 88 88aaaaaa8P' 88aaaaa + d8YaaaaY8b ,88" 88""""" 88""""88' 88 88 88 88""""""""88 88 88 88 88""""88' 88""""" + d8""""""""8b ,88" 88 88 `8b Y8, ,8P 88 88 88 Y8, Y8, ,8P 88 `8b 88 + d8' `8b 88" 88 88 `8b Y8a. .a8P 88 88 88 Y8a. .a8P Y8a. .a8P 88 `8b 88 +d8' `8b 888888888888 88888888888 88 `8b `"Y8888Y"' 88 88 88 `"Y8888Y"' `"Y8888Y"' 88 `8b 88888888888 + ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ + .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. .'`~ ``. + )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( )`_ ._ ( + |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| |(_/^\_)| + `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' `-.`''.-' + """ """ """ """ """ """ """ """ """ """ + + .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. .')'=.'_`.='(`. + :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: :| -.._H_,.- |: + |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| |: -.__H__.- :| + <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> <' `--V--' `> + +art: littlebitspace@https://littlebitspace.com/ +EOF + echo -e "${NC}" } + show_realm_configured(){ echo -e "\n${GREEN}âš”ī¸ Your realm configuration has been forged! âš”ī¸${NC}" echo -e "${GREEN}🏰 Ready to deploy your World of Warcraft server${NC}" @@ -437,9 +518,9 @@ EOF # Deployment type say HEADER "DEPLOYMENT TYPE" - echo "1) 🏠 Local Development (127.0.0.1, local storage)" - echo "2) 🌐 LAN Server (local network IP)" - echo "3) â˜ī¸ Public Server (domain or public IP)" + echo "1) 🏠 Local Development (127.0.0.1)" + echo "2) 🌐 LAN Server (local network IP) (autodetect)" + echo "3) â˜ī¸ Public Server (domain or public IP) (manual)" local DEPLOYMENT_TYPE_INPUT="${CLI_DEPLOYMENT_TYPE}" local DEPLOYMENT_TYPE="" if [ "$NON_INTERACTIVE" = "1" ] && [ -z "$DEPLOYMENT_TYPE_INPUT" ]; then @@ -498,9 +579,9 @@ fi # Permission scheme say HEADER "PERMISSION SCHEME" - echo "1) 🏠 Local Dev (0:0)" - echo "2) đŸ—‚ī¸ NFS Server (1001:1000)" - echo "3) âš™ī¸ Custom" + echo "1) 🏠 Local Root (0:0)" + echo "2) đŸ—‚ī¸ User (1001:1000)" + echo "3) âš™ī¸ Custom" local PERMISSION_SCHEME_INPUT="${CLI_PERMISSION_SCHEME}" local PERMISSION_SCHEME_NAME="" local CONTAINER_USER @@ -889,6 +970,17 @@ fi printf " %-18s detected (source rebuild required)\n" "C++ modules:" fi + local LOCAL_STORAGE_ROOT="${STORAGE_PATH_LOCAL:-./local-storage}" + LOCAL_STORAGE_ROOT="${LOCAL_STORAGE_ROOT%/}" + [ -z "$LOCAL_STORAGE_ROOT" ] && LOCAL_STORAGE_ROOT="." + STORAGE_PATH_LOCAL="$LOCAL_STORAGE_ROOT" + + export STORAGE_PATH STORAGE_PATH_LOCAL + local module_export_var + for module_export_var in "${KNOWN_MODULE_VARS[@]}"; do + export "$module_export_var" + done + if [ "$NEEDS_CXX_REBUILD" = "1" ]; then echo "" say WARNING "These modules require compiling AzerothCore from source." @@ -905,18 +997,18 @@ fi if [ "$RUN_REBUILD_NOW" = "1" ] || [ "$AUTO_REBUILD_ON_DEPLOY" = "1" ]; then if [ -z "$MODULES_REBUILD_SOURCE_PATH_VALUE" ]; then if [ "$MODULE_PLAYERBOTS" = "1" ]; then - MODULES_REBUILD_SOURCE_PATH_VALUE="./source/azerothcore-playerbots" + MODULES_REBUILD_SOURCE_PATH_VALUE="${LOCAL_STORAGE_ROOT}/source/azerothcore-playerbots" else - MODULES_REBUILD_SOURCE_PATH_VALUE="./source/azerothcore" + MODULES_REBUILD_SOURCE_PATH_VALUE="${LOCAL_STORAGE_ROOT}/source/azerothcore" fi say INFO "Using default source path: ${MODULES_REBUILD_SOURCE_PATH_VALUE}" fi fi fi - local default_source_rel="./source/azerothcore" + local default_source_rel="${LOCAL_STORAGE_ROOT}/source/azerothcore" if [ "$MODULE_PLAYERBOTS" = "1" ]; then - default_source_rel="./source/azerothcore-playerbots" + default_source_rel="${LOCAL_STORAGE_ROOT}/source/azerothcore-playerbots" fi if [ -n "$MODULES_REBUILD_SOURCE_PATH_VALUE" ]; then @@ -934,11 +1026,15 @@ fi fi fi + # Module staging will be handled directly in the rebuild section below + if [ "$RUN_REBUILD_NOW" = "1" ]; then local default_source_path="$default_source_rel" local rebuild_source_path="${MODULES_REBUILD_SOURCE_PATH_VALUE:-$default_source_path}" + MODULES_REBUILD_SOURCE_PATH_VALUE="$rebuild_source_path" + export MODULES_REBUILD_SOURCE_PATH="$MODULES_REBUILD_SOURCE_PATH_VALUE" if [ ! -f "$rebuild_source_path/docker-compose.yml" ]; then - say INFO "Preparing source repository via scripts/setup-source.sh" + say INFO "Preparing source repository via scripts/setup-source.sh (git clone/fetch can take a few minutes)" if ! ./scripts/setup-source.sh >/dev/null 2>&1; then say WARNING "Source setup encountered issues; running interactively." if ! ./scripts/setup-source.sh; then @@ -947,6 +1043,33 @@ fi fi fi fi + + # Stage modules to local source directory before compilation + if [ "$NEEDS_CXX_REBUILD" = "1" ]; then + say INFO "Staging module repositories to local source directory..." + local local_modules_dir="${rebuild_source_path}/modules" + mkdir -p "$local_modules_dir" + + # Export module variables for the script + local module_export_var + for module_export_var in "${KNOWN_MODULE_VARS[@]}"; do + export "$module_export_var" + done + + # Set git config for module script + git config --global user.name "${GIT_USERNAME:-ac-compose}" 2>/dev/null || true + git config --global user.email "${GIT_EMAIL:-noreply@azerothcore.org}" 2>/dev/null || true + + # Run module staging script in local modules directory + # Set environment variable to indicate we're running locally + export MODULES_LOCAL_RUN=1 + if (cd "$local_modules_dir" && bash "$SCRIPT_DIR/scripts/manage-modules.sh"); then + say SUCCESS "Module repositories staged to $local_modules_dir" + else + say WARNING "Module staging encountered issues, but continuing with rebuild" + fi + unset MODULES_LOCAL_RUN + fi fi if [ "$RUN_REBUILD_NOW" = "1" ]; then @@ -974,6 +1097,11 @@ fi fi DB_PLAYERBOTS_NAME=${DB_PLAYERBOTS_NAME:-acore_playerbots} + local CLIENT_DATA_CACHE_PATH_VALUE="${LOCAL_STORAGE_ROOT}/client-data-cache" + HOST_ZONEINFO_PATH=${HOST_ZONEINFO_PATH:-/usr/share/zoneinfo} + MYSQL_INNODB_REDO_LOG_CAPACITY=${MYSQL_INNODB_REDO_LOG_CAPACITY:-512M} + MYSQL_RUNTIME_TMPFS_SIZE=${MYSQL_RUNTIME_TMPFS_SIZE:-8G} + CLIENT_DATA_VOLUME=${CLIENT_DATA_VOLUME:-ac-client-data} cat > "$ENV_OUT" <