New scripts, obtaining required information in a more convenient manner

This commit is contained in:
DecaTec 2021-10-06 12:31:32 +02:00
parent 9788b97524
commit 36b668d23a
4 changed files with 91 additions and 17 deletions

View File

@ -5,11 +5,10 @@
#
# Requirements:
# You'll need the domain of your server (variable "serverDomain").
#
# For authentication, you will need the access token of your (admin) account.
# You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "<click to reveal>" to get your access token.
# Copy this token and paste it further down (variable "token").
# - You'll need the domain of your server (variable "serverDomain").
# - For authentication, you will need the access token of your (admin) account.
# You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "<click to reveal>" to get your access token.
# Copy this token and paste it further down (variable "token").
#
# You can also specify another time span for deleting media.
# Default is media, which was not accessed over the last 60 days (variable "timestamp60DaysAgo")
@ -17,10 +16,23 @@
# You can automate this script via cron, e.g. cleanup every night:
# 0 1 * * * /path/to/scripts/Matrix-Synapse-Helpers/CleanupMedia.sh > /dev/null 2>&1
serverDomain="matrix.mydomain.com"
token="insert-token-here"
serverDomain=""
token=""
# You may to customize this time span to fit your needs.
timestamp60DaysAgo=`date +%s000 --date "60 days ago"`
if [ -z "$serverDomain" ]
then
read -p "Enter the Matrix server domain: (e.g. matrix.mydomain.com): " serverDomain
echo ""
fi
if [ -z "$token" ]
then
read -p "Enter your access token: " token
echo ""
fi
# Delete local media
echo "Delete local media..."
echo ""

39
ListAllUsers.sh Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
#
# Lists all users of the given instance.
#
# Requirements:
# - You'll need the domain of your server (variable "serverDomain").
# - Python 2.6+ has to be installed on the system.
# - For authentication, you will need the access token of your (admin) account.
# You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "<click to reveal>" to get your access token.
# Copy this token and paste it further down (variable "token").
#
serverDomain=""
token=""
if [ -z "$serverDomain" ]
then
read -p "Enter the Matrix server domain: (e.g. matrix.mydomain.com): " serverDomain
echo ""
fi
if [ -z "$token" ]
then
read -p "Enter your access token: " token
echo ""
fi
# List users
echo "Retrieving users..."
echo ""
curlUrl="http://localhost:8008/_synapse/admin/v2/users?access_token=$token"
output=$(curl $curlUrl)
echo ""
echo $output | python -m json.tool
echo ""
echo "Done"
echo ""

View File

@ -1,4 +1,10 @@
# Helper scripts for Matrix Synapse
Some useful scripts utilizing the API of Matrix Synapse in order to manage different tasks:
* `ActivateUser.sh`: Activates the given user and assigns a new password.
* `CleanupMedia.sh`: Deletes old local and remote media.
* `DeactivateUser.sh`: Deactivates the given user.
* `GetAccessToken.sh`: Gets the access token with curl.
* `CleanupMedia.sh`: Deletes old local and remote media.
* `ListAllUsers.sh`: Lists all users.
* `UpdateRoomVersion.sh`: Updates a room to the given room version.

View File

@ -5,17 +5,34 @@
#
# Requirements:
#
# For authentication, you will need the access token of your (admin) account.
# You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "<click to reveal>" to get your access token.
# Copy this token and paste it further down (variable "token").
#
# You also need the room ID of the room to update. You can find it in the room's settings under "acvanced" (internal room ID).
# - You need the room ID of the room to update. You can find it in the room's settings under "acvanced" (internal room ID).
# - For authentication, you will need the access token of your (admin) account.
# You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "<click to reveal>" to get your access token.
# Copy this token and paste it further down (variable "token").
#
token="insert-token-here"
roomId='insert-room-id-here'
newRoomVersion="insert-new-room-version-here"
serverDomain=""
token=""
newRoomVersion=""
if [ -z "$serverDomain" ]
then
read -p "Enter the Matrix server domain: (e.g. matrix.mydomain.com): " serverDomain
echo ""
fi
if [ -z "$newRoomVersion" ]
then
read -p "Enter the new room version (e.g. 6): " newRoomVersion
echo ""
fi
if [ -z "$token" ]
then
read -p "Enter your access token: " token
echo ""
fi
# Delete local media
echo "Update room version of room $roomId..."