2026-03-04 22:49:01 +00:00
|
|
|
|
#!/bin/bash
|
2026-03-10 22:07:14 +00:00
|
|
|
|
set -euo pipefail # fail fast, treat unset vars as errors, propagate pipe failures
|
2026-03-04 22:49:01 +00:00
|
|
|
|
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# 0️⃣ Source the official WordPress entrypoint
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# This runs the WordPress init *without* starting Apache.
|
|
|
|
|
|
. /usr/local/bin/docker-entrypoint.sh
|
2026-03-05 07:11:01 +00:00
|
|
|
|
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# 1️⃣ Verify core exists (safety net)
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
|
|
|
|
|
if [ ! -d /var/www/html/wp-admin ]; then
|
2026-03-10 22:07:14 +00:00
|
|
|
|
echo "❌ WordPress core missing after docker-entrypoint.sh"
|
|
|
|
|
|
exit 1
|
2026-03-05 07:11:01 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# 2️⃣ Ensure uploads folder is present & writable
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
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
|
2026-03-05 07:11:01 +00:00
|
|
|
|
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# 3️⃣ Wait for DB to be ready (optional but cheap)
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
|
|
|
|
|
until wp db check --path=/var/www/html --allow-root > /dev/null 2>&1; do
|
2026-03-10 22:07:14 +00:00
|
|
|
|
echo "⏳ Waiting for database..."
|
|
|
|
|
|
sleep 2
|
2026-03-05 07:11:01 +00:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-10 22:07:14 +00:00
|
|
|
|
# 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)
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
2026-03-05 00:12:31 +00:00
|
|
|
|
exec /usr/local/bin/docker-entrypoint.sh "$@"
|