initial commit
This commit is contained in:
parent
ec0629e07b
commit
8e99185335
3
auth
Executable file
3
auth
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
TOKEN="your_extremely_long_and_secure_token_goes_here"
|
24
check_user
Executable file
24
check_user
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Not enough arguments supplied."
|
||||
echo "Syntax: $(basename $0) {username}"
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. $(dirname $0)/auth
|
||||
|
||||
USER=$1
|
||||
|
||||
curl -s --insecure -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' "http://localhost:8008/_synapse/admin/v2/users/@$USER:matrix.erb.pw" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
|
||||
echo
|
29
deactivate_user
Executable file
29
deactivate_user
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Not enough arguments supplied."
|
||||
echo
|
||||
echo "Syntax: $(basename $0) {username} {new name}"
|
||||
echo "Example:"
|
||||
echo " $(basename $0) ktulu dis-Ktulu-dis"
|
||||
}
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. $(dirname $0)/auth
|
||||
|
||||
USER=$1
|
||||
NEWNAME=$2
|
||||
NEWPASS="$(apg -MNC -m64 -n1)"
|
||||
|
||||
curl -s --insecure -X PUT \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"deactivated": true, "displayname":"'$NEWNAME'", "password":"'$NEWPASS'"}' \
|
||||
"http://localhost:8008/_synapse/admin/v2/users/@$USER:matrix.erb.pw" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
|
||||
echo
|
24
delete_room
Executable file
24
delete_room
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Not enough arguments supplied."
|
||||
echo "Syntax: $(basename $0) {roomid}"
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. $(dirname $0)/auth
|
||||
|
||||
ROOM=$1
|
||||
|
||||
curl -s --insecure -X DELETE \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"block":true, "purge":true, "force_purge":true}' "http://localhost:8008/_synapse/admin/v1/rooms/$ROOM" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
|
||||
echo
|
35
list_rooms
Executable file
35
list_rooms
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Not enough arguments supplied."
|
||||
echo "Syntax: $(basename $0) {roomname||all}"
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. $(dirname $0)/auth
|
||||
|
||||
ROOM=$1
|
||||
|
||||
if [[ "${ROOM^^}" == "ALL" ]]; then
|
||||
# show all rooms
|
||||
curl -s --insecure -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' "http://localhost:8008/_synapse/admin/v1/rooms" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
else
|
||||
# filter by room name
|
||||
curl -s --insecure -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}' "http://localhost:8008/_synapse/admin/v1/rooms?search_term=$ROOM" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
fi
|
||||
|
||||
|
||||
echo
|
28
reactivate_user
Executable file
28
reactivate_user
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "Not enough arguments supplied."
|
||||
echo "Syntax: $(basename $0) {username} {new name} {new password} {isadmin 0=no 1=yes}"
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ $# -lt 4 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. $(dirname $0)/auth
|
||||
|
||||
USER=$1
|
||||
NEWNAME=$2
|
||||
NEWPASS=$3
|
||||
ISADMIN=$4
|
||||
|
||||
curl -s --insecure -X PUT \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"deactivated": false, "admin":'$ISADMIN', "displayname":"'$NEWNAME'", "password":"'$NEWPASS'"}' \
|
||||
"http://localhost:8008/_synapse/admin/v2/users/@$USER:matrix.erb.pw" | \
|
||||
sed 's/,/,\n /g; s/{/{\n /g; s/}/\n}/g'
|
||||
|
||||
echo
|
Loading…
x
Reference in New Issue
Block a user