Files
isp-admin-ui/entrypoint.sh
T

45 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
set -e
PUBLIC_PATH="${PUBLIC_PATH:-/}"
PUBLIC_PATH="$(printf '%s' "$PUBLIC_PATH" | sed -E 's|^/*|/|; s|/*$|/|')"
echo "Using normalized PUBLIC_PATH: '$PUBLIC_PATH'"
# Генерация конфигурации приложения
CONFIG_DIR="/opt/msp/isp-admin-ui${PUBLIC_PATH}"
CONFIG_PATH="${CONFIG_DIR}/config.js"
mkdir -p "$CONFIG_DIR"
cat <<EOF > "$CONFIG_PATH"
window.config = {
ENABLE_PASSWORD_LOGIN: ${ENABLE_PASSWORD_LOGIN:-true},
APP_TOKEN: '${APP_TOKEN:-"default_token"}',
CLIENT_NAME: '${CLIENT_NAME:-"isp-admin-ui"}',
OAUTH_LOGIN_BUTTON_TEXT: '${OAUTH_LOGIN_BUTTON_TEXT:-"Войти с помощью OAuth"}',
ENABLE_OAUTH_LOGIN: ${ENABLE_OAUTH_LOGIN:-true}
};
EOF
echo "Generated config at: $CONFIG_PATH"
# Подготовка nginx-конфига: заменяем __PUBLIC_PATH__ на реальное значение
NGINX_SRC="/etc/nginx/conf.d/80_isp-admin-ui.conf"
TMP_FILE="${NGINX_SRC}.tmp"
echo "Substituting __PUBLIC_PATH__ with: '${PUBLIC_PATH}'"
sed "s|__PUBLIC_PATH__|${PUBLIC_PATH}|g" "$NGINX_SRC" > "$TMP_FILE"
# Проверка результата
echo "=== Generated nginx config ==="
cat "$TMP_FILE"
echo "=== End nginx config ==="
# Заменяем оригинальный конфиг
mv "$TMP_FILE" "$NGINX_SRC"
echo "Starting nginx..."
exec nginx -g "daemon off;"