#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" cd "$SCRIPT_DIR" # ── Load .env from repo root ─────────────────────────────────────────────────── if [ -f "$REPO_ROOT/.env" ]; then set -a; source "$REPO_ROOT/.env"; set +a fi DOMAIN_SUFFIX="${DOMAIN_SUFFIX:-}" ACME_EMAIL="${ACME_EMAIL:-}" # ── Validate ─────────────────────────────────────────────────────────────────── if [ -z "$DOMAIN_SUFFIX" ] || [ "$DOMAIN_SUFFIX" = "localhost" ]; then echo "ERROR: Set DOMAIN_SUFFIX to your real domain in infra/.env" exit 1 fi if [ -z "$ACME_EMAIL" ]; then echo "ERROR: Set ACME_EMAIL in infra/.env (required for Let's Encrypt)" exit 1 fi # ── Generate production caddy.json ───────────────────────────────────────────── # Writes TLS-enabled config using Let's Encrypt (no Cloudflare required). # Caddy will use the HTTP-01 challenge (port 80) or TLS-ALPN-01 (port 443). cat > "$SCRIPT_DIR/../proxy/caddy.json" < is created by PAM/logind; it doesn't exist in non-login # shells. Unconditionally redirect all Podman runtime state to /tmp so we # never depend on logind, regardless of what XDG_RUNTIME_DIR was set to # by the calling environment. _HIY_RUNTIME="/tmp/podman-$(id -u)" mkdir -p "$_HIY_RUNTIME" export XDG_RUNTIME_DIR="$_HIY_RUNTIME" # Also write storage.conf so Podman doesn't read a stale RunRoot from the # user's existing ~/.config/containers/storage.conf. mkdir -p "$HOME/.config/containers" cat > "$HOME/.config/containers/storage.conf" <