#!/usr/bin/env sh set -eu DIST_DIR="/app/backend/dist" if [ -z "${TNYR_SALT1_HEX:-}" ] || [ -z "${TNYR_SALT2_HEX:-}" ]; then echo "Legacy salts not set (TNYR_SALT1_HEX/TNYR_SALT2_HEX). That's OK: default mode needs no secrets." echo "If you need legacy server-side links (/shorten-server and old /), generate salts with: python3 backend/generate_salts.py --env" fi PUBLIC_URL="${TNYR_PUBLIC_URL:-}" PORT="${TNYR_PORT:-5502}" DB_PATH="${TNYR_DB_PATH:-}" if [ -z "$PUBLIC_URL" ]; then echo "ERROR: Missing required env var: TNYR_PUBLIC_URL (https://example.com or http://1.2.3.4:5502)" exit 1 fi INFO="$(python - <<'PY' import os from urllib.parse import urlparse u = os.environ.get("TNYR_PUBLIC_URL","").strip() p = urlparse(u) if p.scheme not in ("http","https") or not p.netloc: raise SystemExit("Invalid TNYR_PUBLIC_URL (must be http(s)://host[:port])") print(f"{p.scheme}://{p.netloc}") print(p.netloc) PY )" read -r NORMALIZED_PUBLIC_URL DOMAIN <