Something went wrong. Try again.
Something went wrong. Try again.
3.0 kB · 101 lines
Shell
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102#!/usr/bin/env bash## Reset the local corvus.run stack (PDS + jetstream) and seed it with two# test accounts. Usage: ./docker/seed.sh## `down -v` destroys the data volumes so you start from a clean PDS.## Accounts:# corvus-alice.test / alice-password-123# corvus-bob.test / bob-password-123
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"PDS_URL="${PDS_URL:-http://localhost:2585}"JETSTREAM_URL="${JETSTREAM_URL:-http://localhost:6013}"PLC_URL="${PLC_URL:-http://localhost:2586}"
PDS_ENV_FILE="$SCRIPT_DIR/pds.env"if [ ! -f "$PDS_ENV_FILE" ]; then echo "Missing $PDS_ENV_FILE — regenerate dev secrets before running seed." exit 1fi# shellcheck disable=SC1090set -a; . "$PDS_ENV_FILE"; set +aif [ -z "${PDS_ADMIN_PASSWORD:-}" ]; then echo "PDS_ADMIN_PASSWORD not set in $PDS_ENV_FILE" exit 1fi
pds_auth="Authorization: Basic $(printf 'admin:%s' "$PDS_ADMIN_PASSWORD" | base64)"
echo "Tearing down stack..."docker compose -f "$SCRIPT_DIR/docker-compose.yaml" down -v --remove-orphansecho "Starting stack..."docker compose -f "$SCRIPT_DIR/docker-compose.yaml" up -d --remove-orphans
wait_for() { local name="$1" url="$2" echo "Waiting for $name at $url..." for i in $(seq 1 60); do if curl -sf "$url" >/dev/null 2>&1; then echo "$name is up." return 0 fi if [ "$i" -eq 60 ]; then echo "$name not reachable after 60s, aborting." exit 1 fi sleep 1 done}
wait_for "PLC" "$PLC_URL/_health"wait_for "PDS" "$PDS_URL/xrpc/_health"wait_for "jetstream" "$JETSTREAM_URL/metrics"
create_account() { local handle="$1" local password="$2" local email="$3"
local invite invite=$(curl -sf -X POST "$PDS_URL/xrpc/com.atproto.server.createInviteCode" \ -H 'Content-Type: application/json' \ -H "$pds_auth" \ -d '{"useCount":1}') local code code=$(echo "$invite" | grep -o '"code":"[^"]*"' | cut -d'"' -f4)
local result result=$(curl -sf -X POST "$PDS_URL/xrpc/com.atproto.server.createAccount" \ -H 'Content-Type: application/json' \ -d "{\"handle\":\"$handle\",\"email\":\"$email\",\"password\":\"$password\",\"inviteCode\":\"$code\"}") local did did=$(echo "$result" | grep -o '"did":"[^"]*"' | head -1 | cut -d'"' -f4)
echo " $handle $did"}
echo "Creating accounts..."ALICE_LINE=$(create_account "corvus-alice.test" "alice-password-123" "alice@test.com")BOB_LINE=$(create_account "corvus-bob.test" "bob-password-123" "bob@test.com")ALICE_DID=$(echo "$ALICE_LINE" | awk '{print $2}')BOB_DID=$(echo "$BOB_LINE" | awk '{print $2}')echo "$ALICE_LINE"echo "$BOB_LINE"
cat <<EOF
Done. Stack: PDS: $PDS_URL PLC: $PLC_URL jetstream: ws://localhost:6012/subscribe alice: $ALICE_DID (corvus-alice.test / alice-password-123) bob: $BOB_DID (corvus-bob.test / bob-password-123)
Boot the corvus server (jetstream ingester + XRPC read API):
pnpm dev:serverEOF