1 #!/bin/bash |
1 #!/bin/bash |
2 # $Id$ |
2 # $Id: madmin.sh,v fc290d860b42 2022/01/24 09:19:54 grin $ |
3 #(c)Peter Gervai, 2019-21 |
3 #(c)Peter Gervai, 2019-21 |
4 # |
4 # |
5 # A simple tool to query the admin API |
5 # A simple tool to query the admin API |
6 # |
6 # |
7 # Require token.sh with a content: |
7 # Require token.sh with a content: |
8 # export T="MDAxNWxvY2F0aW..." |
8 # export T="MDAxNWxvY2F0aW..." |
9 # |
9 # |
10 |
10 |
|
11 . ./_config.sh |
11 |
12 |
12 . ./token.sh |
|
13 |
|
14 U="https://matrix.example.mars:8448" |
|
15 MODE="$1" |
13 MODE="$1" |
16 CMD="$2" |
14 CMD="$2" |
17 JSON="$3" || '{}' |
15 JSON="$3" || '{}' |
18 |
16 |
19 |
17 |
20 if [ "x" = "x$CMD" ]; then |
18 if [ "x" = "x$CMD" ]; then |
21 echo "Usage: $0 <METHOD> <CMD> [<json>]" |
19 echo "Usage: $0 <METHOD> <CMD> [<json>]" |
22 echo "Example: $0 GET /_matrix/client/r0/admin/whois/@grin:grin.hu" |
20 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\" }'" |
21 echo " $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!\"}}'" |
22 echo " $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" |
23 echo " $0 POST /_synapse/admin/v1/deactivate/@spammer:grin.hu" |
|
24 echo " $0 DELETE '/_synapse/admin/v2/rooms/!YDqJPFEKtBIEGBHqZE:matrix.org' '{ \"block\": true, \"purge\": true }'" |
|
25 echo " $0 GET '/_synapse/admin/v2/rooms/!YDqJPFEKtBIEGBHqZE:matrix.org/delete_status' | jq" |
|
26 |
26 exit |
27 exit |
27 fi |
28 fi |
28 |
29 |
29 |
30 |
30 #set -x |
31 #set -x |
31 curl -d "$JSON" -X${MODE} "${U}${CMD}?access_token=$T" |
32 curl -d "$JSON" -X${MODE} "${SRV}${CMD}?access_token=$T" |
32 #set +x |
33 #set +x |
33 echo ' ' |
34 echo ' ' |