diff --git a/scripts/download-ledger.sh b/scripts/download-ledger.sh new file mode 100755 index 0000000000000000000000000000000000000000..69c2591c72250bf6758ef9b158a095de318cfb84 --- /dev/null +++ b/scripts/download-ledger.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Download the production constitutional ledger via flyctl. +set -euo pipefail + +APP="${FLY_APP:-slug-constitution}" +REMOTE="${JSONL_PATH:-/data/ledger.jsonl}" +OUT="${1:-ledger.jsonl}" + +mkdir -p "$(dirname "$OUT")" +fly sftp get "$REMOTE" "$OUT" -a "$APP" +wc -c "$OUT" | awk -v f="$OUT" '{print "wrote", $1, "bytes to", f}' diff --git a/scripts/wipe-ledger.sh b/scripts/wipe-ledger.sh new file mode 100755 index 0000000000000000000000000000000000000000..e6e82fe85323fbc1ba53f9f6374be5b801d98ae0 --- /dev/null +++ b/scripts/wipe-ledger.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Truncate the production ledger and restart so the in-memory store reloads empty. +set -euo pipefail + +APP="${FLY_APP:-slug-constitution}" +REMOTE="${JSONL_PATH:-/data/ledger.jsonl}" + +if [[ "${1:-}" != "--yes" ]]; then + echo "This will erase ${REMOTE} on ${APP} and restart the machine." >&2 + echo "Re-run with --yes to confirm." >&2 + exit 1 +fi + +fly ssh console -a "$APP" -C "sh -c 'truncate -s 0 ${REMOTE} && wc -c ${REMOTE}'" +fly apps restart "$APP" +echo "wiped ${REMOTE} on ${APP} and restarted"