refactor: reorganize scripts under bash/python

This commit is contained in:
uprightbass360
2025-11-09 02:48:49 -05:00
parent 23456e0ab9
commit a18e315f1f
40 changed files with 265 additions and 194 deletions

View File

@@ -1,6 +1,6 @@
# Copy this file to .env and adjust values for your environment. # Copy this file to .env and adjust values for your environment.
# Docker Compose will auto-load .env in the same folder as docker-compose.yml. # Docker Compose will auto-load .env in the same folder as docker-compose.yml.
# Template for AzerothCore-RealmMaster profiles-based compose # Template for AzerothCore Realm profiles-based compose
# ===================== # =====================
# Compose overrides (set to 1 to include matching file under compose-overrides/) # Compose overrides (set to 1 to include matching file under compose-overrides/)
@@ -13,7 +13,8 @@ COMPOSE_OVERRIDE_WORLDSERVER_DEBUG_LOGGING_ENABLED=0
# ===================== # =====================
# Project name # Project name
# ===================== # =====================
COMPOSE_PROJECT_NAME=azerothcore-realmmaster # Customize this to match your deployment slug (used for container names/tags)
COMPOSE_PROJECT_NAME=azerothcore-stack
# ===================== # =====================
# Storage & Timezone # Storage & Timezone
@@ -157,7 +158,8 @@ MODULES_REQUIRES_PLAYERBOT_SOURCE=0
# ===================== # =====================
# Client Data Settings # Client Data Settings
# ===================== # =====================
CLIENT_DATA_VERSION=v18 # This is automatically applied, fyi version must match tag exactly
#CLIENT_DATA_VERSION=v18.0
# ===================== # =====================
# Server Configuration # Server Configuration

View File

@@ -8,6 +8,11 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_PATH="$ROOT_DIR/.env" ENV_PATH="$ROOT_DIR/.env"
TEMPLATE_PATH="$ROOT_DIR/.env.template"
source "$ROOT_DIR/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_PATH" "$TEMPLATE_PATH")"
ASSUME_YES=0 ASSUME_YES=0
FORCE_REBUILD=0 FORCE_REBUILD=0
SKIP_SOURCE_SETUP=0 SKIP_SOURCE_SETUP=0
@@ -95,7 +100,7 @@ update_env_value(){
fi fi
} }
MODULE_HELPER="$ROOT_DIR/scripts/modules.py" MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py"
MODULE_STATE_INITIALIZED=0 MODULE_STATE_INITIALIZED=0
declare -a MODULES_COMPILE_LIST=() declare -a MODULES_COMPILE_LIST=()
@@ -185,7 +190,7 @@ ensure_source_repo(){
fi fi
warn "AzerothCore source not found at $src_path; running setup-source.sh" >&2 warn "AzerothCore source not found at $src_path; running setup-source.sh" >&2
if ! (cd "$ROOT_DIR" && ./scripts/setup-source.sh) >&2; then if ! (cd "$ROOT_DIR" && ./scripts/bash/setup-source.sh) >&2; then
err "Failed to setup source repository" >&2 err "Failed to setup source repository" >&2
exit 1 exit 1
fi fi
@@ -201,7 +206,7 @@ ensure_source_repo(){
show_client_data_requirement(){ show_client_data_requirement(){
local repo_path="$1" local repo_path="$1"
local detector="$ROOT_DIR/scripts/detect-client-data-version.sh" local detector="$ROOT_DIR/scripts/bash/detect-client-data-version.sh"
if [ ! -x "$detector" ]; then if [ ! -x "$detector" ]; then
return return
fi fi
@@ -369,17 +374,8 @@ sync_modules(){
} }
resolve_project_name(){ resolve_project_name(){
local raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" local raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
local sanitized project_name::sanitize "$raw_name"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
ensure_modules_dir_writable(){ ensure_modules_dir_writable(){
@@ -484,7 +480,7 @@ stage_modules(){
rm -f "$staging_modules_dir/.modules_state" "$staging_modules_dir/.requires_rebuild" 2>/dev/null || true rm -f "$staging_modules_dir/.modules_state" "$staging_modules_dir/.requires_rebuild" 2>/dev/null || true
fi fi
if ! (cd "$local_modules_dir" && bash "$ROOT_DIR/scripts/manage-modules.sh"); then if ! (cd "$local_modules_dir" && bash "$ROOT_DIR/scripts/bash/manage-modules.sh"); then
err "Module staging failed; aborting build" err "Module staging failed; aborting build"
return 1 return 1
fi fi
@@ -543,7 +539,7 @@ execute_build(){
info "Building AzerothCore with modules (this may take a while)" info "Building AzerothCore with modules (this may take a while)"
docker compose -f "$compose_file" down --remove-orphans >/dev/null 2>&1 || true docker compose -f "$compose_file" down --remove-orphans >/dev/null 2>&1 || true
if (cd "$ROOT_DIR" && ./scripts/rebuild-with-modules.sh --yes --source "$src_path"); then if (cd "$ROOT_DIR" && ./scripts/bash/rebuild-with-modules.sh --yes --source "$src_path"); then
ok "Source build completed" ok "Source build completed"
else else
err "Source build failed" err "Source build failed"

View File

@@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
# ============================================== # ==============================================
# ac-compose Cleanup Script (project-scoped) # AzerothCore RealmMaster Cleanup Script (project-scoped)
# ============================================== # ==============================================
# Usage: ./cleanup.sh [--soft] [--hard] [--nuclear] [--dry-run] [--force] [--preserve-backups] # Usage: ./cleanup.sh [--soft] [--hard] [--nuclear] [--dry-run] [--force] [--preserve-backups]
# Project: ac-compose # Project: azerothcore-rm
set -e set -e
@@ -13,7 +13,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="${SCRIPT_DIR}" PROJECT_DIR="${SCRIPT_DIR}"
DEFAULT_COMPOSE_FILE="${PROJECT_DIR}/docker-compose.yml" DEFAULT_COMPOSE_FILE="${PROJECT_DIR}/docker-compose.yml"
ENV_FILE="${PROJECT_DIR}/.env" ENV_FILE="${PROJECT_DIR}/.env"
source "${PROJECT_DIR}/scripts/lib/compose_overrides.sh" TEMPLATE_FILE="${PROJECT_DIR}/.env.template"
source "${PROJECT_DIR}/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
source "${PROJECT_DIR}/scripts/bash/compose_overrides.sh"
declare -a COMPOSE_FILE_ARGS=() declare -a COMPOSE_FILE_ARGS=()
# Colors # Colors
@@ -135,23 +140,13 @@ done
COMPOSE_BASE="docker compose${COMPOSE_FILE_ARGS_STR}" COMPOSE_BASE="docker compose${COMPOSE_FILE_ARGS_STR}"
STORAGE_PATH="${STORAGE_PATH:-$STORAGE_PATH_DEFAULT}" STORAGE_PATH="${STORAGE_PATH:-$STORAGE_PATH_DEFAULT}"
STORAGE_PATH_LOCAL="${STORAGE_PATH_LOCAL:-$STORAGE_PATH_LOCAL_DEFAULT}" STORAGE_PATH_LOCAL="${STORAGE_PATH_LOCAL:-$STORAGE_PATH_LOCAL_DEFAULT}"
PROJECT_NAME="${COMPOSE_PROJECT_NAME:-ac-compose}" PROJECT_NAME="${COMPOSE_PROJECT_NAME:-$DEFAULT_PROJECT_NAME}"
sanitize_project_name(){ sanitize_project_name(){
local raw="$1" project_name::sanitize "$1"
local sanitized
sanitized="$(echo "$raw" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
PROJECT_IMAGE_PREFIX="$(sanitize_project_name "${COMPOSE_PROJECT_NAME:-azerothcore-realmmaster}")" PROJECT_IMAGE_PREFIX="$(sanitize_project_name "${COMPOSE_PROJECT_NAME:-$DEFAULT_PROJECT_NAME}")"
remove_storage_dir(){ remove_storage_dir(){
local path="$1" local path="$1"
@@ -269,7 +264,7 @@ show_summary() {
} }
main(){ main(){
print_status HEADER "ac-compose CLEANUP" print_status HEADER "${PROJECT_NAME^^} CLEANUP"
if ! command -v docker >/dev/null 2>&1; then if ! command -v docker >/dev/null 2>&1; then
print_status ERROR "Docker not found" print_status ERROR "Docker not found"

View File

@@ -429,6 +429,8 @@
"name": "StatBooster", "name": "StatBooster",
"repo": "https://github.com/AnchyDev/StatBooster.git", "repo": "https://github.com/AnchyDev/StatBooster.git",
"type": "cpp", "type": "cpp",
"status": "blocked",
"block_reason": "Override signature mismatch on OnLootItem",
"post_install_hooks": [ "post_install_hooks": [
"fix-statbooster-api" "fix-statbooster-api"
], ],

View File

@@ -23,7 +23,6 @@
"MODULE_ASSISTANT", "MODULE_ASSISTANT",
"MODULE_REAGENT_BANK", "MODULE_REAGENT_BANK",
"MODULE_BLACK_MARKET_AUCTION_HOUSE", "MODULE_BLACK_MARKET_AUCTION_HOUSE",
"MODULE_STATBOOSTER",
"MODULE_ELUNA_TS", "MODULE_ELUNA_TS",
"MODULE_AIO", "MODULE_AIO",
"MODULE_ELUNA_SCRIPTS", "MODULE_ELUNA_SCRIPTS",

View File

@@ -76,7 +76,6 @@
"MODULE_SERVER_AUTO_SHUTDOWN", "MODULE_SERVER_AUTO_SHUTDOWN",
"MODULE_SOLOCRAFT", "MODULE_SOLOCRAFT",
"MODULE_SOLO_LFG", "MODULE_SOLO_LFG",
"MODULE_STATBOOSTER",
"MODULE_SYSTEM_VIP", "MODULE_SYSTEM_VIP",
"MODULE_TEMP_ANNOUNCEMENTS", "MODULE_TEMP_ANNOUNCEMENTS",
"MODULE_TIC_TAC_TOE", "MODULE_TIC_TAC_TOE",

View File

@@ -11,7 +11,12 @@ set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml"
ENV_PATH="$ROOT_DIR/.env" ENV_PATH="$ROOT_DIR/.env"
source "$ROOT_DIR/scripts/lib/compose_overrides.sh" TEMPLATE_PATH="$ROOT_DIR/.env.template"
source "$ROOT_DIR/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_PATH" "$TEMPLATE_PATH")"
source "$ROOT_DIR/scripts/bash/compose_overrides.sh"
TARGET_PROFILE="" TARGET_PROFILE=""
WATCH_LOGS=1 WATCH_LOGS=1
KEEP_RUNNING=0 KEEP_RUNNING=0
@@ -28,7 +33,7 @@ REMOTE_PROJECT_DIR=""
REMOTE_SKIP_STORAGE=0 REMOTE_SKIP_STORAGE=0
REMOTE_ARGS_PROVIDED=0 REMOTE_ARGS_PROVIDED=0
MODULE_HELPER="$ROOT_DIR/scripts/modules.py" MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py"
MODULE_STATE_INITIALIZED=0 MODULE_STATE_INITIALIZED=0
declare -a MODULES_COMPILE_LIST=() declare -a MODULES_COMPILE_LIST=()
declare -a COMPOSE_FILE_ARGS=() declare -a COMPOSE_FILE_ARGS=()
@@ -59,7 +64,7 @@ show_realm_ready(){
show_remote_plan(){ show_remote_plan(){
local plan_host="${REMOTE_HOST:-<host>}" local plan_host="${REMOTE_HOST:-<host>}"
local plan_user="${REMOTE_USER:-<user>}" local plan_user="${REMOTE_USER:-<user>}"
local plan_dir="${REMOTE_PROJECT_DIR:-~/AzerothCore-RealmMaster}" local plan_dir="${REMOTE_PROJECT_DIR:-$(get_default_remote_dir)}"
printf '\n%b\n' "${BLUE}🧭 Remote Deployment Plan${NC}" printf '\n%b\n' "${BLUE}🧭 Remote Deployment Plan${NC}"
printf '%b\n' "${YELLOW}├─ Validate build status locally${NC}" printf '%b\n' "${YELLOW}├─ Validate build status locally${NC}"
@@ -139,7 +144,7 @@ collect_remote_details(){
fi fi
if [ -z "$REMOTE_PROJECT_DIR" ]; then if [ -z "$REMOTE_PROJECT_DIR" ]; then
REMOTE_PROJECT_DIR="~/AzerothCore-RealmMaster" REMOTE_PROJECT_DIR="$(get_default_remote_dir)"
fi fi
if [ "$interactive" -eq 1 ]; then if [ "$interactive" -eq 1 ]; then
local dir_input local dir_input
@@ -183,10 +188,10 @@ validate_remote_configuration(){
fi fi
fi fi
if [ -z "$REMOTE_PROJECT_DIR" ]; then if [ -z "$REMOTE_PROJECT_DIR" ]; then
REMOTE_PROJECT_DIR="~/AzerothCore-RealmMaster" REMOTE_PROJECT_DIR="$(get_default_remote_dir)"
fi fi
if [ ! -f "$ROOT_DIR/scripts/migrate-stack.sh" ]; then if [ ! -f "$ROOT_DIR/scripts/bash/migrate-stack.sh" ]; then
err "Migration script not found: $ROOT_DIR/scripts/migrate-stack.sh" err "Migration script not found: $ROOT_DIR/scripts/bash/migrate-stack.sh"
exit 1 exit 1
fi fi
} }
@@ -208,7 +213,7 @@ Options:
--remote-user USER SSH username for remote migration --remote-user USER SSH username for remote migration
--remote-port PORT SSH port for remote migration (default: 22) --remote-port PORT SSH port for remote migration (default: 22)
--remote-identity PATH SSH private key for remote migration --remote-identity PATH SSH private key for remote migration
--remote-project-dir DIR Remote project directory (default: ~/AzerothCore-RealmMaster) --remote-project-dir DIR Remote project directory (default: ~/<project-name>)
--remote-skip-storage Skip syncing the storage directory during migration --remote-skip-storage Skip syncing the storage directory during migration
--skip-config Skip applying server configuration preset --skip-config Skip applying server configuration preset
-h, --help Show this help -h, --help Show this help
@@ -265,8 +270,8 @@ if [ "$REMOTE_MODE" -eq 1 ]; then
exit 1 exit 1
fi fi
fi fi
if [ ! -f "$ROOT_DIR/scripts/migrate-stack.sh" ]; then if [ ! -f "$ROOT_DIR/scripts/bash/migrate-stack.sh" ]; then
err "Migration script not found: $ROOT_DIR/scripts/migrate-stack.sh" err "Migration script not found: $ROOT_DIR/scripts/bash/migrate-stack.sh"
exit 1 exit 1
fi fi
fi fi
@@ -350,17 +355,12 @@ ensure_module_state(){
} }
resolve_project_name(){ resolve_project_name(){
local raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" local raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
local sanitized project_name::sanitize "$raw_name"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')" }
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')" get_default_remote_dir(){
if [[ -z "$sanitized" ]]; then echo "~/$(resolve_project_name)"
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
resolve_project_image(){ resolve_project_image(){
@@ -605,7 +605,7 @@ run_remote_migration(){
args+=(--yes) args+=(--yes)
fi fi
(cd "$ROOT_DIR" && ./scripts/migrate-stack.sh "${args[@]}") (cd "$ROOT_DIR" && ./scripts/bash/migrate-stack.sh "${args[@]}")
} }
@@ -615,7 +615,7 @@ stage_runtime(){
args+=("$TARGET_PROFILE") args+=("$TARGET_PROFILE")
fi fi
info "Staging runtime environment via stage-modules.sh ${args[*]}" info "Staging runtime environment via stage-modules.sh ${args[*]}"
(cd "$ROOT_DIR" && ./scripts/stage-modules.sh "${args[@]}") (cd "$ROOT_DIR" && ./scripts/bash/stage-modules.sh "${args[@]}")
} }
tail_world_logs(){ tail_world_logs(){
@@ -687,7 +687,7 @@ apply_server_config(){
info "Applying server configuration preset: $server_config_preset" info "Applying server configuration preset: $server_config_preset"
local config_script="$ROOT_DIR/scripts/apply-config.py" local config_script="$ROOT_DIR/scripts/python/apply-config.py"
if [ ! -x "$config_script" ]; then if [ ! -x "$config_script" ]; then
warn "Configuration script not found or not executable: $config_script" warn "Configuration script not found or not executable: $config_script"
warn "Server will use default settings" warn "Server will use default settings"
@@ -758,7 +758,7 @@ main(){
show_step 2 "$remote_steps" "Migrating deployment to $REMOTE_HOST" show_step 2 "$remote_steps" "Migrating deployment to $REMOTE_HOST"
if run_remote_migration; then if run_remote_migration; then
ok "Remote deployment package prepared for $REMOTE_USER@$REMOTE_HOST." ok "Remote deployment package prepared for $REMOTE_USER@$REMOTE_HOST."
local remote_dir="${REMOTE_PROJECT_DIR:-~/AzerothCore-RealmMaster}" local remote_dir="${REMOTE_PROJECT_DIR:-$(get_default_remote_dir)}"
info "Run the following on the remote host to complete deployment:" info "Run the following on the remote host to complete deployment:"
printf ' %bcd %s && ./deploy.sh --yes --no-watch%b\n' "$YELLOW" "$remote_dir" "$NC" printf ' %bcd %s && ./deploy.sh --yes --no-watch%b\n' "$YELLOW" "$remote_dir" "$NC"
exit 0 exit 0
@@ -781,7 +781,7 @@ main(){
show_step 3 5 "Importing user database files" show_step 3 5 "Importing user database files"
info "Checking for database files in ./database-import/" info "Checking for database files in ./database-import/"
bash "$ROOT_DIR/scripts/import-database-files.sh" bash "$ROOT_DIR/scripts/bash/import-database-files.sh"
show_step 4 6 "Bringing your realm online" show_step 4 6 "Bringing your realm online"
info "Pulling images and waiting for containers to become healthy; this may take a few minutes on first deploy." info "Pulling images and waiting for containers to become healthy; this may take a few minutes on first deploy."

View File

@@ -21,7 +21,7 @@ services:
entrypoint: entrypoint:
- /usr/local/bin/mysql-entrypoint.sh - /usr/local/bin/mysql-entrypoint.sh
volumes: volumes:
- ./scripts/mysql-entrypoint.sh:/usr/local/bin/mysql-entrypoint.sh:ro - ./scripts/bash/mysql-entrypoint.sh:/usr/local/bin/mysql-entrypoint.sh:ro
- ${STORAGE_PATH_LOCAL}/mysql-data:/var/lib/mysql-persistent - ${STORAGE_PATH_LOCAL}/mysql-data:/var/lib/mysql-persistent
- ${BACKUP_PATH}:/backups - ${BACKUP_PATH}:/backups
- ${HOST_ZONEINFO_PATH}:/usr/share/zoneinfo:ro - ${HOST_ZONEINFO_PATH}:/usr/share/zoneinfo:ro
@@ -65,7 +65,7 @@ services:
- ${STORAGE_PATH}/config:/azerothcore/env/dist/etc - ${STORAGE_PATH}/config:/azerothcore/env/dist/etc
- ${STORAGE_PATH}/logs:/azerothcore/logs - ${STORAGE_PATH}/logs:/azerothcore/logs
- ${STORAGE_PATH_LOCAL}/mysql-data:/var/lib/mysql-persistent - ${STORAGE_PATH_LOCAL}/mysql-data:/var/lib/mysql-persistent
- ./scripts/db-import-conditional.sh:/tmp/db-import-conditional.sh:ro - ./scripts/bash/db-import-conditional.sh:/tmp/db-import-conditional.sh:ro
environment: environment:
AC_DATA_DIR: "/azerothcore/data" AC_DATA_DIR: "/azerothcore/data"
AC_LOGS_DIR: "/azerothcore/logs" AC_LOGS_DIR: "/azerothcore/logs"
@@ -171,9 +171,9 @@ services:
- | - |
microdnf install -y curl || yum install -y curl || (apt-get update && apt-get install -y curl) microdnf install -y curl || yum install -y curl || (apt-get update && apt-get install -y curl)
echo "📥 Downloading backup scheduler script (local copy preferred if mounted)..." echo "📥 Downloading backup scheduler script (local copy preferred if mounted)..."
if [ -f /tmp/scripts/backup-scheduler.sh ]; then if [ -f /tmp/scripts/bash/backup-scheduler.sh ]; then
chmod +x /tmp/scripts/backup-scheduler.sh 2>/dev/null || true chmod +x /tmp/scripts/bash/backup-scheduler.sh 2>/dev/null || true
bash /tmp/scripts/backup-scheduler.sh bash /tmp/scripts/bash/backup-scheduler.sh
else else
echo "No local scheduler provided" echo "No local scheduler provided"
fi fi
@@ -269,9 +269,9 @@ services:
- -c - -c
- | - |
mkdir -p /cache mkdir -p /cache
if [ -f /tmp/scripts/download-client-data.sh ]; then if [ -f /tmp/scripts/bash/download-client-data.sh ]; then
chmod +x /tmp/scripts/download-client-data.sh 2>/dev/null || true chmod +x /tmp/scripts/bash/download-client-data.sh 2>/dev/null || true
bash /tmp/scripts/download-client-data.sh bash /tmp/scripts/bash/download-client-data.sh
else else
echo "No local client-data script" echo "No local client-data script"
fi fi
@@ -302,9 +302,9 @@ services:
echo "📦 Installing 7z for faster extraction..." echo "📦 Installing 7z for faster extraction..."
apt-get update -qq && apt-get install -y p7zip-full apt-get update -qq && apt-get install -y p7zip-full
mkdir -p /cache mkdir -p /cache
if [ -f /tmp/scripts/download-client-data.sh ]; then if [ -f /tmp/scripts/bash/download-client-data.sh ]; then
chmod +x /tmp/scripts/download-client-data.sh 2>/dev/null || true chmod +x /tmp/scripts/bash/download-client-data.sh 2>/dev/null || true
bash /tmp/scripts/download-client-data.sh bash /tmp/scripts/bash/download-client-data.sh
echo "🔧 Fixing ownership of extracted files..." echo "🔧 Fixing ownership of extracted files..."
chown -R ${CONTAINER_USER} /azerothcore/data chown -R ${CONTAINER_USER} /azerothcore/data
echo "✅ Client data extraction and ownership setup complete" echo "✅ Client data extraction and ownership setup complete"
@@ -607,7 +607,7 @@ services:
- -c - -c
- | - |
apk add --no-cache curl bash git python3 apk add --no-cache curl bash git python3
(chmod +x /tmp/scripts/manage-modules.sh /tmp/scripts/manage-modules-sql.sh 2>/dev/null || true) && /tmp/scripts/manage-modules.sh (chmod +x /tmp/scripts/bash/manage-modules.sh /tmp/scripts/bash/manage-modules-sql.sh 2>/dev/null || true) && /tmp/scripts/bash/manage-modules.sh
# Fix permissions after module operations # Fix permissions after module operations
chown -R ${CONTAINER_USER} /modules /azerothcore/env/dist/etc 2>/dev/null || true chown -R ${CONTAINER_USER} /modules /azerothcore/env/dist/etc 2>/dev/null || true
chmod -R 755 /modules /azerothcore/env/dist/etc 2>/dev/null || true chmod -R 755 /modules /azerothcore/env/dist/etc 2>/dev/null || true
@@ -659,7 +659,7 @@ services:
chown -R ${CONTAINER_USER} /azerothcore/config /install-markers 2>/dev/null || true chown -R ${CONTAINER_USER} /azerothcore/config /install-markers 2>/dev/null || true
chmod -R 755 /azerothcore/config /install-markers 2>/dev/null || true chmod -R 755 /azerothcore/config /install-markers 2>/dev/null || true
echo "📥 Running local auto-post-install script..." echo "📥 Running local auto-post-install script..."
(chmod +x /tmp/scripts/auto-post-install.sh 2>/dev/null || true) && bash /tmp/scripts/auto-post-install.sh (chmod +x /tmp/scripts/bash/auto-post-install.sh 2>/dev/null || true) && bash /tmp/scripts/bash/auto-post-install.sh
# Fix permissions for all files created during post-install # Fix permissions for all files created during post-install
chown -R ${CONTAINER_USER} /azerothcore/config /install-markers 2>/dev/null || true chown -R ${CONTAINER_USER} /azerothcore/config /install-markers 2>/dev/null || true
chmod -R 755 /azerothcore/config /install-markers 2>/dev/null || true chmod -R 755 /azerothcore/config /install-markers 2>/dev/null || true

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose # azerothcore-rm
set -e set -e
GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m' GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m'

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose # azerothcore-rm
set -e set -e
BACKUP_DIR_BASE="/backups" BACKUP_DIR_BASE="/backups"

View File

@@ -49,7 +49,7 @@ edit_config() {
# Create a minimal template if it doesn't exist # Create a minimal template if it doesn't exist
cat > "$config_file" << 'EOF' cat > "$config_file" << 'EOF'
# AzerothCore Server Configuration Overrides # AzerothCore Server Configuration Overrides
# Edit this file and run './scripts/configure-server.sh apply' to update settings # Edit this file and run './scripts/bash/configure-server.sh apply' to update settings
[worldserver.conf] [worldserver.conf]
# Example settings - uncomment and modify as needed # Example settings - uncomment and modify as needed

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose # azerothcore-rm
set -e set -e
print_help() { print_help() {

View File

@@ -1,13 +1,18 @@
#!/bin/bash #!/bin/bash
# ac-compose helper to deploy phpMyAdmin and Keira3 tooling. # azerothcore-rm helper to deploy phpMyAdmin and Keira3 tooling.
set -euo pipefail set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml"
ENV_FILE="$ROOT_DIR/.env" ENV_FILE="$ROOT_DIR/.env"
source "$ROOT_DIR/scripts/lib/compose_overrides.sh" TEMPLATE_FILE="$ROOT_DIR/.env.template"
source "$ROOT_DIR/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
source "$ROOT_DIR/scripts/bash/compose_overrides.sh"
declare -a COMPOSE_FILE_ARGS=() declare -a COMPOSE_FILE_ARGS=()
BLUE='\033[0;34m' BLUE='\033[0;34m'
@@ -34,16 +39,8 @@ read_env(){
resolve_project_name(){ resolve_project_name(){
local raw_name sanitized local raw_name sanitized
raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')" project_name::sanitize "$raw_name"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
init_compose_files(){ init_compose_files(){

View File

@@ -9,10 +9,10 @@ set -euo pipefail
print_usage() { print_usage() {
cat <<'EOF' cat <<'EOF'
Usage: scripts/detect-client-data-version.sh [--no-header] <repo-path> [...] Usage: scripts/bash/detect-client-data-version.sh [--no-header] <repo-path> [...]
Outputs a tab-separated list of repository path, raw version token found in the Outputs a tab-separated list of repository path, raw version token found in the
source tree, and a normalized CLIENT_DATA_VERSION (e.g., v18). source tree, and a normalized CLIENT_DATA_VERSION (e.g., v18.0).
EOF EOF
} }

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose # azerothcore-rm
set -e set -e
echo '🚀 Starting AzerothCore game data setup...' echo '🚀 Starting AzerothCore game data setup...'

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose # azerothcore-rm
set -e set -e
trap 'echo " ❌ SQL helper error (line ${LINENO}): ${BASH_COMMAND}" >&2' ERR trap 'echo " ❌ SQL helper error (line ${LINENO}): ${BASH_COMMAND}" >&2' ERR
@@ -117,8 +117,8 @@ ensure_module_metadata(){
local -a module_py_candidates=( local -a module_py_candidates=(
"${MODULE_HELPER:-}" "${MODULE_HELPER:-}"
"${HELPER_DIR%/*}/modules.py" "${HELPER_DIR%/*}/modules.py"
"/tmp/scripts/modules.py" "/tmp/scripts/python/modules.py"
"/scripts/modules.py" "/scripts/python/modules.py"
) )
local module_py="" local module_py=""

View File

@@ -10,6 +10,11 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
MODULE_HELPER="$SCRIPT_DIR/modules.py" MODULE_HELPER="$SCRIPT_DIR/modules.py"
DEFAULT_ENV_PATH="$PROJECT_ROOT/.env" DEFAULT_ENV_PATH="$PROJECT_ROOT/.env"
ENV_PATH="${MODULES_ENV_PATH:-$DEFAULT_ENV_PATH}" ENV_PATH="${MODULES_ENV_PATH:-$DEFAULT_ENV_PATH}"
TEMPLATE_FILE="$PROJECT_ROOT/.env.template"
source "$PROJECT_ROOT/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_PATH" "$TEMPLATE_FILE")"
BLUE='\033[0;34m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m' BLUE='\033[0;34m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m'
PLAYERBOTS_DB_UPDATE_LOGGED=0 PLAYERBOTS_DB_UPDATE_LOGGED=0
@@ -75,7 +80,7 @@ resolve_manifest_path(){
setup_git_config(){ setup_git_config(){
info "Configuring git identity" info "Configuring git identity"
git config --global user.name "${GIT_USERNAME:-ac-compose}" >/dev/null 2>&1 || true git config --global user.name "${GIT_USERNAME:-$DEFAULT_PROJECT_NAME}" >/dev/null 2>&1 || true
git config --global user.email "${GIT_EMAIL:-noreply@azerothcore.org}" >/dev/null 2>&1 || true git config --global user.email "${GIT_EMAIL:-noreply@azerothcore.org}" >/dev/null 2>&1 || true
} }
@@ -456,8 +461,8 @@ manage_configuration_files(){
load_sql_helper(){ load_sql_helper(){
local helper_paths=( local helper_paths=(
"/scripts/manage-modules-sql.sh" "/scripts/bash/manage-modules-sql.sh"
"/tmp/scripts/manage-modules-sql.sh" "/tmp/scripts/bash/manage-modules-sql.sh"
) )
if [ "${MODULES_LOCAL_RUN:-0}" = "1" ]; then if [ "${MODULES_LOCAL_RUN:-0}" = "1" ]; then
@@ -556,7 +561,7 @@ track_module_state(){
if [ -n "$host_rebuild_sentinel" ]; then if [ -n "$host_rebuild_sentinel" ]; then
printf '%s\n' "${MODULES_COMPILE_LIST[@]}" > "$host_rebuild_sentinel" 2>/dev/null || true printf '%s\n' "${MODULES_COMPILE_LIST[@]}" > "$host_rebuild_sentinel" 2>/dev/null || true
fi fi
echo "🚨 Module changes detected; run ./scripts/rebuild-with-modules.sh to rebuild source images." echo "🚨 Module changes detected; run ./scripts/bash/rebuild-with-modules.sh to rebuild source images."
else else
rm -f "$rebuild_sentinel" 2>/dev/null || true rm -f "$rebuild_sentinel" 2>/dev/null || true
if [ -n "$host_rebuild_sentinel" ]; then if [ -n "$host_rebuild_sentinel" ]; then

View File

@@ -8,6 +8,11 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
ENV_FILE="$PROJECT_ROOT/.env" ENV_FILE="$PROJECT_ROOT/.env"
TEMPLATE_FILE="$PROJECT_ROOT/.env.template"
source "$PROJECT_ROOT/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
read_env_value(){ read_env_value(){
local key="$1" default="$2" value="" local key="$1" default="$2" value=""
@@ -25,17 +30,8 @@ read_env_value(){
resolve_project_name(){ resolve_project_name(){
local raw_name local raw_name
raw_name="$(read_env_value COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" raw_name="$(read_env_value COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
local sanitized project_name::sanitize "$raw_name"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
resolve_project_image(){ resolve_project_image(){
@@ -79,7 +75,7 @@ Options:
--user USER SSH username on remote host (required) --user USER SSH username on remote host (required)
--port PORT SSH port (default: 22) --port PORT SSH port (default: 22)
--identity PATH SSH private key (passed to scp/ssh) --identity PATH SSH private key (passed to scp/ssh)
--project-dir DIR Remote project directory (default: ~/AzerothCore-RealmMaster) --project-dir DIR Remote project directory (default: ~/<project-name>)
--tarball PATH Output path for the image tar (default: ./local-storage/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: <project-dir>/storage) --storage PATH Remote storage directory (default: <project-dir>/storage)
--skip-storage Do not sync the storage directory --skip-storage Do not sync the storage directory
@@ -129,7 +125,7 @@ expand_remote_path(){
esac esac
} }
PROJECT_DIR="${PROJECT_DIR:-/home/${USER}/AzerothCore-RealmMaster}" PROJECT_DIR="${PROJECT_DIR:-/home/${USER}/$(resolve_project_name)}"
PROJECT_DIR="$(expand_remote_path "$PROJECT_DIR")" PROJECT_DIR="$(expand_remote_path "$PROJECT_DIR")"
REMOTE_STORAGE="${REMOTE_STORAGE:-${PROJECT_DIR}/storage}" REMOTE_STORAGE="${REMOTE_STORAGE:-${PROJECT_DIR}/storage}"
REMOTE_STORAGE="$(expand_remote_path "$REMOTE_STORAGE")" REMOTE_STORAGE="$(expand_remote_path "$REMOTE_STORAGE")"

View File

@@ -0,0 +1,49 @@
#!/bin/bash
project_name::extract(){
local file="$1"
if [ -n "$file" ] && [ -f "$file" ]; then
local line value
line="$(grep -E '^COMPOSE_PROJECT_NAME=' "$file" 2>/dev/null | tail -n1)"
if [ -n "$line" ]; then
value="${line#*=}"
value="${value%$'\r'}"
value="$(printf '%s\n' "$value" | awk -F'#' '{print $1}' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
value="${value%\"}"; value="${value#\"}"
value="${value%\'}"; value="${value#\'}"
printf '%s\n' "$value"
fi
fi
}
project_name::resolve(){
local env_file="$1" template_file="$2" value=""
value="$(project_name::extract "$env_file")"
if [ -z "$value" ] && [ -n "$template_file" ]; then
value="$(project_name::extract "$template_file")"
fi
if [ -z "$value" ] && [ -n "${COMPOSE_PROJECT_NAME:-}" ]; then
value="${COMPOSE_PROJECT_NAME}"
fi
if [ -z "$value" ]; then
echo "Error: COMPOSE_PROJECT_NAME not defined in $env_file, $template_file, or environment." >&2
exit 1
fi
printf '%s\n' "$value"
}
project_name::sanitize(){
local raw="$1"
local sanitized
sanitized="$(echo "$raw" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
echo "Error: COMPOSE_PROJECT_NAME '$raw' is invalid after sanitization." >&2
exit 1
fi
if [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
printf '%s\n' "$sanitized"
}

View File

@@ -1,12 +1,17 @@
#!/bin/bash #!/bin/bash
# ac-compose helper to rebuild AzerothCore from source with enabled modules. # azerothcore-rm helper to rebuild AzerothCore from source with enabled modules.
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
ENV_FILE="$PROJECT_DIR/.env" ENV_FILE="$PROJECT_DIR/.env"
TEMPLATE_FILE="$PROJECT_DIR/.env.template"
source "$PROJECT_DIR/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
BLUE='\033[0;34m' BLUE='\033[0;34m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
@@ -98,17 +103,8 @@ ensure_project_image_tag(){
resolve_project_name(){ resolve_project_name(){
local raw_name local raw_name
raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
local sanitized project_name::sanitize "$raw_name"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
resolve_project_image(){ resolve_project_image(){
@@ -158,7 +154,7 @@ ASSUME_YES=0
SOURCE_OVERRIDE="" SOURCE_OVERRIDE=""
SKIP_STOP=0 SKIP_STOP=0
MODULE_HELPER="$PROJECT_DIR/scripts/modules.py" MODULE_HELPER="$PROJECT_DIR/scripts/python/modules.py"
MODULE_STATE_DIR="" MODULE_STATE_DIR=""
declare -a MODULES_COMPILE_LIST=() declare -a MODULES_COMPILE_LIST=()

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# ac-compose source repository setup # azerothcore-rm source repository setup
set -euo pipefail set -euo pipefail
echo '🔧 Setting up AzerothCore source repository...' echo '🔧 Setting up AzerothCore source repository...'
@@ -35,7 +35,7 @@ SOURCE_PATH="${MODULES_REBUILD_SOURCE_PATH:-$SOURCE_PATH_DEFAULT}"
show_client_data_requirement(){ show_client_data_requirement(){
local repo_path="$1" local repo_path="$1"
local detector="$PROJECT_ROOT/scripts/detect-client-data-version.sh" local detector="$PROJECT_ROOT/scripts/bash/detect-client-data-version.sh"
if [ ! -x "$detector" ]; then if [ ! -x "$detector" ]; then
return return
fi fi

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# ac-compose helper to automatically stage modules and trigger source builds when needed. # azerothcore-rm helper to automatically stage modules and trigger source builds when needed.
set -e set -e
@@ -64,8 +64,13 @@ sync_local_staging(){
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")" PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
ENV_FILE="$PROJECT_DIR/.env" ENV_FILE="$PROJECT_DIR/.env"
TEMPLATE_FILE="$PROJECT_DIR/.env.template"
source "$PROJECT_DIR/scripts/bash/project_name.sh"
# Default project name (read from .env or template)
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
DEFAULT_COMPOSE_FILE="$PROJECT_DIR/docker-compose.yml" DEFAULT_COMPOSE_FILE="$PROJECT_DIR/docker-compose.yml"
source "$PROJECT_DIR/scripts/lib/compose_overrides.sh" source "$PROJECT_DIR/scripts/bash/compose_overrides.sh"
usage(){ usage(){
cat <<EOF cat <<EOF
@@ -101,17 +106,8 @@ read_env(){
resolve_project_name(){ resolve_project_name(){
local raw_name local raw_name
raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")"
local sanitized project_name::sanitize "$raw_name"
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
if [ -z "${COMPOSE_FILE:-}" ]; then if [ -z "${COMPOSE_FILE:-}" ]; then

View File

@@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Project: ac-compose # Project: azerothcore-rm
set -e set -e
# Simple profile-aware deploy + health check for profiles-verify/docker-compose.yml # Simple profile-aware deploy + health check for profiles-verify/docker-compose.yml
@@ -13,7 +13,9 @@ err(){ echo -e "${RED}❌ $*${NC}"; }
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
COMPOSE_FILE="$PROJECT_DIR/docker-compose.yml" COMPOSE_FILE="$PROJECT_DIR/docker-compose.yml"
ENV_FILE="" ENV_FILE=""
source "$PROJECT_DIR/scripts/lib/compose_overrides.sh" TEMPLATE_FILE="$PROJECT_DIR/.env.template"
source "$PROJECT_DIR/scripts/bash/project_name.sh"
source "$PROJECT_DIR/scripts/bash/compose_overrides.sh"
PROFILES=(db services-standard client-data modules tools) PROFILES=(db services-standard client-data modules tools)
SKIP_DEPLOY=false SKIP_DEPLOY=false
QUICK=false QUICK=false
@@ -46,20 +48,17 @@ resolve_project_name(){
else else
env_path="$(dirname "$COMPOSE_FILE")/.env" env_path="$(dirname "$COMPOSE_FILE")/.env"
fi fi
local raw_name="" local raw_name
if [ -f "$env_path" ]; then raw_name="$(project_name::resolve "$env_path" "$TEMPLATE_FILE")"
raw_name="$(grep -E '^COMPOSE_PROJECT_NAME=' "$env_path" | tail -n1 | cut -d'=' -f2-)"
fi
if [ -z "$raw_name" ]; then
raw_name="azerothcore-realmmaster"
fi
local sanitized local sanitized
sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')" sanitized="$(echo "$raw_name" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}" sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')" sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster" echo "Error: COMPOSE_PROJECT_NAME is invalid" >&2
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then exit 1
fi
if [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}" sanitized="ac${sanitized}"
fi fi
echo "$sanitized" echo "$sanitized"
@@ -120,21 +119,21 @@ handle_auto_rebuild(){
local auto_rebuild local auto_rebuild
auto_rebuild="$(read_env_value AUTO_REBUILD_ON_DEPLOY "0")" auto_rebuild="$(read_env_value AUTO_REBUILD_ON_DEPLOY "0")"
if [ "$auto_rebuild" != "1" ]; then if [ "$auto_rebuild" != "1" ]; then
warn "Run ./scripts/rebuild-with-modules.sh after preparing your source tree." warn "Run ./scripts/bash/rebuild-with-modules.sh after preparing your source tree."
return 0 return 0
fi fi
local rebuild_source local rebuild_source
rebuild_source="$(read_env_value MODULES_REBUILD_SOURCE_PATH "")" rebuild_source="$(read_env_value MODULES_REBUILD_SOURCE_PATH "")"
info "AUTO_REBUILD_ON_DEPLOY=1; invoking ./scripts/rebuild-with-modules.sh." info "AUTO_REBUILD_ON_DEPLOY=1; invoking ./scripts/bash/rebuild-with-modules.sh."
local cmd=(./scripts/rebuild-with-modules.sh --yes) local cmd=(./scripts/bash/rebuild-with-modules.sh --yes)
if [ -n "$rebuild_source" ]; then if [ -n "$rebuild_source" ]; then
cmd+=(--source "$rebuild_source") cmd+=(--source "$rebuild_source")
fi fi
if "${cmd[@]}"; then if "${cmd[@]}"; then
info "Module rebuild completed." info "Module rebuild completed."
else else
warn "Automatic rebuild failed; run ./scripts/rebuild-with-modules.sh manually." warn "Automatic rebuild failed; run ./scripts/bash/rebuild-with-modules.sh manually."
fi fi
} }

View File

@@ -260,7 +260,7 @@ def write_outputs(state: ModuleCollectionState, output_dir: Path) -> None:
output_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True)
env_lines: List[str] = [ env_lines: List[str] = [
"# Autogenerated by scripts/modules.py", "# Autogenerated by scripts/python/modules.py",
f"# Generated at {state.generated_at.isoformat()}", f"# Generated at {state.generated_at.isoformat()}",
f'export MODULES_MANIFEST="{state.manifest_path}"', f'export MODULES_MANIFEST="{state.manifest_path}"',
f'export MODULES_ENV_PATH="{state.env_path}"', f'export MODULES_ENV_PATH="{state.env_path}"',

View File

@@ -3,13 +3,19 @@ set -e
clear clear
# ============================================== # ==============================================
# ac-compose - Interactive .env generator # azerothcore-rm - Interactive .env generator
# ============================================== # ==============================================
# Mirrors options from scripts/setup-server.sh but targets ac-compose/.env # Mirrors options from scripts/setup-server.sh but targets azerothcore-rm/.env
# Get script directory for template reading # Get script directory for template reading
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Default project name (can be overridden by COMPOSE_PROJECT_NAME in .env)
ENV_FILE="$SCRIPT_DIR/.env"
TEMPLATE_FILE="$SCRIPT_DIR/.env.template"
source "$SCRIPT_DIR/scripts/bash/project_name.sh"
DEFAULT_PROJECT_NAME="$(project_name::resolve "$ENV_FILE" "$TEMPLATE_FILE")"
# ============================================== # ==============================================
# Constants (auto-loaded from .env.template) # Constants (auto-loaded from .env.template)
# ============================================== # ==============================================
@@ -44,17 +50,7 @@ get_template_value() {
} }
sanitize_project_name(){ sanitize_project_name(){
local raw="$1" project_name::sanitize "$1"
local sanitized
sanitized="$(echo "$raw" | tr '[:upper:]' '[:lower:]')"
sanitized="${sanitized// /-}"
sanitized="$(echo "$sanitized" | tr -cd 'a-z0-9_-')"
if [[ -z "$sanitized" ]]; then
sanitized="azerothcore-realmmaster"
elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then
sanitized="ac${sanitized}"
fi
echo "$sanitized"
} }
resolve_project_image_tag(){ resolve_project_image_tag(){
@@ -353,8 +349,8 @@ EOF
# ============================== # ==============================
MODULE_MANIFEST_PATH="$SCRIPT_DIR/config/module-manifest.json" MODULE_MANIFEST_PATH="$SCRIPT_DIR/config/module-manifest.json"
MODULE_MANIFEST_HELPER="$SCRIPT_DIR/scripts/setup_manifest.py" MODULE_MANIFEST_HELPER="$SCRIPT_DIR/scripts/python/setup_manifest.py"
MODULE_PROFILES_HELPER="$SCRIPT_DIR/scripts/setup_profiles.py" MODULE_PROFILES_HELPER="$SCRIPT_DIR/scripts/python/setup_profiles.py"
ENV_TEMPLATE_FILE="$SCRIPT_DIR/.env.template" ENV_TEMPLATE_FILE="$SCRIPT_DIR/.env.template"
declare -a MODULE_KEYS=() declare -a MODULE_KEYS=()
@@ -554,7 +550,7 @@ main(){
Usage: ./setup.sh [options] Usage: ./setup.sh [options]
Description: Description:
Interactive wizard that generates ac-compose/.env for the Interactive wizard that generates azerothcore-rm/.env for the
profiles-based compose. Prompts for deployment type, ports, storage, profiles-based compose. Prompts for deployment type, ports, storage,
MySQL credentials, backup retention, and module presets or manual MySQL credentials, backup retention, and module presets or manual
toggles. toggles.
@@ -790,7 +786,7 @@ EOF
fi fi
show_wow_header show_wow_header
say INFO "This will create ac-compose/.env for compose profiles." say INFO "This will create azerothcore-rm/.env for compose profiles."
# Deployment type # Deployment type
say HEADER "DEPLOYMENT TYPE" say HEADER "DEPLOYMENT TYPE"
@@ -915,7 +911,11 @@ fi
if [ -n "$CLI_STORAGE_PATH" ]; then if [ -n "$CLI_STORAGE_PATH" ]; then
STORAGE_PATH="$CLI_STORAGE_PATH" STORAGE_PATH="$CLI_STORAGE_PATH"
elif [ "$NON_INTERACTIVE" = "1" ]; then elif [ "$NON_INTERACTIVE" = "1" ]; then
if [ "$DEPLOYMENT_TYPE" = "local" ]; then
STORAGE_PATH=$DEFAULT_LOCAL_STORAGE
else
STORAGE_PATH=$DEFAULT_MOUNT_STORAGE STORAGE_PATH=$DEFAULT_MOUNT_STORAGE
fi
else else
echo "1) 💾 ./storage (local)" echo "1) 💾 ./storage (local)"
echo "2) 🌐 /nfs/azerothcore (NFS)" echo "2) 🌐 /nfs/azerothcore (NFS)"
@@ -930,6 +930,7 @@ fi
esac esac
done done
fi fi
say INFO "Storage path set to ${STORAGE_PATH}"
# Backup # Backup
say HEADER "BACKUP CONFIGURATION" say HEADER "BACKUP CONFIGURATION"
@@ -954,7 +955,7 @@ fi
echo "Choose a server configuration preset:" echo "Choose a server configuration preset:"
if [ -x "$SCRIPT_DIR/scripts/parse-config-presets.py" ] && [ -d "$config_dir" ]; then if [ -x "$SCRIPT_DIR/scripts/python/parse-config-presets.py" ] && [ -d "$config_dir" ]; then
while IFS=$'\t' read -r preset_key preset_name preset_desc; do while IFS=$'\t' read -r preset_key preset_name preset_desc; do
[ -n "$preset_key" ] || continue [ -n "$preset_key" ] || continue
CONFIG_PRESET_NAMES["$preset_key"]="$preset_name" CONFIG_PRESET_NAMES["$preset_key"]="$preset_name"
@@ -963,7 +964,7 @@ fi
echo "$menu_index) $preset_name" echo "$menu_index) $preset_name"
echo " $preset_desc" echo " $preset_desc"
menu_index=$((menu_index + 1)) menu_index=$((menu_index + 1))
done < <(python3 "$SCRIPT_DIR/scripts/parse-config-presets.py" list --presets-dir "$config_dir") done < <(python3 "$SCRIPT_DIR/scripts/python/parse-config-presets.py" list --presets-dir "$config_dir")
else else
# Fallback if parser script not available # Fallback if parser script not available
CONFIG_MENU_INDEX[1]="none" CONFIG_MENU_INDEX[1]="none"
@@ -1565,7 +1566,7 @@ fi
{ {
cat <<EOF cat <<EOF
# Generated by ac-compose/setup.sh # Generated by azerothcore-rm/setup.sh
# Compose overrides (set to 1 to include matching file under compose-overrides/) # Compose overrides (set to 1 to include matching file under compose-overrides/)
# mysql-expose.yml -> exposes MySQL externally via COMPOSE_OVERRIDE_MYSQL_EXPOSE_ENABLED # mysql-expose.yml -> exposes MySQL externally via COMPOSE_OVERRIDE_MYSQL_EXPOSE_ENABLED

View File

@@ -175,23 +175,21 @@ print_service(){
module_summary_list(){ module_summary_list(){
if [ ! -f "$ENV_FILE" ]; then if [ ! -f "$ENV_FILE" ]; then
echo "MODULES: (env not found)" echo "(env not found)"
return return
fi fi
local module_vars local module_vars
module_vars="$(grep -E '^MODULE_[A-Z_]+=1' "$ENV_FILE" 2>/dev/null | cut -d'=' -f1)" module_vars="$(grep -E '^MODULE_[A-Z_]+=1' "$ENV_FILE" 2>/dev/null | cut -d'=' -f1)"
if [ -n "$module_vars" ]; then if [ -n "$module_vars" ]; then
echo "MODULES:"
while IFS= read -r mod; do while IFS= read -r mod; do
[ -z "$mod" ] && continue [ -z "$mod" ] && continue
local pretty="${mod#MODULE_}" local pretty="${mod#MODULE_}"
pretty="$(echo "$pretty" | tr '[:upper:]' '[:lower:]' | tr '_' ' ' | sed 's/\b\w/\U&/g')" pretty="$(echo "$pretty" | tr '[:upper:]' '[:lower:]' | tr '_' ' ' | sed 's/\b\w/\U&/g')"
printf "%s\n" "$pretty" printf "%s\n" "$pretty"
done <<< "$module_vars" done <<< "$module_vars"
else else
echo "MODULES: none" echo "none"
fi fi
echo ""
if container_running "ac-worldserver"; then if container_running "ac-worldserver"; then
local playerbot="disabled" local playerbot="disabled"
local module_playerbots local module_playerbots
@@ -208,6 +206,47 @@ module_summary_list(){
fi fi
} }
render_module_ports(){
local modules_raw="$1" ports_raw="$2" net_line="$3"
mapfile -t modules <<< "$modules_raw"
mapfile -t ports_lines <<< "$ports_raw"
local ports=()
for idx in "${!ports_lines[@]}"; do
local line="${ports_lines[$idx]}"
if [ "$idx" -eq 0 ]; then
continue
fi
line="$(echo "$line" | sed 's/^[[:space:]]*//')"
[ -z "$line" ] && continue
ports+=("$line")
done
if [ -n "$net_line" ]; then
ports+=("DOCKER NET: ${net_line##*: }")
fi
local rows="${#modules[@]}"
if [ "${#ports[@]}" -gt "$rows" ]; then
rows="${#ports[@]}"
fi
printf " %-52s %s\n" "MODULES:" "PORTS:"
for ((i=0; i<rows; i++)); do
local left="${modules[i]:-}"
local right="${ports[i]:-}"
if [ -n "$left" ]; then
left="$left"
fi
local port_column=""
if [[ "$right" == DOCKER\ NET:* ]]; then
port_column=" $right"
elif [ -n "$right" ]; then
port_column=" $right"
fi
printf " %-50s %s\n" "$left" "$port_column"
done
}
user_stats(){ user_stats(){
if ! container_running "ac-mysql"; then if ! container_running "ac-mysql"; then
echo -e "USERS: ${RED}Database offline${NC}" echo -e "USERS: ${RED}Database offline${NC}"
@@ -310,11 +349,11 @@ render_snapshot(){
print_service ac-phpmyadmin "phpMyAdmin" print_service ac-phpmyadmin "phpMyAdmin"
print_service ac-keira3 "Keira3" print_service ac-keira3 "Keira3"
echo "" echo ""
module_summary_list local module_block ports_block net_line
echo "" module_block="$(module_summary_list)"
echo "$(ports_summary)" ports_block="$(ports_summary)"
echo "" net_line="$(network_summary)"
echo "$(network_summary)" render_module_ports "$module_block" "$ports_block" "$net_line"
} }
display_snapshot(){ display_snapshot(){