#!/bin/bash set -euo pipefail # fail fast, treat unset vars as errors, propagate pipe failures # ------------------------------------------------- # 0️⃣ Source the official WordPress entrypoint # ------------------------------------------------- # This runs the WordPress init *without* starting Apache. . /usr/local/bin/docker-entrypoint.sh # ------------------------------------------------- # 1️⃣ Verify core exists (safety net) # ------------------------------------------------- if [ ! -d /var/www/html/wp-admin ]; then echo "❌ WordPress core missing after docker-entrypoint.sh" exit 1 fi # ------------------------------------------------- # 2️⃣ Ensure uploads folder is present & writable # ------------------------------------------------- mkdir -p /var/www/html/wp-content/uploads chmod 775 /var/www/html/wp-content/uploads chown -R www-data:www-data /var/www/html/wp-content/uploads # ------------------------------------------------- # 3️⃣ Wait for DB to be ready (optional but cheap) # ------------------------------------------------- until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do echo "⏳ Waiting for database..." sleep 2 done # ------------------------------------------------- # 4️⃣ Run the theme installer (once) # ------------------------------------------------- if ! wp theme is-installed indy-wp-theme --allow-root --path=/var/www/html; then /usr/local/bin/entrypoint-theme.sh fi # ------------------------------------------------- # 5️⃣ Hand control back to the official entrypoint (starts Apache) # ------------------------------------------------- exec /usr/local/bin/docker-entrypoint.sh "$@"