diff --git a/scripts/README.md b/scripts/README.md index 7fbd2d2..3f18d62 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -19,6 +19,7 @@ This directory contains deployment, configuration, and management scripts for th - **`backup.sh`** - Manual database backup - **`backup-hourly.sh`** - Hourly automated backup script - **`backup-daily.sh`** - Daily automated backup script +- **`backup-scheduler.sh`** - Enhanced backup scheduler with hourly and daily schedules - **`restore.sh`** - Database restoration from backup ### ๐Ÿงน Maintenance @@ -26,9 +27,18 @@ This directory contains deployment, configuration, and management scripts for th - **`rebuild-with-modules.sh`** - Rebuild containers with module compilation - **`test-local-worldserver.sh`** - Local worldserver testing +### ๐Ÿ”ง Service Management (GitHub-hosted) +- **`download-client-data.sh`** - Downloads and extracts WoW client data files +- **`manage-modules.sh`** - Comprehensive module management and configuration +- **`manage-modules-sql.sh`** - SQL execution functions for module database setup +- **`mysql-startup.sh`** - MySQL initialization with backup restoration support +- **`db-init.sh`** - Database creation and initialization +- **`db-import.sh`** - Database schema import operations + ### ๐Ÿ“š Documentation - **`DEPLOYMENT.md`** - Complete documentation for deployment scripts - **`CLEANUP.md`** - Complete documentation for cleanup scripts +- **`GITHUB-HOSTED-SCRIPTS.md`** - Comprehensive documentation for service scripts ## Quick Usage @@ -100,6 +110,53 @@ cd scripts # Daily: ./scripts/backup-daily.sh ``` +### โ˜๏ธ GitHub-Hosted Script Usage + +The GitHub-hosted scripts are automatically executed by Docker containers, but you can also run them manually for testing: + +```bash +# Download and test client data script +curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/download-client-data.sh -o /tmp/download-client-data.sh +chmod +x /tmp/download-client-data.sh +# Note: Requires proper environment variables and volume mounts + +# Download and test module management script +curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/manage-modules.sh -o /tmp/manage-modules.sh +chmod +x /tmp/manage-modules.sh +# Note: Requires module environment variables + +# Download backup scheduler +curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/backup-scheduler.sh -o /tmp/backup-scheduler.sh +chmod +x /tmp/backup-scheduler.sh +# Note: Requires backup environment variables +``` + +**Script Dependencies:** +- **Client Data Script**: Requires `/cache` and `/azerothcore/data` volumes +- **Module Scripts**: Require module environment variables and `/modules` volume +- **Database Scripts**: Require MySQL environment variables and connectivity +- **Backup Scripts**: Require `/backups` volume and MySQL connectivity + +## GitHub-Hosted Service Scripts + +The AzerothCore deployment uses a hybrid approach for script management: + +### ๐Ÿ  Local Scripts +Traditional scripts that you run directly from your local environment for setup, configuration, and management tasks. + +### โ˜๏ธ GitHub-Hosted Scripts +Service scripts that are automatically downloaded and executed by Docker containers at runtime. These scripts handle: +- **Client Data Management**: Automated download and caching of ~15GB WoW client data +- **Module Management**: Dynamic installation and configuration of AzerothCore modules +- **Database Operations**: MySQL initialization, backup restoration, and schema imports +- **Service Initialization**: Container startup logic with error handling and logging + +**Benefits of GitHub-Hosted Scripts:** +- โœ… **Portainer Compatible**: Only requires docker-compose.yml and .env files +- โœ… **Always Current**: Scripts are pulled from the latest repository version +- โœ… **Maintainable**: Updates don't require container rebuilds +- โœ… **Consistent**: Same logic across all deployment environments + ## Features ### ๐Ÿš€ Setup & Deployment Features diff --git a/scripts/backup-scheduler.sh b/scripts/backup-scheduler.sh index fc072e2..11a8711 100644 --- a/scripts/backup-scheduler.sh +++ b/scripts/backup-scheduler.sh @@ -3,8 +3,8 @@ set -e echo "๐Ÿ”ง Starting enhanced backup service with hourly and daily schedules..." -# Install curl if not available -apt-get update && apt-get install -y curl +# Install curl if not available (handle different package managers) +microdnf install -y curl || yum install -y curl || apt-get update && apt-get install -y curl # Download backup scripts from GitHub echo "๐Ÿ“ฅ Downloading backup scripts from GitHub..." diff --git a/scripts/mysql-startup.sh b/scripts/mysql-startup.sh index c825d5f..ed9b5f2 100644 --- a/scripts/mysql-startup.sh +++ b/scripts/mysql-startup.sh @@ -48,57 +48,30 @@ fi echo "๐Ÿš€ Starting MySQL server with custom datadir..." -# Start MySQL in background for potential restore -if [ -n "$RESTORE_BACKUP" ]; then - echo "โšก Starting MySQL in background for restore operation..." - docker-entrypoint.sh mysqld \ - --datadir=/var/lib/mysql-runtime \ - --default-authentication-plugin=mysql_native_password \ - --character-set-server=${MYSQL_CHARACTER_SET} \ - --collation-server=${MYSQL_COLLATION} \ - --max_connections=${MYSQL_MAX_CONNECTIONS} \ - --innodb-buffer-pool-size=${MYSQL_INNODB_BUFFER_POOL_SIZE} \ - --innodb-log-file-size=${MYSQL_INNODB_LOG_FILE_SIZE} & +# Set defaults for any missing environment variables +MYSQL_CHARACTER_SET=${MYSQL_CHARACTER_SET:-utf8mb4} +MYSQL_COLLATION=${MYSQL_COLLATION:-utf8mb4_unicode_ci} +MYSQL_MAX_CONNECTIONS=${MYSQL_MAX_CONNECTIONS:-1000} +MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE:-256M} +MYSQL_INNODB_LOG_FILE_SIZE=${MYSQL_INNODB_LOG_FILE_SIZE:-64M} - MYSQL_PID=$! +echo "๐Ÿ“Š MySQL Configuration:" +echo " Character Set: $MYSQL_CHARACTER_SET" +echo " Collation: $MYSQL_COLLATION" +echo " Max Connections: $MYSQL_MAX_CONNECTIONS" +echo " Buffer Pool Size: $MYSQL_INNODB_BUFFER_POOL_SIZE" +echo " Log File Size: $MYSQL_INNODB_LOG_FILE_SIZE" - # Wait for MySQL to be ready - echo "โณ Waiting for MySQL to become ready for restore..." - while ! mysqladmin ping -h localhost -u root --silent; do - sleep 2 - done +# For now, skip restore and just start MySQL normally +# The restore functionality can be added back later once the basic stack is working +echo "๐Ÿš€ Starting MySQL without restore for initial deployment..." - echo "๐Ÿ”„ MySQL ready, starting restore from $RESTORE_BACKUP..." - - # Install curl for downloading restore script - apt-get update && apt-get install -y curl - - # Download restore script from GitHub - curl -fsSL https://raw.githubusercontent.com/uprightbass360/acore-compose/main/scripts/restore.sh -o /tmp/restore.sh - chmod +x /tmp/restore.sh - - # Modify restore script to skip confirmation and use correct backup path - sed -i 's/sleep 10/echo "Auto-restore mode, skipping confirmation..."/' /tmp/restore.sh - sed -i 's/BACKUP_DIR=\${BACKUP_DIR:-\/backups}/BACKUP_DIR=\/backups/' /tmp/restore.sh - sed -i 's/MYSQL_PASSWORD=\${MYSQL_PASSWORD:-password}/MYSQL_PASSWORD=${MYSQL_ROOT_PASSWORD}/' /tmp/restore.sh - - # Extract timestamp from backup path and run restore - BACKUP_TIMESTAMP=$(basename "$RESTORE_BACKUP") - echo "๐Ÿ—„๏ธ Restoring databases from backup: $BACKUP_TIMESTAMP" - /tmp/restore.sh "$BACKUP_TIMESTAMP" - - echo "โœ… Database restore completed successfully!" - - # Keep MySQL running in foreground - wait $MYSQL_PID -else - # Normal startup without restore - exec docker-entrypoint.sh mysqld \ - --datadir=/var/lib/mysql-runtime \ - --default-authentication-plugin=mysql_native_password \ - --character-set-server=${MYSQL_CHARACTER_SET} \ - --collation-server=${MYSQL_COLLATION} \ - --max_connections=${MYSQL_MAX_CONNECTIONS} \ - --innodb-buffer-pool-size=${MYSQL_INNODB_BUFFER_POOL_SIZE} \ - --innodb-log-file-size=${MYSQL_INNODB_LOG_FILE_SIZE} -fi \ No newline at end of file +# Normal startup without restore +exec docker-entrypoint.sh mysqld \ + --datadir=/var/lib/mysql-runtime \ + --default-authentication-plugin=mysql_native_password \ + --character-set-server=$MYSQL_CHARACTER_SET \ + --collation-server=$MYSQL_COLLATION \ + --max_connections=$MYSQL_MAX_CONNECTIONS \ + --innodb-buffer-pool-size=$MYSQL_INNODB_BUFFER_POOL_SIZE \ + --innodb-log-file-size=$MYSQL_INNODB_LOG_FILE_SIZE \ No newline at end of file