indy-wp/entrypoint-theme.sh

41 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode 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.

#!/usr/bin/env bash
set -euo pipefail
# -------------------------------------------------
# Wait for wp-config.php (core ready)
# -------------------------------------------------
while [ ! -f /var/www/html/wp-config.php ]; do
echo "⏳ Waiting for WordPress core to be ready..."
sleep 2
done
# -------------------------------------------------
# Ensure theme directory ownership & permissions
# -------------------------------------------------
chown -R www-data:www-data /var/www/html/wp-content/themes
chmod -R 755 /var/www/html/wp-content/themes
# -------------------------------------------------
# Activate the theme that is already present
# -------------------------------------------------
THEME_SLUG="indy-wp-theme"
# If the theme folder is missing (e.g., a volume was mounted over it),
# fall back to the tarball that matches the buildtime tag.
if [ ! -d "/var/www/html/wp-content/themes/${THEME_SLUG}" ]; then
echo "⚠️ Theme folder missing extracting the builtin ${THEME_TAG} archive …"
# The archive was already extracted during the build, but if a volume
# overwrote the directory we can reextract it from the images copy:
tar -xzf "/tmp/indy-wp-theme.tar.gz" -C "/var/www/html/wp-content/themes"
chown -R www-data:www-data "/var/www/html/wp-content/themes/${THEME_SLUG}"
chmod -R 755 "/var/www/html/wp-content/themes/${THEME_SLUG}"
fi
# Activate if not already active
if ! wp theme is-active "$THEME_SLUG" --allow-root --path=/var/www/html; then
echo "🚀 Activating IndyWP theme (${THEME_TAG}) …"
wp theme activate "$THEME_SLUG" \
--allow-root \
--path=/var/www/html
fi