···1+#!/bin/bash
2+set -o errexit
3+set -o nounset
4+set -o pipefail
5+6+source "$(dirname "$0")/../pds.env"
7+8+# curl a URL and fail if the request fails.
9+function curl_cmd_get {
10+ curl --fail --silent --show-error "$@"
11+}
12+13+# curl a URL and fail if the request fails.
14+function curl_cmd_post {
15+ curl --fail --silent --show-error --request POST --header "Content-Type: application/json" "$@"
16+}
17+18+# curl a URL but do not fail if the request fails.
19+function curl_cmd_post_nofail {
20+ curl --silent --show-error --request POST --header "Content-Type: application/json" "$@"
21+}
22+23+USERNAME="${1:-}"
24+25+if [[ "${USERNAME}" == "" ]]; then
26+ read -p "Enter a username: " USERNAME
27+fi
28+29+if [[ "${USERNAME}" == "" ]]; then
30+ echo "ERROR: missing USERNAME parameter." >/dev/stderr
31+ echo "Usage: $0 ${SUBCOMMAND} <USERNAME>" >/dev/stderr
32+ exit 1
33+fi
34+35+PASSWORD="password"
36+INVITE_CODE="$(curl_cmd_post \
37+ --user "admin:${PDS_ADMIN_PASSWORD}" \
38+ --data '{"useCount": 1}' \
39+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createInviteCode" | jq --raw-output '.code'
40+)"
41+RESULT="$(curl_cmd_post_nofail \
42+ --data "{\"email\":\"${USERNAME}@${PDS_HOSTNAME}\", \"handle\":\"${USERNAME}.${PDS_HOSTNAME}\", \"password\":\"${PASSWORD}\", \"inviteCode\":\"${INVITE_CODE}\"}" \
43+ "https://${PDS_HOSTNAME}/xrpc/com.atproto.server.createAccount"
44+)"
45+46+DID="$(echo $RESULT | jq --raw-output '.did')"
47+if [[ "${DID}" != did:* ]]; then
48+ ERR="$(echo ${RESULT} | jq --raw-output '.message')"
49+ echo "ERROR: ${ERR}" >/dev/stderr
50+ echo "Usage: $0 <EMAIL> <HANDLE>" >/dev/stderr
51+ exit 1
52+fi
53+54+echo
55+echo "Account created successfully!"
56+echo "-----------------------------"
57+echo "Handle : ${USERNAME}.${PDS_HOSTNAME}"
58+echo "DID : ${DID}"
59+echo "Password : ${PASSWORD}"
60+echo "-----------------------------"
61+echo "This is a test account with an insecure password."
62+echo "Make sure it's only used for development."
63+echo
+5
nix/vm.nix
···79 };
80 # 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
81 networking.firewall.enable = false;
0000082 time.timeZone = "Europe/London";
83 services.getty.autologinUser = "root";
84 environment.systemPackages = with pkgs; [curl vim git sqlite litecli];
···79 };
80 # 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
81 networking.firewall.enable = false;
82+ services.dnsmasq.enable = true;
83+ services.dnsmasq.settings.address = "/tngl.boltless.dev/10.0.2.2";
84+ security.pki.certificates = [
85+ (builtins.readFile ../local-infra/cert/localtangled/root.crt)
86+ ];
87 time.timeZone = "Europe/London";
88 services.getty.autologinUser = "root";
89 environment.systemPackages = with pkgs; [curl vim git sqlite litecli];