refactoring and adding automations

This commit is contained in:
Deckard
2025-10-17 01:40:50 -04:00
parent 4bf22d1829
commit 859a214e12
65 changed files with 4622 additions and 956 deletions

View File

@@ -1,11 +1,12 @@
#!/bin/bash
# ac-compose
set -e
echo "🚀 AzerothCore Auto Post-Install Configuration"
echo "=============================================="
# Install required packages
apk add --no-cache curl mysql-client bash docker-cli-compose jq
apk add --no-cache curl mysql-client bash docker-cli-compose jq || apk add --no-cache curl mysql-client bash jq
# Create install markers directory
mkdir -p /install-markers
@@ -15,7 +16,6 @@ if [ -f "/install-markers/post-install-completed" ]; then
echo "✅ Post-install configuration already completed"
echo " Marker file found: /install-markers/post-install-completed"
echo "🔄 To re-run post-install configuration, delete the marker file and restart this container"
echo "📝 Command: docker exec ${CONTAINER_POST_INSTALL} rm -f /install-markers/post-install-completed"
echo ""
echo "🏃 Keeping container alive for manual operations..."
tail -f /dev/null
@@ -50,8 +50,6 @@ else
if [ ! -f "/azerothcore/config/authserver.conf" ] || [ ! -f "/azerothcore/config/worldserver.conf" ]; then
echo "❌ Configuration files not found after waiting"
echo " Expected: /azerothcore/config/authserver.conf"
echo " Expected: /azerothcore/config/worldserver.conf"
exit 1
fi
@@ -59,126 +57,34 @@ else
echo ""
echo "🔧 Step 1: Updating configuration files..."
# Download and execute update-config.sh
curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/update-config.sh -o /tmp/update-config.sh
chmod +x /tmp/update-config.sh
# Update DB connection lines and any necessary settings directly with sed
sed -i "s|^LoginDatabaseInfo *=.*|LoginDatabaseInfo = \"${MYSQL_HOST};${MYSQL_PORT};${MYSQL_USER};${MYSQL_ROOT_PASSWORD};${DB_AUTH_NAME}\"|" /azerothcore/config/authserver.conf || true
sed -i "s|^LoginDatabaseInfo *=.*|LoginDatabaseInfo = \"${MYSQL_HOST};${MYSQL_PORT};${MYSQL_USER};${MYSQL_ROOT_PASSWORD};${DB_AUTH_NAME}\"|" /azerothcore/config/worldserver.conf || true
sed -i "s|^WorldDatabaseInfo *=.*|WorldDatabaseInfo = \"${MYSQL_HOST};${MYSQL_PORT};${MYSQL_USER};${MYSQL_ROOT_PASSWORD};${DB_WORLD_NAME}\"|" /azerothcore/config/worldserver.conf || true
sed -i "s|^CharacterDatabaseInfo *=.*|CharacterDatabaseInfo = \"${MYSQL_HOST};${MYSQL_PORT};${MYSQL_USER};${MYSQL_ROOT_PASSWORD};${DB_CHARACTERS_NAME}\"|" /azerothcore/config/worldserver.conf || true
# Modify script to use container environment
sed -i 's|docker-compose-azerothcore-services.env|/project/docker-compose-azerothcore-services.env|' /tmp/update-config.sh
sed -i 's|CONFIG_DIR="${STORAGE_PATH}/config"|CONFIG_DIR="/azerothcore/config"|' /tmp/update-config.sh
# Execute update-config.sh
cd /project
/tmp/update-config.sh
if [ $? -eq 0 ]; then
echo "✅ Configuration files updated successfully"
else
echo "❌ Failed to update configuration files"
exit 1
fi
echo "✅ Configuration files updated"
# Step 2: Update realmlist table
echo ""
echo "🌐 Step 2: Updating realmlist table..."
mysql -h "${MYSQL_HOST}" -u"${MYSQL_USER}" -p"${MYSQL_ROOT_PASSWORD}" --skip-ssl-verify "${DB_AUTH_NAME}" -e "
UPDATE realmlist SET address='${SERVER_ADDRESS}', port=${REALM_PORT} WHERE id=1;
" || echo "⚠️ Could not update realmlist table"
# Download and execute update-realmlist.sh
curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/update-realmlist.sh -o /tmp/update-realmlist.sh
chmod +x /tmp/update-realmlist.sh
echo "✅ Realmlist updated"
# Modify script to use container environment
sed -i 's|docker-compose-azerothcore-services.env|/project/docker-compose-azerothcore-services.env|' /tmp/update-realmlist.sh
# Replace all docker exec mysql commands with direct mysql commands
sed -i "s|docker exec ac-mysql mysql -u \"\${MYSQL_USER}\" -p\"\${MYSQL_ROOT_PASSWORD}\" \"\${DB_AUTH_NAME}\"|mysql -h \"${MYSQL_HOST}\" -u\"${MYSQL_USER}\" -p\"${MYSQL_ROOT_PASSWORD}\" --skip-ssl-verify \"${DB_AUTH_NAME}\"|g" /tmp/update-realmlist.sh
sed -i "s|docker exec ac-mysql mysql -u \"\${MYSQL_USER}\" -p\"\${MYSQL_ROOT_PASSWORD}\"|mysql -h \"${MYSQL_HOST}\" -u\"${MYSQL_USER}\" -p\"${MYSQL_ROOT_PASSWORD}\" --skip-ssl-verify|g" /tmp/update-realmlist.sh
# Execute update-realmlist.sh
cd /project
/tmp/update-realmlist.sh
if [ $? -eq 0 ]; then
echo "✅ Realmlist table updated successfully"
else
echo "❌ Failed to update realmlist table"
exit 1
fi
# Step 3: Restart services to apply changes
echo ""
echo " Step 3: Restarting services to apply changes..."
echo "📝 Configuration changes have been applied to files"
echo "🔄 Restarting authserver and worldserver to pick up new configuration..."
# Detect container runtime (Docker or Podman)
CONTAINER_CMD=""
if command -v docker >/dev/null 2>&1; then
# Check if we can connect to Docker daemon
if docker version >/dev/null 2>&1; then
CONTAINER_CMD="docker"
echo "🐳 Detected Docker runtime"
fi
fi
if [ -z "$CONTAINER_CMD" ] && command -v podman >/dev/null 2>&1; then
# Check if we can connect to Podman
if podman version >/dev/null 2>&1; then
CONTAINER_CMD="podman"
echo "🦭 Detected Podman runtime"
fi
fi
if [ -z "$CONTAINER_CMD" ]; then
echo "⚠️ No container runtime detected (docker/podman) - skipping restart"
else
# Restart authserver
if [ -n "$CONTAINER_AUTHSERVER" ]; then
echo "🔄 Restarting authserver container: $CONTAINER_AUTHSERVER"
if $CONTAINER_CMD restart "$CONTAINER_AUTHSERVER" 2>/dev/null; then
echo "✅ Authserver restarted successfully"
else
echo "⚠️ Failed to restart authserver (may not be running yet)"
fi
fi
# Restart worldserver
if [ -n "$CONTAINER_WORLDSERVER" ]; then
echo "🔄 Restarting worldserver container: $CONTAINER_WORLDSERVER"
if $CONTAINER_CMD restart "$CONTAINER_WORLDSERVER" 2>/dev/null; then
echo "✅ Worldserver restarted successfully"
else
echo "⚠️ Failed to restart worldserver (may not be running yet)"
fi
fi
fi
echo "✅ Service restart completed"
echo " Step 3: (Optional) Restart services to apply changes — handled externally"
# Create completion marker
echo "$(date)" > /install-markers/post-install-completed
echo "NEW_INSTALL_DATE=$(date)" >> /install-markers/post-install-completed
echo "CONFIG_FILES_UPDATED=true" >> /install-markers/post-install-completed
echo "REALMLIST_UPDATED=true" >> /install-markers/post-install-completed
echo "SERVICES_RESTARTED=true" >> /install-markers/post-install-completed
echo ""
echo "🎉 Auto post-install configuration completed successfully!"
echo ""
echo "📋 Summary of changes:"
echo " ✅ AuthServer configured with production database settings"
echo " ✅ WorldServer configured with production database settings"
echo " ✅ Realmlist updated with server address: ${SERVER_ADDRESS}:${REALM_PORT}"
echo " ✅ Services restarted to apply changes"
echo " ✅ Completion marker created: /install-markers/post-install-completed"
echo ""
echo "🎮 Your AzerothCore server is now ready for production!"
echo " Players can connect to: ${SERVER_ADDRESS}:${REALM_PORT}"
echo ""
echo "💡 Next steps:"
echo " 1. Create admin accounts using the worldserver console"
echo " 2. Test client connectivity"
echo " 3. Configure any additional modules as needed"
echo ""
echo "🏃 Keeping container alive for future manual operations..."
tail -f /dev/null
fi
fi