#!/bin/bash set -eu # ------------------------------------------------- # 0️⃣ Run the official WordPress entrypoint first # ------------------------------------------------- docker-entrypoint.sh "$@" # ------------------------------------------------- # 1️⃣ Verify core exists # ------------------------------------------------- if [ ! -d /var/www/html/wp-admin ]; then echo "❌ WordPress core missing after docker-entrypoint.sh" exit 1 fi # ------------------------------------------------- # 2️⃣ wp-config.php # ------------------------------------------------- if [ ! -f /var/www/html/wp-config.php ]; then echo "⚙️ Creating wp-config.php..." wp config create \ --dbname="${WORDPRESS_DB_NAME}" \ --dbuser="${WORDPRESS_DB_USER}" \ --dbpass="${WORDPRESS_DB_PASSWORD}" \ --dbhost="${WORDPRESS_DB_HOST}" \ --path=/var/www/html \ --allow-root fi sed -i '/^?>/d' /var/www/html/wp-config.php echo "define('FS_METHOD','direct');" >> /var/www/html/wp-config.php # ------------------------------------------------- # 3️⃣ Wait for DB to be ready # ------------------------------------------------- until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do echo "⏳ Waiting for database..." sleep 2 done # ------------------------------------------------- # 4️⃣ Install core if not already installed # ------------------------------------------------- if ! wp core is-installed --path=/var/www/html --allow-root; then echo "🚀 Installing WordPress core..." wp core install \ --url="http://localhost" \ --title="IndyMedia" \ --admin_user=admin \ --admin_password=admin123 \ --admin_email=admin@example.com \ --skip-email \ --allow-root fi # ------------------------------------------------- # 5️⃣ Activate our custom theme (force) # ------------------------------------------------- if wp theme is-installed indywp --allow-root; then wp theme activate indywp --allow-root else echo "⚠️ indywp theme not found – check Dockerfile copy step." fi # ------------------------------------------------- # 6️⃣ Hand over to the official entrypoint (starts Apache) # ------------------------------------------------- exec /usr/local/bin/docker-entrypoint.sh "$@"