···11+#!/bin/bash
22+set -o errexit
33+set -o nounset
44+set -o pipefail
55+66+source "$(dirname "$0")/../pds.env"
77+88+# curl a URL and fail if the request fails.
99+function curl_cmd_get {
1010+ curl --fail --silent --show-error "$@"
1111+}
1212+1313+# curl a URL and fail if the request fails.
1414+function curl_cmd_post {
1515+ curl --fail --silent --show-error --request POST --header "Content-Type: application/json" "$@"
1616+}
1717+1818+# curl a URL but do not fail if the request fails.
1919+function curl_cmd_post_nofail {
2020+ curl --silent --show-error --request POST --header "Content-Type: application/json" "$@"
2121+}
2222+2323+USERNAME="${1:-}"
2424+2525+if [[ "${USERNAME}" == "" ]]; then
2626+ read -p "Enter a username: " USERNAME
2727+fi
2828+2929+if [[ "${USERNAME}" == "" ]]; then
3030+ echo "ERROR: missing USERNAME parameter." >/dev/stderr
3131+ echo "Usage: $0 ${SUBCOMMAND} <USERNAME>" >/dev/stderr
3232+ exit 1
3333+fi
3434+3535+PASSWORD="password"
3636+INVITE_CODE="$(curl_cmd_post \
3737+ --user "admin:${PDS_ADMIN_PASSWORD}" \
3838+ --data '{"useCount": 1}' \
3939+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode" | jq --raw-output '.code'
4040+)"
4141+RESULT="$(curl_cmd_post_nofail \
4242+ --data "{\"email\":\"${USERNAME}@${PDS_HOSTNAME}\", \"handle\":\"${USERNAME}.${PDS_HOSTNAME}\", \"password\":\"${PASSWORD}\", \"inviteCode\":\"${INVITE_CODE}\"}" \
4343+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createAccount"
4444+)"
4545+4646+DID="$(echo $RESULT | jq --raw-output '.did')"
4747+if [[ "${DID}" != did:* ]]; then
4848+ ERR="$(echo ${RESULT} | jq --raw-output '.message')"
4949+ echo "ERROR: ${ERR}" >/dev/stderr
5050+ echo "Usage: $0 <EMAIL> <HANDLE>" >/dev/stderr
5151+ exit 1
5252+fi
5353+5454+echo
5555+echo "Account created successfully!"
5656+echo "-----------------------------"
5757+echo "Handle : ${USERNAME}.${PDS_HOSTNAME}"
5858+echo "DID : ${DID}"
5959+echo "Password : ${PASSWORD}"
6060+echo "-----------------------------"
6161+echo "This is a test account with an insecure password."
6262+echo "Make sure it's only used for development."
6363+echo
+5
nix/vm.nix
···7979 };
8080 # This is fine because any and all ports that are forwarded to host are explicitly marked above, we don't need a separate guest firewall
8181 networking.firewall.enable = false;
8282+ services.dnsmasq.enable = true;
8383+ services.dnsmasq.settings.address = "/tngl.boltless.dev/10.0.2.2";
8484+ security.pki.certificates = [
8585+ (builtins.readFile ../local-infra/cert/localtangled/root.crt)
8686+ ];
8287 time.timeZone = "Europe/London";
8388 services.getty.autologinUser = "root";
8489 environment.systemPackages = with pkgs; [curl vim git sqlite litecli];