Add synapse/madmin.sh: simple program to call admin API with curl.
authorPeter Gervai <grin@grin.hu>
Fri, 21 Jan 2022 10:22:39 +0100
changeset 4 721d4af9fdd7
parent 3 99e6c1cdae3b
child 5 2128a557be76
Add synapse/madmin.sh: simple program to call admin API with curl.
synapse/madmin.sh
synapse/token.sh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/synapse/madmin.sh	Fri Jan 21 10:22:39 2022 +0100
@@ -0,0 +1,33 @@
+#!/bin/bash
+# $Id$
+#(c)Peter Gervai, 2019-21
+#
+# A simple tool to query the admin API
+#
+# Require token.sh with a content:
+#  export T="MDAxNWxvY2F0aW..."
+#
+
+
+. ./token.sh
+
+U="https://matrix.example.mars:8448"
+MODE="$1"
+CMD="$2"
+JSON="$3" || '{}'
+
+
+if [ "x" = "x$CMD" ]; then
+	echo "Usage: $0 <METHOD> <CMD> [<json>]"
+	echo "Example: $0 GET /_matrix/client/r0/admin/whois/@grin:grin.hu"
+	echo "Example: $0 GET /_synapse/admin/v1/reset_password/@example:grin.hu '{ \"new_password\": \"12345\" }'"
+	echo "Example: $0 POST /_synapse/admin/v1/send_server_notice '{\"user_id\": \"@grin:matrix.org\", \"content\":{\"msgtype\":\"m.text\",\"body\": \"Hello from server!\"}}'"
+	echo "         $0 POST /_synapse/admin/v1/deactivate/@spammer:grin.hu"
+	exit
+fi
+
+
+#set -x
+curl -d "$JSON" -X${MODE} "${U}${CMD}?access_token=$T"
+#set +x
+echo ' '
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/synapse/token.sh	Fri Jan 21 10:22:39 2022 +0100
@@ -0,0 +1,1 @@
+export T="MDAxNWxvY2F0aW... token for admin user"