synapse/madmin.sh
author Peter Gervai <grin@grin.hu>
Wed, 08 Mar 2023 22:27:54 +0100
changeset 12 3336c2c14bae
parent 6 85afc1496738
permissions -rwxr-xr-x
Add mass_event_remove.sh: simple script redact events collected from the db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ' '