summary refs log tree commit diff
path: root/old stuff/Spacebar-synapse/post-rebuild.sh
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-09-26 15:03:18 +0200
committerRory& <root@rory.gay>2024-06-05 17:25:16 +0200
commit10a409f984e9bce9cf15c1aaf3771a5043afc305 (patch)
tree0c8b07784e7632a5c9b53ef3ddedb5bdbae067ab /old stuff/Spacebar-synapse/post-rebuild.sh
parentWork on spacebar container (diff)
downloadSpacebar-Open-Infrastructure-10a409f984e9bce9cf15c1aaf3771a5043afc305.tar.xz
Postgres, maybe?
Diffstat (limited to 'old stuff/Spacebar-synapse/post-rebuild.sh')
-rwxr-xr-xold stuff/Spacebar-synapse/post-rebuild.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/old stuff/Spacebar-synapse/post-rebuild.sh b/old stuff/Spacebar-synapse/post-rebuild.sh
new file mode 100755
index 0000000..8dc0e7d
--- /dev/null
+++ b/old stuff/Spacebar-synapse/post-rebuild.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl gnused nix coreutils jq openssl
+#set -x
+REG_KEY=`cat /var/lib/matrix-synapse/registration_shared_secret.txt`
+LOCALPART='rory.gay'
+REACHABLE_DOMAIN='http://localhost:8008'
+
+# -- LICENSE: CNPL v7+ - https://thufie.lain.haus/files/CNPLv7.md
+# Modified from Nyaaori (https://nyaaori.cat) <+@nyaaori.cat>
+# Explicit authorisation to use the code has been granted by the original author
+#  for use by members of the Rory system (https://rory.gay)
+
+# the magic function:
+register(){
+	echo "Registering $1 with password $2"
+	_nonce=`curl http://localhost:8008/_synapse/admin/v1/register | jq -r .nonce`
+	#data: nonce, domain, username, password
+	_hmac=`printf '%s\0%s\0%s\0%s' "$_nonce" "$1" "$2" "admin" |  openssl dgst -sha1 -hmac "$REG_KEY" |  awk '{print $2}'`
+	curl -XPOST -d '{"nonce": "'"$_nonce"'", "username": "'"$1"'", "displayname": "'"$1"'", "password": "'"$2"'", "admin": true, "mac": "'"$_hmac"'"}' $REACHABLE_DOMAIN/_synapse/admin/v1/register | tee -a matrix-user-tokens.txt
+}
+
+# -- END OF LICENSED CODE
+
+
+
+PASSWD=`cat /etc/matrix-user-pass`
+for u in {draupnir,rory,chris,maddy,cat}
+do 
+	register $u $PASSWD
+done