diff --git a/diagnose-client-data.sh b/diagnose-client-data.sh new file mode 100644 index 0000000..167ba21 --- /dev/null +++ b/diagnose-client-data.sh @@ -0,0 +1,195 @@ +#!/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/download-client-data.sh b/scripts/download-client-data.sh index c89b64f..a374522 100755 --- a/scripts/download-client-data.sh +++ b/scripts/download-client-data.sh @@ -12,7 +12,14 @@ if [ -n "$REQUESTED_TAG" ]; then LATEST_URL="https://github.com/wowgaming/client-data/releases/download/${REQUESTED_TAG}/data.zip" else echo '📡 Fetching latest client data release info...' - RELEASE_INFO=$(wget -qO- https://api.github.com/repos/wowgaming/client-data/releases/latest 2>/dev/null) + if command -v curl >/dev/null 2>&1; then + RELEASE_INFO=$(curl -sL https://api.github.com/repos/wowgaming/client-data/releases/latest 2>/dev/null) + elif command -v wget >/dev/null 2>&1; then + RELEASE_INFO=$(wget -qO- https://api.github.com/repos/wowgaming/client-data/releases/latest 2>/dev/null) + else + echo '❌ No download tool available to fetch release info (need curl or wget)' + exit 1 + fi if [ -n "$RELEASE_INFO" ]; then LATEST_URL=$(echo "$RELEASE_INFO" | grep '"browser_download_url":' | grep '\.zip' | cut -d'"' -f4 | head -1) @@ -84,26 +91,62 @@ if [ ! -f "data.zip" ]; then --summary-interval=5 --download-result=hide \ --console-log-level=warn --show-console-readout=false \ --dir "$CACHE_DIR" -o "$(basename "$TMP_FILE")" "$LATEST_URL" || { - echo '⚠️ aria2c failed, falling back to wget...' - wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" 2>&1 | sed 's/^/📊 /' || { - echo '❌ wget failed, trying curl...' + echo '⚠️ aria2c failed, falling back to curl...' + if command -v curl >/dev/null 2>&1; then curl -L --progress-bar -o "$TMP_FILE" "$LATEST_URL" || { + echo '❌ curl failed, trying wget...' + if command -v wget >/dev/null 2>&1; then + wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" || { + echo '❌ All download methods failed' + rm -f "$TMP_FILE" + exit 1 + } + else + echo '❌ wget not available, all download methods failed' + rm -f "$TMP_FILE" + exit 1 + fi + } + elif command -v wget >/dev/null 2>&1; then + wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" || { echo '❌ All download methods failed' rm -f "$TMP_FILE" exit 1 } - } + else + echo '❌ No fallback download method available' + rm -f "$TMP_FILE" + exit 1 + fi } else - echo "📥 Using wget (aria2c not available)..." - wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" 2>&1 | sed 's/^/📊 /' || { - echo '❌ wget failed, trying curl...' + # Try curl first since it's more commonly available in minimal containers + if command -v curl >/dev/null 2>&1; then + echo "📥 Using curl (aria2c not available)..." curl -L --progress-bar -o "$TMP_FILE" "$LATEST_URL" || { - echo '❌ All download methods failed' + echo '❌ curl failed, trying wget...' + if command -v wget >/dev/null 2>&1; then + wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" 2>&1 | sed 's/^/📊 /' || { + echo '❌ All download methods failed' + rm -f "$TMP_FILE" + exit 1 + } + else + echo '❌ wget not available, all download methods failed' + exit 1 + fi + } + elif command -v wget >/dev/null 2>&1; then + echo "📥 Using wget (aria2c and curl not available)..." + wget --progress=dot:giga -O "$TMP_FILE" "$LATEST_URL" 2>&1 | sed 's/^/📊 /' || { + echo '❌ wget failed, no other download methods available' rm -f "$TMP_FILE" exit 1 } - } + else + echo '❌ No download tool available (tried aria2c, curl, wget)' + exit 1 + fi fi echo "🔍 Verifying download integrity..." diff --git a/setup.sh b/setup.sh index d0f1a61..2674b24 100755 --- a/setup.sh +++ b/setup.sh @@ -1489,6 +1489,25 @@ EOF rebuild_args+=(--source "$MODULES_REBUILD_SOURCE_PATH_VALUE") if ./scripts/rebuild-with-modules.sh "${rebuild_args[@]}"; then say SUCCESS "Module rebuild completed" + + # Tag the built images as modules-latest so deploy.sh doesn't require another rebuild + if [ "$NEEDS_CXX_REBUILD" = "1" ] || [ "$MODULE_PLAYERBOTS" = "1" ]; then + say INFO "Tagging module images for deployment..." + local source_auth="$AC_AUTHSERVER_IMAGE_PLAYERBOTS_VALUE" + local source_world="$AC_WORLDSERVER_IMAGE_PLAYERBOTS_VALUE" + local target_auth="$AC_AUTHSERVER_IMAGE_MODULES_VALUE" + local target_world="$AC_WORLDSERVER_IMAGE_MODULES_VALUE" + + if docker image inspect "$source_auth" >/dev/null 2>&1; then + docker tag "$source_auth" "$target_auth" + say SUCCESS "Tagged $target_auth from $source_auth" + fi + + if docker image inspect "$source_world" >/dev/null 2>&1; then + docker tag "$source_world" "$target_world" + say SUCCESS "Tagged $target_world from $source_world" + fi + fi else say WARNING "Module rebuild failed; run ./scripts/rebuild-with-modules.sh manually once issues are resolved." fi