indy-wp/entrypoint-theme.sh

41 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
set -euo pipefail
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
# Wait for wp-config.php (core ready)
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
while [ ! -f /var/www/html/wp-config.php ]; do
echo "⏳ Waiting for WordPress core to be ready..."
sleep 2
done
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
# Ensure theme directory ownership & permissions
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
chown -R www-data:www-data /var/www/html/wp-content/themes
chmod -R 755 /var/www/html/wp-content/themes
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
# Activate the theme that is already present
2026-03-09 17:25:27 +00:00
# -------------------------------------------------
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