41 lines
1.6 KiB
Bash
41 lines
1.6 KiB
Bash
#!/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 build‑time tag.
|
||
if [ ! -d "/var/www/html/wp-content/themes/${THEME_SLUG}" ]; then
|
||
echo "⚠️ Theme folder missing – extracting the built‑in ${THEME_TAG} archive …"
|
||
# The archive was already extracted during the build, but if a volume
|
||
# overwrote the directory we can re‑extract it from the image’s 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 Indy‑WP theme (${THEME_TAG}) …"
|
||
wp theme activate "$THEME_SLUG" \
|
||
--allow-root \
|
||
--path=/var/www/html
|
||
fi
|