indy-wp/entrypoint.sh

70 lines
2.2 KiB
Bash
Executable File
Raw 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.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
set -eu
# -------------------------------------------------
# 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
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
# -------------------------------------------------
# 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
# -------------------------------------------------
# 6⃣ Hand over to the official entrypoint (starts Apache)
# -------------------------------------------------
exec /usr/local/bin/docker-entrypoint.sh "$@"