mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:48:24 +01:00
The bash daemon was deleted in Session 4 of killing-the-bash-daemon; Fleet Runner (the desktop poller) is the local executor now. This retires the 'daemon' name from everything describing the live system — constants (DAEMON_*→RUNNER_*), types (DaemonStateKey→RunnerStateKey), the status banner component, state-derivation fns, control props, CSS classes (ui-control-fleet-daemon→-runner), and comments/UI strings. Backward-compat shims (no breakage to deployed Fleet Runner installs): - src/lib/constants/daemon.ts re-exports RUNNER_* under the old DAEMON_* names for the desktop Electron build until it points at the runner path. - Fleet Doctor reads runner.env, falls back to legacy daemon.env. Deliberately KEPT as 'daemon' (they name the genuinely-dead/legacy thing): the deprecated DAEMON_TOKEN bearer contract, the /api/agent/daemon 410 tombstone, the legacyDaemon developer download, and historical killing-the-bash-daemon references. systemctl daemon-reload / NX_DAEMON left untouched (not ours). tsc clean · eslint 0 errors · test:home 97/97 · smoke 44/44 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.2 KiB
Bash
53 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Build <repo>/<app_dir>/.env.selfhost.local for an app from its Vercel env
|
|
# (fresh `vercel env pull` if the repo is linked, else ~/dev/vercel-env-backup).
|
|
# Sanitizes Vercel-isms, rewrites DB URL to the box-local Postgres, points
|
|
# auth/site URLs at the new domain, adds AUTH_TRUST_HOST for proxied Auth.js.
|
|
# Usage: gen-env.sh <app>
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
app_lookup "${1:?usage: gen-env.sh <app>}"
|
|
|
|
SRC_DIR="$REPO/$APP_DIR"
|
|
OUT="$SRC_DIR/.env.selfhost.local"
|
|
DOMAIN="${DOMAINS%%,*}"
|
|
|
|
# Source env: fresh pull beats stale backup
|
|
RAW=$(mktemp); trap 'rm -f "$RAW"' EXIT
|
|
if [ -d "$REPO/.vercel" ] || vercel link --yes --project "$NAME" --scope orangecat --cwd "$REPO" >/dev/null 2>&1; then
|
|
vercel env pull "$RAW" --environment=production --yes --cwd "$REPO" >/dev/null 2>&1 || true
|
|
fi
|
|
if [ ! -s "$RAW" ]; then
|
|
BACKUP="$HOME/dev/vercel-env-backup/$NAME.env"
|
|
[ -f "$BACKUP" ] && cp "$BACKUP" "$RAW"
|
|
fi
|
|
[ -s "$RAW" ] || { echo "WARN: no Vercel env found for $NAME — writing minimal env"; : > "$RAW"; }
|
|
|
|
DB_URL=""
|
|
if [ "$DB" != "-" ]; then
|
|
pass=$(box "grep '^$DB|' ~/.db-credentials | cut -d'|' -f2")
|
|
[ -z "$pass" ] && { echo "ERROR: no credentials for db $DB on box"; exit 1; }
|
|
DB_URL="postgresql://$DB:$pass@localhost:5432/$DB"
|
|
fi
|
|
|
|
{
|
|
echo "# Generated by gen-env.sh $(date +%F) — runtime env for $DOMAIN"
|
|
while IFS= read -r line; do
|
|
case "$line" in \#*|"") continue;; esac
|
|
key="${line%%=*}"
|
|
val="${line#*=}"
|
|
val="${val%\"}"; val="${val#\"}"; val="${val%\\n}" # strip quotes + literal trailing \n
|
|
case "$key" in
|
|
VERCEL|VERCEL_*|NX_DAEMON|TURBO_*) continue ;;
|
|
DATABASE_URL|DIRECT_URL|POSTGRES_URL|POSTGRES_PRISMA_URL|POSTGRES_URL_NON_POOLING)
|
|
[ -n "$DB_URL" ] && val="$DB_URL" ;;
|
|
NEXTAUTH_URL|AUTH_URL|NEXT_PUBLIC_APP_URL|NEXT_PUBLIC_BASE_URL|NEXT_PUBLIC_SITE_URL)
|
|
val="https://$DOMAIN" ;;
|
|
esac
|
|
printf '%s="%s"\n' "$key" "${val//\"/\\\"}"
|
|
done < "$RAW"
|
|
[ -n "$DB_URL" ] && grep -qE '^(DATABASE_URL)=' "$RAW" || { [ -n "$DB_URL" ] && echo "DATABASE_URL=$DB_URL"; }
|
|
echo "AUTH_TRUST_HOST=true"
|
|
} > "$OUT"
|
|
chmod 600 "$OUT"
|
|
echo "wrote $OUT ($(grep -c '=' "$OUT") vars, db=$DB)"
|