GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — code/pm-stack/deploy.sh at main · developing-today/code Expand file tree/ Copy pathdeploy.shMore file actions executable file ·128 lines (123 loc) · 4.92 KB / Copy pathdeploy.shFile metadata and controlsexecutable file ·128 lines (123 loc) · 4.92 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 #!/usr/bin/env bash # Deploy the pm-stack on this host. # # Renders .env (mode 600) from the SOPS-encrypted secrets in # ../secrets/pm-stack.sops.yaml (relative to this repo checkout), then # pulls and (re)creates the containers, then renders the Cloudflare # Tunnel token files used by the pm-tunnel systemd user unit # (tunnel.token, read by cloudflared via --token-file, #8933; the # legacy tunnel.env env-file rendering is kept for rollback). # # Usage: # ./deploy.sh render env, pull images, start/refresh stack # ./deploy.sh render only render .env + tunnel token file # ./deploy.sh restart docker compose restart (keeps current env; # note: env changes need a full deploy.sh run, # compose only applies env on recreate) # # Host specifics (the ONLY host-specific values in the stack): # PM_STACK_SECRETS path to the SOPS file # (default: ../secrets/pm-stack.sops.yaml next to # this script's repo checkout) # SOPS_AGE_KEY_FILE age key for decryption # (default: ~/.config/sops/age/keys.txt) # The stack itself binds 127.0.0.1:5173 and stores data in the Docker # named volume pm-stack_postgres_data on this host. set -euo pipefail # Argument contract (#3352): at most one command, deploy (the default), # render or restart; anything else is a usage error before any work. case "$#:${1-deploy}" in 0:deploy | 1:deploy | 1:render | 1:restart) ;; *) echo "$0: unexpected arguments '$*'; usage: $0 [deploy|render|restart]" >&2 exit 2 ;; esac cd "$(dirname "$0")" STACK_DIR="$PWD" SECRETS_FILE="${PM_STACK_SECRETS:-$STACK_DIR/../secrets/pm-stack.sops.yaml}" export SOPS_AGE_KEY_FILE="${SOPS_AGE_KEY_FILE:-$HOME/.config/sops/age/keys.txt}" render() { if [[ ! -f $SECRETS_FILE ]]; then echo "secrets file not found: $SECRETS_FILE" >&2 exit 1 fi # Decrypt to a variable; values never touch disk in plaintext except # in the two rendered files below (both mode 600). local plain plain="$(sops --decrypt "$SECRETS_FILE")" local get get() { printf '%s\n' "$plain" | sed -n "s/^$1: //p" | tr -d "\"'"; } umask 077 { echo "# Rendered by deploy.sh from secrets/pm-stack.sops.yaml — do not edit, do not commit." echo "KANEO_CLIENT_URL=https://kaneo.security.cab" echo "POSTGRES_DB=kaneo" echo "POSTGRES_USER=kaneo" echo "POSTGRES_PASSWORD=$(get postgres_password)" echo "AUTH_SECRET=$(get auth_secret)" echo "NOTIFICATION_SECRET_ENCRYPTION_KEY=$(get notification_secret_encryption_key)" # Registration renders CLOSED — that is the fleet posture, and a # re-render must never silently reopen it. (Incident 2026-10-24: # the previous preserve-if-set logic plus a false default in # .env.example dropped the closed posture on a Phase 1 re-render; # see the design record's Phase 1 as-built correction.) Opening # registration — only ever to bootstrap the first account — is an # explicit one-render opt-out: # KANEO_OPEN_REGISTRATION=1 ./deploy.sh # Re-run ./deploy.sh without the variable to close it again. if [[ ${KANEO_OPEN_REGISTRATION:-} == 1 ]]; then echo "DISABLE_REGISTRATION=false" else echo "DISABLE_REGISTRATION=true" fi echo "GITHUB_APP_ID=$(get github_app_id)" echo "GITHUB_APP_NAME=$(get github_app_name)" echo "GITHUB_WEBHOOK_SECRET=$(get github_webhook_secret)" echo "GITHUB_PRIVATE_KEY_BASE64=$(get github_private_key_base64)" } >.env chmod 600 .env # cloudflared reads the tunnel token from tunnel.token via # --token-file (#8933: never through the connector's argv or # environment). tunnel.env is still rendered for rollback to the # pre-#8933 unit; nothing consumes it in the current unit. printf '%s' "$(get cloudflare_tunnel_token)" >tunnel.token chmod 600 tunnel.token echo "TUNNEL_TOKEN=$(get cloudflare_tunnel_token)" >tunnel.env chmod 600 tunnel.env echo "rendered .env, tunnel.token and tunnel.env from $SECRETS_FILE" } case "${1:-deploy}" in render) render ;; restart) docker compose restart ;; deploy) render docker compose pull docker compose up -d --force-recreate echo "waiting for kaneo health..." for i in $(seq 1 30); do if curl --fail --silent http://127.0.0.1:5173/api/health >/dev/null; then echo "kaneo is healthy: $(curl --silent http://127.0.0.1:5173/api/health)" # Close-authority guard (code#10137): the GitHub sync transitions # live only in Kaneo's DB, and a fresh import can silently restore # the dangerous upstream default. Assert them on every deploy. if ! python3 "$STACK_DIR/kaneo-sync-guard.py"; then echo "kaneo sync guard failed or healed drift - deploy marked failed; see output above" >&2 exit 1 fi exit 0 fi sleep 5 done echo "kaneo did not become healthy in time; check: docker compose logs" >&2 exit 1 ;; *) echo "usage: $0 [deploy|render|restart]" >&2 exit 2 ;; esac |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |