2026-03-04 22:49:01 +00:00
|
|
|
|
#!/bin/bash
|
2026-03-05 07:11:01 +00:00
|
|
|
|
set -eu
|
2026-03-04 22:49:01 +00:00
|
|
|
|
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
|
|
|
|
|
# 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
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-04 22:49:01 +00:00
|
|
|
|
if [ ! -f /var/www/html/wp-config.php ]; then
|
2026-03-05 07:11:01 +00:00
|
|
|
|
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
|
2026-03-04 22:49:01 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
|
|
|
|
|
# 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."
|
2026-03-05 00:12:31 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
2026-03-05 07:11:01 +00:00
|
|
|
|
# -------------------------------------------------
|
|
|
|
|
|
# 6️⃣ Hand over to the official entrypoint (starts Apache)
|
|
|
|
|
|
# -------------------------------------------------
|
2026-03-05 00:12:31 +00:00
|
|
|
|
exec /usr/local/bin/docker-entrypoint.sh "$@"
|