indy-wp/entrypoint.sh

44 lines
1.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#!/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 "$@"