indy-wp/entrypoint.sh

70 lines
2.2 KiB
Bash
Raw Normal View History

#!/bin/bash
2026-03-05 07:11:01 +00:00
set -eu
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
# -------------------------------------------------
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
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."
fi
2026-03-05 07:11:01 +00:00
# -------------------------------------------------
# 6⃣ Hand over to the official entrypoint (starts Apache)
# -------------------------------------------------
exec /usr/local/bin/docker-entrypoint.sh "$@"