From c784037ed4addda5b26cddb8be31937818d769d1 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 7 Feb 2026 23:21:04 -0500 Subject: [PATCH] Resolve real .env path and escape APP_URL for sed replacement --- docker/entrypoint.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 1176b8be9..5116a53cc 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -67,10 +67,17 @@ if [ "${BEHIND_PROXY}" == "true" ]; then export ASSET_URL=${APP_URL} # Write ASSET_URL to .env so PHP-FPM workers can read it (clear_env = yes by default) - if grep -q "^ASSET_URL=" /pelican-data/.env; then - sed -i "s|^ASSET_URL=.*|ASSET_URL=${APP_URL}|" /pelican-data/.env + ENV_FILE="/var/www/html/.env" + if [ -e "$ENV_FILE" ]; then + ENV_FILE="$(readlink -f "$ENV_FILE")" else - echo "ASSET_URL=${APP_URL}" >> /pelican-data/.env + ENV_FILE="/pelican-data/.env" + fi + ESCAPED_APP_URL="$(printf '%s' "$APP_URL" | sed 's/[&|]/\\&/g')" + if grep -q "^ASSET_URL=" "$ENV_FILE"; then + sed -i "s|^ASSET_URL=.*|ASSET_URL=${ESCAPED_APP_URL}|" "$ENV_FILE" + else + echo "ASSET_URL=${APP_URL}" >> "$ENV_FILE" fi fi