Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
1.2 kB · 35 lines
Shell
123456789101112131415161718192021222324252627282930313233343536#!/bin/sh# pds account creation only; safe to run against a live rig without touching fixturesset -eu
. /scripts/lib.sh
USERS="${*:-${USERS:-}}"[ -n "$USERS" ] || fail "usage: add-accounts.sh name [name ...]" \ " or set USERS to a space-separated list."
: "${PDS_HOSTNAME:?PDS_HOSTNAME must be set}": "${PDS_ADMIN_PASSWORD:?PDS_ADMIN_PASSWORD must be set}"
for u in $USERS; do handle="${u}.${PDS_HOSTNAME}" email="${u}@${PDS_HOSTNAME}" did=$(resolve_handle "$handle") if [ -n "$did" ]; then printf '[skip] %s = %s\n' "$handle" "$did" >&2 else invite=$(curl -fsS -u "admin:${PDS_ADMIN_PASSWORD}" \ -H "Content-Type: application/json" \ -d '{"useCount":1}' \ "${PDS_URL}/xrpc/com.atproto.server.createInviteCode" | jq -er '.code')
result=$(curl -fsS \ -H "Content-Type: application/json" \ -d "{\"email\":\"${email}\",\"handle\":\"${handle}\",\"password\":\"${PASSWORD}\",\"inviteCode\":\"${invite}\"}" \ "${PDS_URL}/xrpc/com.atproto.server.createAccount")
did=$(printf '%s\n' "$result" | jq -er '.did') printf '[create] %s = %s (password: %s)\n' "$handle" "$did" "$PASSWORD" >&2 fi printf '%s\t%s\n' "$u" "$did"done