Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
Shell
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#!/bin/bashset -o errexitset -o nounsetset -o pipefail
source "$(dirname "$0")/../pds.env"
# PDS_HOSTNAME=# PDS_ADMIN_PASSWORD=
# curl a URL and fail if the request fails.function curl_cmd_get { curl --fail --silent --show-error "$@"}
# curl a URL and fail if the request fails.function curl_cmd_post { curl --fail --silent --show-error --request POST --header "Content-Type: application/json" "$@"}
# curl a URL but do not fail if the request fails.function curl_cmd_post_nofail { curl --silent --show-error --request POST --header "Content-Type: application/json" "$@"}
USERNAME="${1:-}"
if [[ "${USERNAME}" == "" ]]; then read -p "Enter a username: " USERNAMEfi
if [[ "${USERNAME}" == "" ]]; then echo "ERROR: missing USERNAME parameter." >/dev/stderr echo "Usage: $0 ${SUBCOMMAND} <USERNAME>" >/dev/stderr exit 1fi
EMAIL=${USERNAME}@${PDS_HOSTNAME}
PASSWORD="password"INVITE_CODE="$(curl_cmd_post \ --user "admin:${PDS_ADMIN_PASSWORD}" \ --data '{"useCount": 1}' \ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode" | jq --raw-output '.code')"RESULT="$(curl_cmd_post_nofail \ --data "{\"email\":\"${EMAIL}\", \"handle\":\"${USERNAME}.${PDS_HOSTNAME}\", \"password\":\"${PASSWORD}\", \"inviteCode\":\"${INVITE_CODE}\"}" \ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createAccount")"
DID="$(echo $RESULT | jq --raw-output '.did')"if [[ "${DID}" != did:* ]]; then ERR="$(echo ${RESULT} | jq --raw-output '.message')" echo "ERROR: ${ERR}" >/dev/stderr echo "Usage: $0 <EMAIL> <HANDLE>" >/dev/stderr exit 1fi
echoecho "Account created successfully!"echo "-----------------------------"echo "Handle : ${USERNAME}.${PDS_HOSTNAME}"echo "DID : ${DID}"echo "Password : ${PASSWORD}"echo "-----------------------------"echo "This is a test account with an insecure password."echo "Make sure it's only used for development."echo