Generate media proxy origin config on deploy

This commit is contained in:
Jage9
2026-03-08 21:26:07 -04:00
parent 6368187ee4
commit 47d4a61256
3 changed files with 42 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ PUBLISH_DIR="${2:-$REPO_ROOT/deploy/publish/chgrid}"
BASE_PATH="${3:-/chgrid/}"
CLIENT_DIR="$REPO_ROOT/client"
PHP_PROXY_DIR="$REPO_ROOT/deploy/php"
SERVER_ENV_FILE="$REPO_ROOT/server/.env"
PUBLIC_HTACCESS_SRC="$REPO_ROOT/deploy/apache/chgrid-public-htaccess"
if [[ ! -d "$CLIENT_DIR" ]]; then
@@ -30,6 +31,26 @@ if [[ -d "$PHP_PROXY_DIR" ]]; then
rsync -a "$PHP_PROXY_DIR/" "$PUBLISH_DIR/"
fi
if [[ -f "$SERVER_ENV_FILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$SERVER_ENV_FILE"
set +a
fi
if [[ -n "${CHGRID_HOST_ORIGIN:-}" ]]; then
escaped_host_origin=${CHGRID_HOST_ORIGIN//\\/\\\\}
escaped_host_origin=${escaped_host_origin//\'/\\\'}
cat > "$PUBLISH_DIR/media_proxy.config.php" <<EOF
<?php
return array(
'host_origin' => '$escaped_host_origin',
);
EOF
else
rm -f "$PUBLISH_DIR/media_proxy.config.php"
fi
if [[ -f "$PUBLIC_HTACCESS_SRC" ]]; then
cp "$PUBLIC_HTACCESS_SRC" "$PUBLISH_DIR/.htaccess"
fi