Certbot script with env values comments was fixed.
This commit is contained in:
parent
c70ac6e310
commit
60e74a3137
2 changed files with 14 additions and 4 deletions
|
|
@ -114,7 +114,7 @@ SMTP_FROM=no-reply@contract-check.local
|
|||
SMTP_USE_TLS=true
|
||||
|
||||
# --- Edge proxy (Nginx + certbot) ---
|
||||
NGINX_SERVER_NAME=contract-check.example.com # public domain for the edge profile
|
||||
NGINX_SERVER_NAME=contract-check.example.com
|
||||
|
||||
# --- Telegram bot (adapter, HTTP-only to api) ---
|
||||
BOT_TOKEN= # same value as TELEGRAM_BOT_TOKEN (kept for the bot image)
|
||||
|
|
|
|||
|
|
@ -32,10 +32,20 @@ if [[ -z "$DOMAIN" || -z "$EMAIL" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f .env ]] && ! grep -qE "^NGINX_SERVER_NAME=${DOMAIN}\s*$" .env; then
|
||||
echo "ERROR: NGINX_SERVER_NAME in .env must equal ${DOMAIN}." >&2
|
||||
# Resolve NGINX_SERVER_NAME the same way compose does: shell env wins over .env.
|
||||
# Tolerates quotes, inline comments ("domain # comment"), CRLF and padding —
|
||||
# a hostname never contains whitespace, so the first token is the value.
|
||||
configured="${NGINX_SERVER_NAME:-}"
|
||||
if [[ -z "$configured" && -f .env ]]; then
|
||||
raw="$(sed -nE 's/^NGINX_SERVER_NAME=//p' .env | tail -n1 | tr -d "\"'\r")"
|
||||
read -r configured _ <<<"$raw" || true
|
||||
fi
|
||||
if [[ "$configured" != "$DOMAIN" ]]; then
|
||||
echo "ERROR: NGINX_SERVER_NAME must equal ${DOMAIN} (found: '${configured:-<unset>}')." >&2
|
||||
echo " nginx renders server_name and the certificate path from it." >&2
|
||||
echo " Add/fix: NGINX_SERVER_NAME=${DOMAIN}" >&2
|
||||
echo " Fix .env in the project root: NGINX_SERVER_NAME=${DOMAIN}" >&2
|
||||
echo " (or export NGINX_SERVER_NAME=${DOMAIN} before running this script)" >&2
|
||||
echo " Run the script from the project root — the dir containing .env." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue