Protocol, Port as variables, '-k' parameter for curl
This commit is contained in:
parent
61dbb6bffc
commit
2e8f2201cc
|
|
@ -13,16 +13,18 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
token=""
|
token=""
|
||||||
|
protocol="http"
|
||||||
|
port="8008"
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
read -p "Enter your access token: " token
|
read -pr "Enter your access token: " token
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Enter the user which should be activated: (e.g. @test:matrix.mydomain.com): " user_to_activate
|
read -pr "Enter the user which should be activated: (e.g. @test:matrix.mydomain.com): " user_to_activate
|
||||||
echo ""
|
echo ""
|
||||||
read -sp "Enter the new passwort for user: " new_password
|
read -spr "Enter the new passwort for user: " new_password
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# User lower case only
|
# User lower case only
|
||||||
|
|
@ -31,10 +33,10 @@ user_to_activate="${user_to_activate,,}"
|
||||||
# Activate user
|
# Activate user
|
||||||
echo "Activate user $user_to_activate..."
|
echo "Activate user $user_to_activate..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v2/users/$user_to_activate?access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v2/users/$user_to_activate?access_token=$token"
|
||||||
|
|
||||||
echo $curlUrl
|
echo "$curlUrl"
|
||||||
curl -X PUT $curlUrl -H 'Content-Type: application/json' -d '{"deactivated": false, "password":"'"$new_password"'"}'
|
curl -k -X PUT "$curlUrl" -H 'Content-Type: application/json' -d '{"deactivated": false, "password":"'"$new_password"'"}'
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
token=""
|
token=""
|
||||||
|
protocol="http"
|
||||||
|
port="8008"
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
|
|
@ -20,16 +22,16 @@ then
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Enter the user whose password should be changed: (e.g. @test:matrix.mydomain.com): " user_to_change_password
|
read -pr "Enter the user whose password should be changed: (e.g. @test:matrix.mydomain.com): " user_to_change_password
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
read -sp "Enter the NEW password: " new_password
|
read -spr "Enter the NEW password: " new_password
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
read -sp "Confirm the new password: " new_password2
|
read -spr "Confirm the new password: " new_password2
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ $new_password != $new_password2 ]; then
|
if [ "$new_password" != "$new_password2" ]; then
|
||||||
echo "Error: The passwords do not match"
|
echo "Error: The passwords do not match"
|
||||||
echo "The password was NOT changed"!
|
echo "The password was NOT changed"!
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -41,8 +43,8 @@ user_to_change_password="${user_to_change_password,,}"
|
||||||
# Change users's password
|
# Change users's password
|
||||||
echo "Change password for user $user_to_change_password..."
|
echo "Change password for user $user_to_change_password..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v2/users/$user_to_change_password?access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v2/users/$user_to_change_password?access_token=$token"
|
||||||
curl -X PUT $curlUrl -H 'Content-Type: application/json' -d '{"password": "'"$new_password"'"}'
|
curl -k -X PUT "$curlUrl" -H 'Content-Type: application/json' -d '{"password": "'"$new_password"'"}'
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -19,26 +19,28 @@
|
||||||
|
|
||||||
serverDomain=""
|
serverDomain=""
|
||||||
token=""
|
token=""
|
||||||
|
protocol="http"
|
||||||
|
port="8008"
|
||||||
# You may to customize this time span to fit your needs.
|
# You may to customize this time span to fit your needs.
|
||||||
timestamp60DaysAgo=`date +%s000 --date "60 days ago"`
|
timestamp60DaysAgo=$(date +%s000 --date "60 days ago")
|
||||||
|
|
||||||
if [ -z "$serverDomain" ]
|
if [ -z "$serverDomain" ]
|
||||||
then
|
then
|
||||||
read -p "Enter the Matrix server domain: (e.g. matrix.mydomain.com): " serverDomain
|
read -pr "Enter the Matrix server domain: (e.g. matrix.mydomain.com): " serverDomain
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
read -p "Enter your access token: " token
|
read -pr "Enter your access token: " token
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete local media
|
# Delete local media
|
||||||
echo "Delete local media..."
|
echo "Delete local media..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v1/media/$serverDomain/delete?before_ts=$timestamp60DaysAgo&access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v1/media/$serverDomain/delete?before_ts=$timestamp60DaysAgo&access_token=$token"
|
||||||
curl -XPOST $curlUrl
|
curl -k -X POST "$curlUrl"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -46,8 +48,8 @@ echo ""
|
||||||
# Purge remote media
|
# Purge remote media
|
||||||
echo "Purge remote media..."
|
echo "Purge remote media..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v1/purge_media_cache?before_ts=$timestamp60DaysAgo&access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v1/purge_media_cache?before_ts=$timestamp60DaysAgo&access_token=$token"
|
||||||
curl -XPOST $curlUrl
|
curl -k -X POST "$curlUrl"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
token=""
|
token=""
|
||||||
|
protocol="http"
|
||||||
|
port="8008"
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
|
|
@ -20,7 +22,7 @@ then
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Enter the user which should be deactivated: (e.g. @test:matrix.mydomain.com): " user_to_deactivate
|
read -pr "Enter the user which should be deactivated: (e.g. @test:matrix.mydomain.com): " user_to_deactivate
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# User lower case only
|
# User lower case only
|
||||||
|
|
@ -29,8 +31,8 @@ user_to_deactivate="${user_to_deactivate,,}"
|
||||||
# Deactivate user
|
# Deactivate user
|
||||||
echo "Deactivate user $user_to_deactivate..."
|
echo "Deactivate user $user_to_deactivate..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v1/deactivate/$user_to_deactivate?access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v1/deactivate/$user_to_deactivate?access_token=$token"
|
||||||
curl -X POST $curlUrl -H 'Content-Type: application/json' -d '{"erase": true}'
|
curl -k -X POST "$curlUrl" -H 'Content-Type: application/json' -d '{"erase": true}'
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -23,7 +23,7 @@ echo ""
|
||||||
echo "Your access token:"
|
echo "Your access token:"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo $content
|
echo "$content"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,22 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
token=""
|
token=""
|
||||||
|
protocol="http"
|
||||||
|
ort="8008"
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
read -p "Enter your access token: " token
|
read -pr "Enter your access token: " token
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# List users
|
# List users
|
||||||
echo "Retrieving users..."
|
echo "Retrieving users..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_synapse/admin/v2/users?access_token=$token"
|
curlUrl="$protocol://localhost:$port/_synapse/admin/v2/users?access_token=$token"
|
||||||
output=$(curl $curlUrl)
|
output=$(curl -k "$curlUrl")
|
||||||
echo ""
|
echo ""
|
||||||
echo $output | python -m json.tool
|
echo "$output" | python -m json.tool
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# Requirements:
|
# Requirements:
|
||||||
# - The script has to be executed on the same machine where Matrix Synapse is installed.
|
# - The script has to be executed on the same machine where Matrix Synapse is installed.
|
||||||
# - You 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 "advanced" (internal room ID).
|
||||||
# - For authentication, you will need the access token of your (admin) account.
|
# - 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.
|
# 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").
|
# Copy this token and paste it further down (variable "token").
|
||||||
|
|
@ -14,25 +14,28 @@
|
||||||
|
|
||||||
token=""
|
token=""
|
||||||
newRoomVersion=""
|
newRoomVersion=""
|
||||||
|
roomId=""
|
||||||
|
protocol="http"
|
||||||
|
port="8008"
|
||||||
|
|
||||||
if [ -z "$newRoomVersion" ]
|
if [ -z "$newRoomVersion" ]
|
||||||
then
|
then
|
||||||
read -p "Enter the new room version (e.g. 6): " newRoomVersion
|
read -pr "Enter the new room version (e.g. 6): " newRoomVersion
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$token" ]
|
if [ -z "$token" ]
|
||||||
then
|
then
|
||||||
read -p "Enter your access token: " token
|
read -pr "Enter your access token: " token
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete local media
|
# Delete local media
|
||||||
echo "Update room version of room $roomId..."
|
echo "Update room version of room $roomId..."
|
||||||
echo ""
|
echo ""
|
||||||
curlUrl="http://localhost:8008/_matrix/client/r0/rooms/$roomId/upgrade?access_token=$token"
|
curlUrl="$protocol://localhost:$port/_matrix/client/r0/rooms/$roomId/upgrade?access_token=$token"
|
||||||
curl -X POST $curlUrl -H 'Content-Type: application/json' -d '{"new_version": "'"$newRoomVersion"'"}'
|
curl -k -X POST "$curlUrl" -H 'Content-Type: application/json' -d '{"new_version": "'"$newRoomVersion"'"}'
|
||||||
echo ""
|
echo ""
|
||||||
echo "Done"
|
echo "Done"
|
||||||
echo ""
|
echo ""
|
||||||
Loading…
Reference in New Issue