equal
deleted
inserted
replaced
|
1 #!/bin/bash |
|
2 # $Id$ |
|
3 #(c)Peter Gervai, 2019-21 |
|
4 # |
|
5 # A simple tool to query the admin API |
|
6 # |
|
7 # Require token.sh with a content: |
|
8 # export T="MDAxNWxvY2F0aW..." |
|
9 # |
|
10 |
|
11 |
|
12 . ./token.sh |
|
13 |
|
14 U="https://matrix.example.mars:8448" |
|
15 MODE="$1" |
|
16 CMD="$2" |
|
17 JSON="$3" || '{}' |
|
18 |
|
19 |
|
20 if [ "x" = "x$CMD" ]; then |
|
21 echo "Usage: $0 <METHOD> <CMD> [<json>]" |
|
22 echo "Example: $0 GET /_matrix/client/r0/admin/whois/@grin:grin.hu" |
|
23 echo "Example: $0 GET /_synapse/admin/v1/reset_password/@example:grin.hu '{ \"new_password\": \"12345\" }'" |
|
24 echo "Example: $0 POST /_synapse/admin/v1/send_server_notice '{\"user_id\": \"@grin:matrix.org\", \"content\":{\"msgtype\":\"m.text\",\"body\": \"Hello from server!\"}}'" |
|
25 echo " $0 POST /_synapse/admin/v1/deactivate/@spammer:grin.hu" |
|
26 exit |
|
27 fi |
|
28 |
|
29 |
|
30 #set -x |
|
31 curl -d "$JSON" -X${MODE} "${U}${CMD}?access_token=$T" |
|
32 #set +x |
|
33 echo ' ' |