From 9b2f4e26299dd6733064129821c59908f0d0cf45 Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Tue, 28 Oct 2025 18:16:24 -0400 Subject: [PATCH] move sentenel files to local-storage --- build.sh | 12 +- deploy.sh | 17 +-- diagnose-client-data.sh | 195 -------------------------------- scripts/manage-modules.sh | 9 +- scripts/rebuild-with-modules.sh | 11 +- scripts/stage-modules.sh | 8 +- setup.sh | 2 +- verify-deployment.sh | 2 +- 8 files changed, 45 insertions(+), 211 deletions(-) delete mode 100644 diagnose-client-data.sh diff --git a/build.sh b/build.sh index acf45e1..8a02d58 100755 --- a/build.sh +++ b/build.sh @@ -207,7 +207,7 @@ ensure_source_repo(){ # Build state detection (extracted from setup.sh and deploy.sh) modules_need_rebuild(){ local storage_path - storage_path="$(read_env STORAGE_PATH "./storage")" + storage_path="$(read_env STORAGE_PATH_LOCAL "./local-storage")" if [[ "$storage_path" != /* ]]; then storage_path="$ROOT_DIR/$storage_path" fi @@ -376,6 +376,14 @@ stage_modules(){ local host_modules_dir="${storage_path}/modules" export MODULES_HOST_DIR="$host_modules_dir" + # Set up local storage path for build sentinel tracking + local local_storage_path + local_storage_path="$(read_env STORAGE_PATH_LOCAL "./local-storage")" + if [[ "$local_storage_path" != /* ]]; then + local_storage_path="$ROOT_DIR/$local_storage_path" + fi + export LOCAL_STORAGE_SENTINEL_PATH="$local_storage_path/modules/.requires_rebuild" + # Prepare isolated git config for the module script local prev_git_config_global="${GIT_CONFIG_GLOBAL:-}" local git_temp_config="" @@ -556,7 +564,7 @@ main(){ # Clear build sentinel after successful build local storage_path - storage_path="$(read_env STORAGE_PATH "./storage")" + storage_path="$(read_env STORAGE_PATH_LOCAL "./local-storage")" if [[ "$storage_path" != /* ]]; then storage_path="$ROOT_DIR/$storage_path" fi diff --git a/deploy.sh b/deploy.sh index 995b70e..bc631f0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -34,8 +34,8 @@ warn(){ printf '%b\n' "${YELLOW}⚠️ $*${NC}"; } err(){ printf '%b\n' "${RED}❌ $*${NC}"; } show_deployment_header(){ - printf '\n%b\n' "${BLUE}⚔️ AZEROTHCORE REALM DEPLOYMENT ⚔️${NC}" - printf '%b\n' "${BLUE}════════════════════════════════════════${NC}" + printf '\n%b\n' "${BLUE}⚔️ AZEROTHCORE REALM DEPLOYMENT ⚔️${NC}" + printf '%b\n' "${BLUE}═══════════════════════════════════════${NC}" printf '%b\n\n' "${BLUE}🏰 Bringing Your Realm Online 🏰${NC}" } @@ -175,7 +175,7 @@ stop_runtime_stack(){ # Deployment sentinel management mark_deployment_complete(){ local storage_path - storage_path="$(read_env STORAGE_PATH "./storage")" + storage_path="$(read_env STORAGE_PATH_LOCAL "./local-storage")" if [[ "$storage_path" != /* ]]; then storage_path="$ROOT_DIR/$storage_path" fi @@ -186,7 +186,7 @@ mark_deployment_complete(){ modules_need_rebuild(){ local storage_path - storage_path="$(read_env STORAGE_PATH "./storage")" + storage_path="$(read_env STORAGE_PATH_LOCAL "./local-storage")" if [[ "$storage_path" != /* ]]; then storage_path="$ROOT_DIR/$storage_path" fi @@ -196,13 +196,16 @@ modules_need_rebuild(){ # Build prompting logic prompt_build_if_needed(){ - local build_reasons - readarray -t build_reasons < <(detect_build_needed) + local build_reasons_output + build_reasons_output=$(detect_build_needed) - if [ ${#build_reasons[@]} -eq 0 ]; then + if [ -z "$build_reasons_output" ]; then return 0 # No build needed fi + local build_reasons + readarray -t build_reasons <<< "$build_reasons_output" + # Check if auto-rebuild is enabled local auto_rebuild auto_rebuild="$(read_env AUTO_REBUILD_ON_DEPLOY "0")" diff --git a/diagnose-client-data.sh b/diagnose-client-data.sh deleted file mode 100644 index 167ba21..0000000 --- a/diagnose-client-data.sh +++ /dev/null @@ -1,195 +0,0 @@ -#!/bin/bash -# -# Diagnostic script to identify why client-data extraction fails on Debian -# but works on Ubuntu -# - -set -e - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' - -info() { echo -e "${BLUE}[INFO]${NC} $*"; } -ok() { echo -e "${GREEN}[PASS]${NC} $*"; } -warn() { echo -e "${YELLOW}[WARN]${NC} $*"; } -fail() { echo -e "${RED}[FAIL]${NC} $*"; } - -echo "========================================" -echo " Client-Data Extraction Diagnostics" -echo "========================================" -echo "" - -# Test 1: System Information -info "Test 1: System Information" -echo " OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)" -echo " Kernel: $(uname -r)" -echo " Host date: $(date)" -echo "" - -# Test 2: Docker Version -info "Test 2: Docker Version" -docker version --format '{{.Server.Version}}' && ok "Docker installed" || fail "Docker not found" -echo " Docker version: $(docker version --format '{{.Server.Version}}')" -echo "" - -# Test 3: Docker Configuration -info "Test 3: Docker Configuration" -if [ -f /etc/docker/daemon.json ]; then - ok "Found custom Docker config" - echo " Config:" - cat /etc/docker/daemon.json | sed 's/^/ /' -else - warn "No custom Docker config found (using defaults)" -fi -echo "" - -# Test 4: Host DNS Configuration -info "Test 4: Host DNS Configuration" -echo " Nameservers:" -cat /etc/resolv.conf | grep nameserver | sed 's/^/ /' -echo "" - -# Test 5: Container DNS Resolution -info "Test 5: Container DNS Resolution" -echo " Testing DNS inside Ubuntu 22.04 container..." -if docker run --rm ubuntu:22.04 sh -c "cat /etc/resolv.conf" >/dev/null 2>&1; then - docker run --rm ubuntu:22.04 cat /etc/resolv.conf | sed 's/^/ /' - ok "Container DNS configured" -else - fail "Container DNS check failed" -fi -echo "" - -# Test 6: Network Connectivity -info "Test 6: Network Connectivity to Ubuntu Repos" -echo " Pinging archive.ubuntu.com..." -if docker run --rm ubuntu:22.04 sh -c "apt-get update -qq && apt-get install -y iputils-ping >/dev/null 2>&1 && ping -c 2 archive.ubuntu.com" >/dev/null 2>&1; then - ok "Can reach archive.ubuntu.com" -else - warn "Cannot reach archive.ubuntu.com (may be network/DNS issue)" -fi -echo "" - -# Test 7: Container Date/Time -info "Test 7: Container Date/Time Sync" -HOST_DATE=$(date +%s) -CONTAINER_DATE=$(docker run --rm ubuntu:22.04 date +%s) -DATE_DIFF=$((HOST_DATE - CONTAINER_DATE)) -if [ ${DATE_DIFF#-} -lt 10 ]; then - ok "Container time synced (diff: ${DATE_DIFF}s)" -else - warn "Container time out of sync (diff: ${DATE_DIFF}s)" -fi -echo " Host: $(date)" -echo " Container: $(docker run --rm ubuntu:22.04 date)" -echo "" - -# Test 8: apt-get update (Default DNS) -info "Test 8: apt-get update with default DNS" -echo " Running apt-get update inside container..." -if docker run --rm ubuntu:22.04 apt-get update >/dev/null 2>&1; then - ok "apt-get update succeeded with default DNS" -else - fail "apt-get update failed with default DNS" - echo " Error output:" - docker run --rm ubuntu:22.04 apt-get update 2>&1 | grep -E "Err:|W:|E:" | head -5 | sed 's/^/ /' -fi -echo "" - -# Test 9: apt-get update (Google DNS) -info "Test 9: apt-get update with Google DNS (8.8.8.8)" -echo " Running apt-get update with --dns 8.8.8.8..." -if docker run --rm --dns 8.8.8.8 ubuntu:22.04 apt-get update >/dev/null 2>&1; then - ok "apt-get update succeeded with Google DNS" - echo " ✓ FIX: Adding dns: [8.8.8.8, 8.8.4.4] to docker-compose.yml should work" -else - fail "apt-get update failed even with Google DNS" - echo " Error output:" - docker run --rm --dns 8.8.8.8 ubuntu:22.04 apt-get update 2>&1 | grep -E "Err:|W:|E:" | head -5 | sed 's/^/ /' -fi -echo "" - -# Test 10: wget availability in base image -info "Test 10: Check if wget/curl exists in client-data image" -IMAGE="uprightbass360/azerothcore-wotlk-playerbots:client-data-Playerbot" -if docker image inspect "$IMAGE" >/dev/null 2>&1; then - echo " Checking for download tools in $IMAGE..." - if docker run --rm "$IMAGE" sh -c "which wget" 2>/dev/null; then - ok "wget found in base image" - else - warn "wget not found in base image" - fi - if docker run --rm "$IMAGE" sh -c "which curl" 2>/dev/null; then - ok "curl found in base image" - else - warn "curl not found in base image" - fi - if docker run --rm "$IMAGE" sh -c "which aria2c" 2>/dev/null; then - ok "aria2c found in base image" - else - warn "aria2c not found in base image" - fi -else - warn "Image $IMAGE not found locally" -fi -echo "" - -# Test 11: GitHub connectivity -info "Test 11: GitHub Connectivity" -echo " Testing connection to github.com..." -if docker run --rm alpine:latest sh -c "apk add --no-cache curl >/dev/null 2>&1 && curl -I https://github.com 2>&1" | grep -q "HTTP/"; then - ok "Can reach github.com" -else - fail "Cannot reach github.com" -fi -echo "" - -# Test 12: Download test (small file) -info "Test 12: Download Test (small file from GitHub)" -echo " Attempting to download a small file from GitHub releases..." -TEST_URL="https://github.com/wowgaming/client-data/releases/latest" -if docker run --rm alpine:latest sh -c "apk add --no-cache curl >/dev/null 2>&1 && curl -sL '$TEST_URL' >/dev/null" 2>&1; then - ok "Successfully accessed GitHub releases" -else - fail "Failed to access GitHub releases" -fi -echo "" - -# Summary -echo "========================================" -echo " Summary & Recommendations" -echo "========================================" -echo "" - -# Provide recommendations based on test results -if docker run --rm --dns 8.8.8.8 ubuntu:22.04 apt-get update >/dev/null 2>&1; then - echo "✓ RECOMMENDATION: Add Google DNS to docker-compose.yml" - echo "" - echo "Add this to the ac-client-data-playerbots service in docker-compose.yml:" - echo "" - echo " ac-client-data-playerbots:" - echo " dns:" - echo " - 8.8.8.8" - echo " - 8.8.4.4" - echo " # ... rest of config" - echo "" -elif ! docker run --rm ubuntu:22.04 apt-get update >/dev/null 2>&1; then - echo "⚠ RECOMMENDATION: Use manual download method" - echo "" - echo "The apt-get update is failing even with Google DNS." - echo "Use manual download:" - echo "" - echo " cd /tmp" - echo " wget https://github.com/wowgaming/client-data/releases/download/v17/data.zip" - echo " docker volume create ac-client-data" - echo " docker run --rm -v ac-client-data:/data -v /tmp:/host alpine:latest \\" - echo " sh -c 'apk add --no-cache unzip && cd /data && unzip /host/data.zip'" - echo "" -else - ok "All tests passed - extraction should work" -fi - -echo "========================================" diff --git a/scripts/manage-modules.sh b/scripts/manage-modules.sh index 1433a18..0cf964c 100755 --- a/scripts/manage-modules.sh +++ b/scripts/manage-modules.sh @@ -825,7 +825,14 @@ fi echo 'Module management complete.' if [ "$MODULES_LOCAL_RUN" = "1" ]; then - REBUILD_SENTINEL="./.requires_rebuild" + # When running locally, use local-storage for build state tracking + local local_storage_path="${LOCAL_STORAGE_SENTINEL_PATH:-}" + if [ -n "$local_storage_path" ]; then + REBUILD_SENTINEL="$local_storage_path" + else + # Fallback to current directory if no path provided (legacy behavior) + REBUILD_SENTINEL="./.requires_rebuild" + fi else REBUILD_SENTINEL="/modules/.requires_rebuild" fi diff --git a/scripts/rebuild-with-modules.sh b/scripts/rebuild-with-modules.sh index 69b9912..977a090 100755 --- a/scripts/rebuild-with-modules.sh +++ b/scripts/rebuild-with-modules.sh @@ -128,8 +128,13 @@ STORAGE_PATH="$(read_env STORAGE_PATH "./storage")" if [[ "$STORAGE_PATH" != /* ]]; then STORAGE_PATH="$PROJECT_DIR/${STORAGE_PATH#./}" fi +# Build sentinel is tracked in local storage +LOCAL_STORAGE_PATH="$(read_env STORAGE_PATH_LOCAL "./local-storage")" +if [[ "$LOCAL_STORAGE_PATH" != /* ]]; then + LOCAL_STORAGE_PATH="$PROJECT_DIR/$LOCAL_STORAGE_PATH" +fi MODULES_DIR="$STORAGE_PATH/modules" -SENTINEL_FILE="$MODULES_DIR/.requires_rebuild" +SENTINEL_FILE="$LOCAL_STORAGE_PATH/modules/.requires_rebuild" STORAGE_PATH_ABS="$STORAGE_PATH" @@ -166,11 +171,11 @@ SHARED_MODULES_DIR="$STORAGE_PATH/modules" if [ -d "$LOCAL_MODULES_DIR" ]; then echo "🔧 Using modules from source directory: $LOCAL_MODULES_DIR" MODULES_DIR="$LOCAL_MODULES_DIR" - SENTINEL_FILE="$LOCAL_MODULES_DIR/.requires_rebuild" + # Build sentinel always stays in local storage for consistency else echo "🔧 Using modules from shared storage: $SHARED_MODULES_DIR" MODULES_DIR="$SHARED_MODULES_DIR" - SENTINEL_FILE="$SHARED_MODULES_DIR/.requires_rebuild" + # Build sentinel always stays in local storage for consistency fi SOURCE_COMPOSE="$REBUILD_SOURCE_PATH/docker-compose.yml" diff --git a/scripts/stage-modules.sh b/scripts/stage-modules.sh index 4265bfb..88acc5a 100755 --- a/scripts/stage-modules.sh +++ b/scripts/stage-modules.sh @@ -98,7 +98,13 @@ if [[ "$STORAGE_PATH" != /* ]]; then STORAGE_PATH="$PROJECT_DIR/$STORAGE_PATH" fi MODULES_DIR="$STORAGE_PATH/modules" -SENTINEL_FILE="$MODULES_DIR/.requires_rebuild" + +# Build sentinel is in local storage, deployment modules are in shared storage +LOCAL_STORAGE_PATH="$(read_env STORAGE_PATH_LOCAL "./local-storage")" +if [[ "$LOCAL_STORAGE_PATH" != /* ]]; then + LOCAL_STORAGE_PATH="$PROJECT_DIR/$LOCAL_STORAGE_PATH" +fi +SENTINEL_FILE="$LOCAL_STORAGE_PATH/modules/.requires_rebuild" # Define module mappings (from rebuild-with-modules.sh) declare -A MODULE_REPO_MAP=( diff --git a/setup.sh b/setup.sh index 4c0408f..e4d5b9e 100755 --- a/setup.sh +++ b/setup.sh @@ -1107,7 +1107,7 @@ fi fi # Set build sentinel to indicate rebuild is needed - local storage_abs="$STORAGE_PATH" + local storage_abs="$STORAGE_PATH_LOCAL" if [[ "$storage_abs" != /* ]]; then storage_abs="$(cd "$(dirname "$0")" && pwd)/$storage_abs" fi diff --git a/verify-deployment.sh b/verify-deployment.sh index 9dd57c6..0f3e05f 100755 --- a/verify-deployment.sh +++ b/verify-deployment.sh @@ -98,7 +98,7 @@ read_env_value(){ handle_auto_rebuild(){ local storage_path - storage_path="$(read_env_value STORAGE_PATH "./storage")" + storage_path="$(read_env_value STORAGE_PATH_LOCAL "./local-storage")" if [[ "$storage_path" != /* ]]; then storage_path="$(dirname "$COMPOSE_FILE")/$storage_path" fi