author | Peter Gervai <grin@grin.hu> |
Wed, 03 Aug 2022 10:43:29 +0200 | |
changeset 11 | 3d9a0d238469 |
parent 6 | 85afc1496738 |
permissions | -rwxr-xr-x |
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
1 |
#!/bin/bash |
6
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
2 |
# $Id: madmin.sh,v fc290d860b42 2022/01/24 09:19:54 grin $ |
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
3 |
#(c)Peter Gervai, 2019-21 |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
4 |
# |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
5 |
# A simple tool to query the admin API |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
6 |
# |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
7 |
# Require token.sh with a content: |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
8 |
# export T="MDAxNWxvY2F0aW..." |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
9 |
# |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
10 |
|
6
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
11 |
. ./_config.sh |
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
12 |
|
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
13 |
MODE="$1" |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
14 |
CMD="$2" |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
15 |
JSON="$3" || '{}' |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
16 |
|
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
17 |
|
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
18 |
if [ "x" = "x$CMD" ]; then |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
19 |
echo "Usage: $0 <METHOD> <CMD> [<json>]" |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
20 |
echo "Example: $0 GET /_matrix/client/r0/admin/whois/@grin:grin.hu" |
6
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
21 |
echo " $0 GET /_synapse/admin/v1/reset_password/@example:grin.hu '{ \"new_password\": \"12345\" }'" |
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
22 |
echo " $0 POST /_synapse/admin/v1/send_server_notice '{\"user_id\": \"@grin:matrix.org\", \"content\":{\"msgtype\":\"m.text\",\"body\": \"Hello from server!\"}}'" |
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
23 |
echo " $0 POST /_synapse/admin/v1/deactivate/@spammer:grin.hu" |
6
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
24 |
echo " $0 DELETE '/_synapse/admin/v2/rooms/!YDqJPFEKtBIEGBHqZE:matrix.org' '{ \"block\": true, \"purge\": true }'" |
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
25 |
echo " $0 GET '/_synapse/admin/v2/rooms/!YDqJPFEKtBIEGBHqZE:matrix.org/delete_status' | jq" |
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
26 |
|
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
27 |
exit |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
28 |
fi |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
29 |
|
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
30 |
|
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
31 |
#set -x |
6
85afc1496738
madmin shows v2 delete room example
Peter Gervai <grin@grin.hu>
parents:
4
diff
changeset
|
32 |
curl -d "$JSON" -X${MODE} "${SRV}${CMD}?access_token=$T" |
4
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
33 |
#set +x |
721d4af9fdd7
Add synapse/madmin.sh: simple program to call admin API with curl.
Peter Gervai <grin@grin.hu>
parents:
diff
changeset
|
34 |
echo ' ' |