indy-wp/entrypoint.sh

44 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
set -euo pipefail # fail fast, treat unset vars as errors, propagate pipe failures
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
# 0⃣ Source the official WordPress entrypoint
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
# This runs the WordPress init *without* starting Apache.
. /usr/local/bin/docker-entrypoint.sh
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
# 1⃣ Verify core exists (safety net)
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
if [ ! -d /var/www/html/wp-admin ]; then
echo "❌ WordPress core missing after docker-entrypoint.sh"
exit 1
2026-03-05 07:11:01 +00:00
fi
# -------------------------------------------------
# 2⃣ Ensure uploads folder is present & writable
2026-03-05 07:11:01 +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
# -------------------------------------------------
# 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
echo "⏳ Waiting for database..."
sleep 2
2026-03-05 07:11:01 +00:00
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)
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
exec /usr/local/bin/docker-entrypoint.sh "$@"