From a18e315f1f4dc0757da561fe29900c80b91c0473 Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Sun, 9 Nov 2025 02:48:49 -0500 Subject: [PATCH] refactor: reorganize scripts under bash/python --- .env.template | 8 ++- build.sh | 28 ++++----- cleanup.sh | 29 ++++----- config/module-manifest.json | 2 + config/module-profiles/RealmMaster.json | 3 +- config/module-profiles/all-modules.json | 3 +- deploy.sh | 52 ++++++++-------- docker-compose.yml | 26 ++++---- scripts/{ => bash}/auto-post-install.sh | 2 +- scripts/{ => bash}/backup-export.sh | 0 scripts/{ => bash}/backup-import.sh | 0 scripts/{ => bash}/backup-merge.sh | 0 scripts/{ => bash}/backup-scheduler.sh | 2 +- scripts/{lib => bash}/compose_overrides.sh | 0 scripts/{ => bash}/configure-server.sh | 2 +- scripts/{ => bash}/copy-module-configs.sh | 0 scripts/{ => bash}/db-import-conditional.sh | 2 +- scripts/{ => bash}/deploy-tools.sh | 21 +++---- .../{ => bash}/detect-client-data-version.sh | 4 +- scripts/{ => bash}/download-client-data.sh | 2 +- scripts/{ => bash}/import-database-files.sh | 0 scripts/{ => bash}/manage-modules-sql.sh | 6 +- scripts/{ => bash}/manage-modules.sh | 13 ++-- scripts/{ => bash}/migrate-stack.sh | 22 +++---- scripts/{ => bash}/mysql-entrypoint.sh | 0 scripts/bash/project_name.sh | 49 +++++++++++++++ scripts/{ => bash}/rebuild-with-modules.sh | 22 +++---- scripts/{ => bash}/setup-source.sh | 4 +- scripts/{ => bash}/stage-modules.sh | 22 +++---- scripts/{ => bash}/start-containers.sh | 0 scripts/{ => bash}/stop-containers.sh | 0 scripts/{ => bash}/verify-deployment.sh | 29 +++++---- scripts/{ => python}/apply-config.py | 0 scripts/{ => python}/check_module_staging.py | 0 scripts/{ => python}/modules.py | 2 +- scripts/{ => python}/parse-config-presets.py | 0 scripts/{ => python}/setup_manifest.py | 0 scripts/{ => python}/setup_profiles.py | 0 setup.sh | 43 ++++++------- status.sh | 61 +++++++++++++++---- 40 files changed, 265 insertions(+), 194 deletions(-) rename scripts/{ => bash}/auto-post-install.sh (99%) rename scripts/{ => bash}/backup-export.sh (100%) rename scripts/{ => bash}/backup-import.sh (100%) rename scripts/{ => bash}/backup-merge.sh (100%) rename scripts/{ => bash}/backup-scheduler.sh (99%) rename scripts/{lib => bash}/compose_overrides.sh (100%) rename scripts/{ => bash}/configure-server.sh (98%) rename scripts/{ => bash}/copy-module-configs.sh (100%) rename scripts/{ => bash}/db-import-conditional.sh (99%) rename scripts/{ => bash}/deploy-tools.sh (84%) rename scripts/{ => bash}/detect-client-data-version.sh (92%) rename scripts/{ => bash}/download-client-data.sh (99%) rename scripts/{ => bash}/import-database-files.sh (100%) rename scripts/{ => bash}/manage-modules-sql.sh (99%) rename scripts/{ => bash}/manage-modules.sh (97%) rename scripts/{ => bash}/migrate-stack.sh (95%) rename scripts/{ => bash}/mysql-entrypoint.sh (100%) create mode 100644 scripts/bash/project_name.sh rename scripts/{ => bash}/rebuild-with-modules.sh (96%) rename scripts/{ => bash}/setup-source.sh (97%) rename scripts/{ => bash}/stage-modules.sh (95%) rename scripts/{ => bash}/start-containers.sh (100%) rename scripts/{ => bash}/stop-containers.sh (100%) rename scripts/{ => bash}/verify-deployment.sh (88%) rename scripts/{ => python}/apply-config.py (100%) rename scripts/{ => python}/check_module_staging.py (100%) rename scripts/{ => python}/modules.py (99%) rename scripts/{ => python}/parse-config-presets.py (100%) rename scripts/{ => python}/setup_manifest.py (100%) rename scripts/{ => python}/setup_profiles.py (100%) diff --git a/.env.template b/.env.template index ed3c0ee..d337fc5 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,6 @@ # 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. -# 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/) @@ -13,7 +13,8 @@ COMPOSE_OVERRIDE_WORLDSERVER_DEBUG_LOGGING_ENABLED=0 # ===================== # 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 @@ -157,7 +158,8 @@ MODULES_REQUIRES_PLAYERBOT_SOURCE=0 # ===================== # Client Data Settings # ===================== -CLIENT_DATA_VERSION=v18 +# This is automatically applied, fyi version must match tag exactly +#CLIENT_DATA_VERSION=v18.0 # ===================== # Server Configuration diff --git a/build.sh b/build.sh index 4bb9cf9..6fb48be 100755 --- a/build.sh +++ b/build.sh @@ -8,6 +8,11 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 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 FORCE_REBUILD=0 SKIP_SOURCE_SETUP=0 @@ -95,7 +100,7 @@ update_env_value(){ fi } -MODULE_HELPER="$ROOT_DIR/scripts/modules.py" +MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py" MODULE_STATE_INITIALIZED=0 declare -a MODULES_COMPILE_LIST=() @@ -185,7 +190,7 @@ ensure_source_repo(){ fi 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 exit 1 fi @@ -201,7 +206,7 @@ ensure_source_repo(){ show_client_data_requirement(){ 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 return fi @@ -369,17 +374,8 @@ sync_modules(){ } resolve_project_name(){ - local raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" - local sanitized - 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" + local raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")" + project_name::sanitize "$raw_name" } 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 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" return 1 fi @@ -543,7 +539,7 @@ execute_build(){ info "Building AzerothCore with modules (this may take a while)" 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" else err "Source build failed" diff --git a/cleanup.sh b/cleanup.sh index 8f3b1ba..1f62628 100755 --- a/cleanup.sh +++ b/cleanup.sh @@ -1,10 +1,10 @@ #!/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] -# Project: ac-compose +# Project: azerothcore-rm set -e @@ -13,7 +13,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="${SCRIPT_DIR}" DEFAULT_COMPOSE_FILE="${PROJECT_DIR}/docker-compose.yml" 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=() # Colors @@ -135,23 +140,13 @@ done COMPOSE_BASE="docker compose${COMPOSE_FILE_ARGS_STR}" STORAGE_PATH="${STORAGE_PATH:-$STORAGE_PATH_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(){ - 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 - sanitized="azerothcore-realmmaster" - elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then - sanitized="ac${sanitized}" - fi - echo "$sanitized" + project_name::sanitize "$1" } -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(){ local path="$1" @@ -269,7 +264,7 @@ show_summary() { } main(){ - print_status HEADER "ac-compose CLEANUP" + print_status HEADER "${PROJECT_NAME^^} CLEANUP" if ! command -v docker >/dev/null 2>&1; then print_status ERROR "Docker not found" diff --git a/config/module-manifest.json b/config/module-manifest.json index abfda1a..e608a91 100644 --- a/config/module-manifest.json +++ b/config/module-manifest.json @@ -429,6 +429,8 @@ "name": "StatBooster", "repo": "https://github.com/AnchyDev/StatBooster.git", "type": "cpp", + "status": "blocked", + "block_reason": "Override signature mismatch on OnLootItem", "post_install_hooks": [ "fix-statbooster-api" ], diff --git a/config/module-profiles/RealmMaster.json b/config/module-profiles/RealmMaster.json index 74fcdf9..b7902d5 100644 --- a/config/module-profiles/RealmMaster.json +++ b/config/module-profiles/RealmMaster.json @@ -23,7 +23,6 @@ "MODULE_ASSISTANT", "MODULE_REAGENT_BANK", "MODULE_BLACK_MARKET_AUCTION_HOUSE", - "MODULE_STATBOOSTER", "MODULE_ELUNA_TS", "MODULE_AIO", "MODULE_ELUNA_SCRIPTS", @@ -38,4 +37,4 @@ "label": "\ud83e\udde9 Sam", "description": "Sam's playerbot-centric preset (use high bot counts)", "order": 7 -} \ No newline at end of file +} diff --git a/config/module-profiles/all-modules.json b/config/module-profiles/all-modules.json index 19a9ece..f7e9948 100644 --- a/config/module-profiles/all-modules.json +++ b/config/module-profiles/all-modules.json @@ -76,7 +76,6 @@ "MODULE_SERVER_AUTO_SHUTDOWN", "MODULE_SOLOCRAFT", "MODULE_SOLO_LFG", - "MODULE_STATBOOSTER", "MODULE_SYSTEM_VIP", "MODULE_TEMP_ANNOUNCEMENTS", "MODULE_TIC_TAC_TOE", @@ -95,4 +94,4 @@ "label": "\ud83e\udde9 All Modules", "description": "Enable every optional module in the repository", "order": 5 -} \ No newline at end of file +} diff --git a/deploy.sh b/deploy.sh index 0b13b37..2058651 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,7 +11,12 @@ set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" 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="" WATCH_LOGS=1 KEEP_RUNNING=0 @@ -28,7 +33,7 @@ REMOTE_PROJECT_DIR="" REMOTE_SKIP_STORAGE=0 REMOTE_ARGS_PROVIDED=0 -MODULE_HELPER="$ROOT_DIR/scripts/modules.py" +MODULE_HELPER="$ROOT_DIR/scripts/python/modules.py" MODULE_STATE_INITIALIZED=0 declare -a MODULES_COMPILE_LIST=() declare -a COMPOSE_FILE_ARGS=() @@ -59,7 +64,7 @@ show_realm_ready(){ show_remote_plan(){ local plan_host="${REMOTE_HOST:-}" local plan_user="${REMOTE_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 '%b\n' "${YELLOW}├─ Validate build status locally${NC}" @@ -139,7 +144,7 @@ collect_remote_details(){ fi if [ -z "$REMOTE_PROJECT_DIR" ]; then - REMOTE_PROJECT_DIR="~/AzerothCore-RealmMaster" + REMOTE_PROJECT_DIR="$(get_default_remote_dir)" fi if [ "$interactive" -eq 1 ]; then local dir_input @@ -183,10 +188,10 @@ validate_remote_configuration(){ fi fi if [ -z "$REMOTE_PROJECT_DIR" ]; then - REMOTE_PROJECT_DIR="~/AzerothCore-RealmMaster" + REMOTE_PROJECT_DIR="$(get_default_remote_dir)" fi - if [ ! -f "$ROOT_DIR/scripts/migrate-stack.sh" ]; then - err "Migration script not found: $ROOT_DIR/scripts/migrate-stack.sh" + if [ ! -f "$ROOT_DIR/scripts/bash/migrate-stack.sh" ]; then + err "Migration script not found: $ROOT_DIR/scripts/bash/migrate-stack.sh" exit 1 fi } @@ -208,7 +213,7 @@ Options: --remote-user USER SSH username for remote migration --remote-port PORT SSH port for remote migration (default: 22) --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: ~/) --remote-skip-storage Skip syncing the storage directory during migration --skip-config Skip applying server configuration preset -h, --help Show this help @@ -265,8 +270,8 @@ if [ "$REMOTE_MODE" -eq 1 ]; then exit 1 fi fi - if [ ! -f "$ROOT_DIR/scripts/migrate-stack.sh" ]; then - err "Migration script not found: $ROOT_DIR/scripts/migrate-stack.sh" + if [ ! -f "$ROOT_DIR/scripts/bash/migrate-stack.sh" ]; then + err "Migration script not found: $ROOT_DIR/scripts/bash/migrate-stack.sh" exit 1 fi fi @@ -350,17 +355,12 @@ ensure_module_state(){ } resolve_project_name(){ - local raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" - local sanitized - 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" + local raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")" + project_name::sanitize "$raw_name" +} + +get_default_remote_dir(){ + echo "~/$(resolve_project_name)" } resolve_project_image(){ @@ -605,7 +605,7 @@ run_remote_migration(){ args+=(--yes) 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") fi 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(){ @@ -687,7 +687,7 @@ apply_server_config(){ 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 warn "Configuration script not found or not executable: $config_script" warn "Server will use default settings" @@ -758,7 +758,7 @@ main(){ show_step 2 "$remote_steps" "Migrating deployment to $REMOTE_HOST" if run_remote_migration; then 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:" printf ' %bcd %s && ./deploy.sh --yes --no-watch%b\n' "$YELLOW" "$remote_dir" "$NC" exit 0 @@ -781,7 +781,7 @@ main(){ show_step 3 5 "Importing user database files" 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" info "Pulling images and waiting for containers to become healthy; this may take a few minutes on first deploy." diff --git a/docker-compose.yml b/docker-compose.yml index 987a16d..d60f478 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,7 +21,7 @@ services: entrypoint: - /usr/local/bin/mysql-entrypoint.sh 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 - ${BACKUP_PATH}:/backups - ${HOST_ZONEINFO_PATH}:/usr/share/zoneinfo:ro @@ -65,7 +65,7 @@ services: - ${STORAGE_PATH}/config:/azerothcore/env/dist/etc - ${STORAGE_PATH}/logs:/azerothcore/logs - ${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: AC_DATA_DIR: "/azerothcore/data" 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) echo "📥 Downloading backup scheduler script (local copy preferred if mounted)..." - if [ -f /tmp/scripts/backup-scheduler.sh ]; then - chmod +x /tmp/scripts/backup-scheduler.sh 2>/dev/null || true - bash /tmp/scripts/backup-scheduler.sh + if [ -f /tmp/scripts/bash/backup-scheduler.sh ]; then + chmod +x /tmp/scripts/bash/backup-scheduler.sh 2>/dev/null || true + bash /tmp/scripts/bash/backup-scheduler.sh else echo "No local scheduler provided" fi @@ -269,9 +269,9 @@ services: - -c - | mkdir -p /cache - if [ -f /tmp/scripts/download-client-data.sh ]; then - chmod +x /tmp/scripts/download-client-data.sh 2>/dev/null || true - bash /tmp/scripts/download-client-data.sh + if [ -f /tmp/scripts/bash/download-client-data.sh ]; then + chmod +x /tmp/scripts/bash/download-client-data.sh 2>/dev/null || true + bash /tmp/scripts/bash/download-client-data.sh else echo "No local client-data script" fi @@ -302,9 +302,9 @@ services: echo "📦 Installing 7z for faster extraction..." apt-get update -qq && apt-get install -y p7zip-full mkdir -p /cache - if [ -f /tmp/scripts/download-client-data.sh ]; then - chmod +x /tmp/scripts/download-client-data.sh 2>/dev/null || true - bash /tmp/scripts/download-client-data.sh + if [ -f /tmp/scripts/bash/download-client-data.sh ]; then + chmod +x /tmp/scripts/bash/download-client-data.sh 2>/dev/null || true + bash /tmp/scripts/bash/download-client-data.sh echo "🔧 Fixing ownership of extracted files..." chown -R ${CONTAINER_USER} /azerothcore/data echo "✅ Client data extraction and ownership setup complete" @@ -607,7 +607,7 @@ services: - -c - | 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 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 @@ -659,7 +659,7 @@ services: chown -R ${CONTAINER_USER} /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..." - (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 chown -R ${CONTAINER_USER} /azerothcore/config /install-markers 2>/dev/null || true chmod -R 755 /azerothcore/config /install-markers 2>/dev/null || true diff --git a/scripts/auto-post-install.sh b/scripts/bash/auto-post-install.sh similarity index 99% rename from scripts/auto-post-install.sh rename to scripts/bash/auto-post-install.sh index cdd88b8..4229f23 100755 --- a/scripts/auto-post-install.sh +++ b/scripts/bash/auto-post-install.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose +# azerothcore-rm set -e GREEN='\033[0;32m'; BLUE='\033[0;34m'; NC='\033[0m' diff --git a/scripts/backup-export.sh b/scripts/bash/backup-export.sh similarity index 100% rename from scripts/backup-export.sh rename to scripts/bash/backup-export.sh diff --git a/scripts/backup-import.sh b/scripts/bash/backup-import.sh similarity index 100% rename from scripts/backup-import.sh rename to scripts/bash/backup-import.sh diff --git a/scripts/backup-merge.sh b/scripts/bash/backup-merge.sh similarity index 100% rename from scripts/backup-merge.sh rename to scripts/bash/backup-merge.sh diff --git a/scripts/backup-scheduler.sh b/scripts/bash/backup-scheduler.sh similarity index 99% rename from scripts/backup-scheduler.sh rename to scripts/bash/backup-scheduler.sh index 2a8da91..f4fa685 100755 --- a/scripts/backup-scheduler.sh +++ b/scripts/bash/backup-scheduler.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose +# azerothcore-rm set -e BACKUP_DIR_BASE="/backups" diff --git a/scripts/lib/compose_overrides.sh b/scripts/bash/compose_overrides.sh similarity index 100% rename from scripts/lib/compose_overrides.sh rename to scripts/bash/compose_overrides.sh diff --git a/scripts/configure-server.sh b/scripts/bash/configure-server.sh similarity index 98% rename from scripts/configure-server.sh rename to scripts/bash/configure-server.sh index 91ae48b..3aba34e 100755 --- a/scripts/configure-server.sh +++ b/scripts/bash/configure-server.sh @@ -49,7 +49,7 @@ edit_config() { # Create a minimal template if it doesn't exist cat > "$config_file" << 'EOF' # 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] # Example settings - uncomment and modify as needed diff --git a/scripts/copy-module-configs.sh b/scripts/bash/copy-module-configs.sh similarity index 100% rename from scripts/copy-module-configs.sh rename to scripts/bash/copy-module-configs.sh diff --git a/scripts/db-import-conditional.sh b/scripts/bash/db-import-conditional.sh similarity index 99% rename from scripts/db-import-conditional.sh rename to scripts/bash/db-import-conditional.sh index dab52df..5ac15bd 100755 --- a/scripts/db-import-conditional.sh +++ b/scripts/bash/db-import-conditional.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose +# azerothcore-rm set -e print_help() { diff --git a/scripts/deploy-tools.sh b/scripts/bash/deploy-tools.sh similarity index 84% rename from scripts/deploy-tools.sh rename to scripts/bash/deploy-tools.sh index de3f101..2f66058 100755 --- a/scripts/deploy-tools.sh +++ b/scripts/bash/deploy-tools.sh @@ -1,13 +1,18 @@ #!/bin/bash -# ac-compose helper to deploy phpMyAdmin and Keira3 tooling. +# azerothcore-rm helper to deploy phpMyAdmin and Keira3 tooling. set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." DEFAULT_COMPOSE_FILE="$ROOT_DIR/docker-compose.yml" 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=() BLUE='\033[0;34m' @@ -34,16 +39,8 @@ read_env(){ resolve_project_name(){ local raw_name sanitized - raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" - 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" + raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")" + project_name::sanitize "$raw_name" } init_compose_files(){ diff --git a/scripts/detect-client-data-version.sh b/scripts/bash/detect-client-data-version.sh similarity index 92% rename from scripts/detect-client-data-version.sh rename to scripts/bash/detect-client-data-version.sh index 205b977..4f16424 100755 --- a/scripts/detect-client-data-version.sh +++ b/scripts/bash/detect-client-data-version.sh @@ -9,10 +9,10 @@ set -euo pipefail print_usage() { cat <<'EOF' -Usage: scripts/detect-client-data-version.sh [--no-header] [...] +Usage: scripts/bash/detect-client-data-version.sh [--no-header] [...] 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 } diff --git a/scripts/download-client-data.sh b/scripts/bash/download-client-data.sh similarity index 99% rename from scripts/download-client-data.sh rename to scripts/bash/download-client-data.sh index a374522..6f66fb9 100755 --- a/scripts/download-client-data.sh +++ b/scripts/bash/download-client-data.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose +# azerothcore-rm set -e echo '🚀 Starting AzerothCore game data setup...' diff --git a/scripts/import-database-files.sh b/scripts/bash/import-database-files.sh similarity index 100% rename from scripts/import-database-files.sh rename to scripts/bash/import-database-files.sh diff --git a/scripts/manage-modules-sql.sh b/scripts/bash/manage-modules-sql.sh similarity index 99% rename from scripts/manage-modules-sql.sh rename to scripts/bash/manage-modules-sql.sh index ccb3a6b..fb57a46 100755 --- a/scripts/manage-modules-sql.sh +++ b/scripts/bash/manage-modules-sql.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose +# azerothcore-rm set -e trap 'echo " ❌ SQL helper error (line ${LINENO}): ${BASH_COMMAND}" >&2' ERR @@ -117,8 +117,8 @@ ensure_module_metadata(){ local -a module_py_candidates=( "${MODULE_HELPER:-}" "${HELPER_DIR%/*}/modules.py" - "/tmp/scripts/modules.py" - "/scripts/modules.py" + "/tmp/scripts/python/modules.py" + "/scripts/python/modules.py" ) local module_py="" diff --git a/scripts/manage-modules.sh b/scripts/bash/manage-modules.sh similarity index 97% rename from scripts/manage-modules.sh rename to scripts/bash/manage-modules.sh index 952c55d..5c24b84 100755 --- a/scripts/manage-modules.sh +++ b/scripts/bash/manage-modules.sh @@ -10,6 +10,11 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" MODULE_HELPER="$SCRIPT_DIR/modules.py" DEFAULT_ENV_PATH="$PROJECT_ROOT/.env" 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' PLAYERBOTS_DB_UPDATE_LOGGED=0 @@ -75,7 +80,7 @@ resolve_manifest_path(){ setup_git_config(){ 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 } @@ -456,8 +461,8 @@ manage_configuration_files(){ load_sql_helper(){ local helper_paths=( - "/scripts/manage-modules-sql.sh" - "/tmp/scripts/manage-modules-sql.sh" + "/scripts/bash/manage-modules-sql.sh" + "/tmp/scripts/bash/manage-modules-sql.sh" ) if [ "${MODULES_LOCAL_RUN:-0}" = "1" ]; then @@ -556,7 +561,7 @@ track_module_state(){ if [ -n "$host_rebuild_sentinel" ]; then printf '%s\n' "${MODULES_COMPILE_LIST[@]}" > "$host_rebuild_sentinel" 2>/dev/null || true 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 rm -f "$rebuild_sentinel" 2>/dev/null || true if [ -n "$host_rebuild_sentinel" ]; then diff --git a/scripts/migrate-stack.sh b/scripts/bash/migrate-stack.sh similarity index 95% rename from scripts/migrate-stack.sh rename to scripts/bash/migrate-stack.sh index 84b0783..738a9bb 100755 --- a/scripts/migrate-stack.sh +++ b/scripts/bash/migrate-stack.sh @@ -8,6 +8,11 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" 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(){ local key="$1" default="$2" value="" @@ -25,17 +30,8 @@ read_env_value(){ resolve_project_name(){ local raw_name -raw_name="$(read_env_value COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" - local sanitized - 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" + raw_name="$(read_env_value COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")" + project_name::sanitize "$raw_name" } resolve_project_image(){ @@ -79,7 +75,7 @@ Options: --user USER SSH username on remote host (required) --port PORT SSH port (default: 22) --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: ~/) --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 @@ -129,7 +125,7 @@ expand_remote_path(){ 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")" REMOTE_STORAGE="${REMOTE_STORAGE:-${PROJECT_DIR}/storage}" REMOTE_STORAGE="$(expand_remote_path "$REMOTE_STORAGE")" diff --git a/scripts/mysql-entrypoint.sh b/scripts/bash/mysql-entrypoint.sh similarity index 100% rename from scripts/mysql-entrypoint.sh rename to scripts/bash/mysql-entrypoint.sh diff --git a/scripts/bash/project_name.sh b/scripts/bash/project_name.sh new file mode 100644 index 0000000..23cef14 --- /dev/null +++ b/scripts/bash/project_name.sh @@ -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" +} diff --git a/scripts/rebuild-with-modules.sh b/scripts/bash/rebuild-with-modules.sh similarity index 96% rename from scripts/rebuild-with-modules.sh rename to scripts/bash/rebuild-with-modules.sh index 86c5f32..f0d4b3b 100755 --- a/scripts/rebuild-with-modules.sh +++ b/scripts/bash/rebuild-with-modules.sh @@ -1,12 +1,17 @@ #!/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 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" 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' GREEN='\033[0;32m' @@ -98,17 +103,8 @@ ensure_project_image_tag(){ resolve_project_name(){ local raw_name - raw_name="$(read_env COMPOSE_PROJECT_NAME "azerothcore-realmmaster")" - local sanitized - 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" + raw_name="$(read_env COMPOSE_PROJECT_NAME "$DEFAULT_PROJECT_NAME")" + project_name::sanitize "$raw_name" } resolve_project_image(){ @@ -158,7 +154,7 @@ ASSUME_YES=0 SOURCE_OVERRIDE="" SKIP_STOP=0 -MODULE_HELPER="$PROJECT_DIR/scripts/modules.py" +MODULE_HELPER="$PROJECT_DIR/scripts/python/modules.py" MODULE_STATE_DIR="" declare -a MODULES_COMPILE_LIST=() diff --git a/scripts/setup-source.sh b/scripts/bash/setup-source.sh similarity index 97% rename from scripts/setup-source.sh rename to scripts/bash/setup-source.sh index 673724f..ceae026 100755 --- a/scripts/setup-source.sh +++ b/scripts/bash/setup-source.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ac-compose source repository setup +# azerothcore-rm source repository setup set -euo pipefail echo '🔧 Setting up AzerothCore source repository...' @@ -35,7 +35,7 @@ SOURCE_PATH="${MODULES_REBUILD_SOURCE_PATH:-$SOURCE_PATH_DEFAULT}" show_client_data_requirement(){ 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 return fi diff --git a/scripts/stage-modules.sh b/scripts/bash/stage-modules.sh similarity index 95% rename from scripts/stage-modules.sh rename to scripts/bash/stage-modules.sh index acda9ae..1faa659 100755 --- a/scripts/stage-modules.sh +++ b/scripts/bash/stage-modules.sh @@ -1,6 +1,6 @@ #!/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 @@ -64,8 +64,13 @@ sync_local_staging(){ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" 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" -source "$PROJECT_DIR/scripts/lib/compose_overrides.sh" +source "$PROJECT_DIR/scripts/bash/compose_overrides.sh" usage(){ cat <&2 + exit 1 + fi + if [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then sanitized="ac${sanitized}" fi echo "$sanitized" @@ -120,21 +119,21 @@ handle_auto_rebuild(){ local auto_rebuild auto_rebuild="$(read_env_value AUTO_REBUILD_ON_DEPLOY "0")" 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 fi local rebuild_source rebuild_source="$(read_env_value MODULES_REBUILD_SOURCE_PATH "")" - info "AUTO_REBUILD_ON_DEPLOY=1; invoking ./scripts/rebuild-with-modules.sh." - local cmd=(./scripts/rebuild-with-modules.sh --yes) + info "AUTO_REBUILD_ON_DEPLOY=1; invoking ./scripts/bash/rebuild-with-modules.sh." + local cmd=(./scripts/bash/rebuild-with-modules.sh --yes) if [ -n "$rebuild_source" ]; then cmd+=(--source "$rebuild_source") fi if "${cmd[@]}"; then info "Module rebuild completed." 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 } diff --git a/scripts/apply-config.py b/scripts/python/apply-config.py similarity index 100% rename from scripts/apply-config.py rename to scripts/python/apply-config.py diff --git a/scripts/check_module_staging.py b/scripts/python/check_module_staging.py similarity index 100% rename from scripts/check_module_staging.py rename to scripts/python/check_module_staging.py diff --git a/scripts/modules.py b/scripts/python/modules.py similarity index 99% rename from scripts/modules.py rename to scripts/python/modules.py index dab30e7..40804a3 100755 --- a/scripts/modules.py +++ b/scripts/python/modules.py @@ -260,7 +260,7 @@ def write_outputs(state: ModuleCollectionState, output_dir: Path) -> None: output_dir.mkdir(parents=True, exist_ok=True) env_lines: List[str] = [ - "# Autogenerated by scripts/modules.py", + "# Autogenerated by scripts/python/modules.py", f"# Generated at {state.generated_at.isoformat()}", f'export MODULES_MANIFEST="{state.manifest_path}"', f'export MODULES_ENV_PATH="{state.env_path}"', diff --git a/scripts/parse-config-presets.py b/scripts/python/parse-config-presets.py similarity index 100% rename from scripts/parse-config-presets.py rename to scripts/python/parse-config-presets.py diff --git a/scripts/setup_manifest.py b/scripts/python/setup_manifest.py similarity index 100% rename from scripts/setup_manifest.py rename to scripts/python/setup_manifest.py diff --git a/scripts/setup_profiles.py b/scripts/python/setup_profiles.py similarity index 100% rename from scripts/setup_profiles.py rename to scripts/python/setup_profiles.py diff --git a/setup.sh b/setup.sh index 6db9997..04e1905 100755 --- a/setup.sh +++ b/setup.sh @@ -3,13 +3,19 @@ set -e 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 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) # ============================================== @@ -44,17 +50,7 @@ get_template_value() { } sanitize_project_name(){ - 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 - sanitized="azerothcore-realmmaster" - elif [[ ! "$sanitized" =~ ^[a-z0-9] ]]; then - sanitized="ac${sanitized}" - fi - echo "$sanitized" + project_name::sanitize "$1" } resolve_project_image_tag(){ @@ -353,8 +349,8 @@ EOF # ============================== MODULE_MANIFEST_PATH="$SCRIPT_DIR/config/module-manifest.json" -MODULE_MANIFEST_HELPER="$SCRIPT_DIR/scripts/setup_manifest.py" -MODULE_PROFILES_HELPER="$SCRIPT_DIR/scripts/setup_profiles.py" +MODULE_MANIFEST_HELPER="$SCRIPT_DIR/scripts/python/setup_manifest.py" +MODULE_PROFILES_HELPER="$SCRIPT_DIR/scripts/python/setup_profiles.py" ENV_TEMPLATE_FILE="$SCRIPT_DIR/.env.template" declare -a MODULE_KEYS=() @@ -554,7 +550,7 @@ main(){ Usage: ./setup.sh [options] 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, MySQL credentials, backup retention, and module presets or manual toggles. @@ -790,7 +786,7 @@ EOF fi 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 say HEADER "DEPLOYMENT TYPE" @@ -915,7 +911,11 @@ fi if [ -n "$CLI_STORAGE_PATH" ]; then STORAGE_PATH="$CLI_STORAGE_PATH" elif [ "$NON_INTERACTIVE" = "1" ]; then - STORAGE_PATH=$DEFAULT_MOUNT_STORAGE + if [ "$DEPLOYMENT_TYPE" = "local" ]; then + STORAGE_PATH=$DEFAULT_LOCAL_STORAGE + else + STORAGE_PATH=$DEFAULT_MOUNT_STORAGE + fi else echo "1) 💾 ./storage (local)" echo "2) 🌐 /nfs/azerothcore (NFS)" @@ -930,6 +930,7 @@ fi esac done fi + say INFO "Storage path set to ${STORAGE_PATH}" # Backup say HEADER "BACKUP CONFIGURATION" @@ -954,7 +955,7 @@ fi 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 [ -n "$preset_key" ] || continue CONFIG_PRESET_NAMES["$preset_key"]="$preset_name" @@ -963,7 +964,7 @@ fi echo "$menu_index) $preset_name" echo " $preset_desc" 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 # Fallback if parser script not available CONFIG_MENU_INDEX[1]="none" @@ -1565,7 +1566,7 @@ fi { cat < exposes MySQL externally via COMPOSE_OVERRIDE_MYSQL_EXPOSE_ENABLED diff --git a/status.sh b/status.sh index 307e456..7784f05 100755 --- a/status.sh +++ b/status.sh @@ -175,23 +175,21 @@ print_service(){ module_summary_list(){ if [ ! -f "$ENV_FILE" ]; then - echo "MODULES: (env not found)" + echo "(env not found)" return fi local module_vars module_vars="$(grep -E '^MODULE_[A-Z_]+=1' "$ENV_FILE" 2>/dev/null | cut -d'=' -f1)" if [ -n "$module_vars" ]; then - echo "MODULES:" while IFS= read -r mod; do [ -z "$mod" ] && continue local pretty="${mod#MODULE_}" pretty="$(echo "$pretty" | tr '[:upper:]' '[:lower:]' | tr '_' ' ' | sed 's/\b\w/\U&/g')" - printf " • %s\n" "$pretty" + printf "%s\n" "$pretty" done <<< "$module_vars" else - echo "MODULES: none" + echo "none" fi - echo "" if container_running "ac-worldserver"; then local playerbot="disabled" local module_playerbots @@ -199,7 +197,7 @@ module_summary_list(){ if [ "$module_playerbots" = "1" ]; then playerbot="enabled" if docker inspect --format='{{.State.Status}}' ac-worldserver 2>/dev/null | grep -q "running"; then - playerbot="running" + playerbot="running" fi fi local eluna="disabled" @@ -208,6 +206,47 @@ module_summary_list(){ 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