diff --git a/ActivateUser.sh b/ActivateUser.sh index eec7ea0..64b76d4 100644 --- a/ActivateUser.sh +++ b/ActivateUser.sh @@ -13,16 +13,18 @@ # token="" +protocol="http" +port="8008" if [ -z "$token" ] then - read -p "Enter your access token: " token + read -pr "Enter your access token: " token echo "" 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 "" -read -sp "Enter the new passwort for user: " new_password +read -spr "Enter the new passwort for user: " new_password echo "" # User lower case only @@ -31,10 +33,10 @@ user_to_activate="${user_to_activate,,}" # Activate user echo "Activate user $user_to_activate..." 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 -curl -X PUT $curlUrl -H 'Content-Type: application/json' -d '{"deactivated": false, "password":"'"$new_password"'"}' +echo "$curlUrl" +curl -k -X PUT "$curlUrl" -H 'Content-Type: application/json' -d '{"deactivated": false, "password":"'"$new_password"'"}' echo "" echo "Done" echo "" \ No newline at end of file diff --git a/ChangeUserPassword.sh b/ChangeUserPassword.sh index 77ae90a..0bb9997 100644 --- a/ChangeUserPassword.sh +++ b/ChangeUserPassword.sh @@ -13,6 +13,8 @@ # token="" +protocol="http" +port="8008" if [ -z "$token" ] then @@ -20,16 +22,16 @@ then echo "" 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 "" -read -sp "Enter the NEW password: " new_password +read -spr "Enter the NEW password: " new_password echo "" -read -sp "Confirm the new password: " new_password2 +read -spr "Confirm the new password: " new_password2 echo "" -if [ $new_password != $new_password2 ]; then +if [ "$new_password" != "$new_password2" ]; then echo "Error: The passwords do not match" echo "The password was NOT changed"! exit 1 @@ -41,8 +43,8 @@ user_to_change_password="${user_to_change_password,,}" # Change users's password echo "Change password for user $user_to_change_password..." echo "" -curlUrl="http://localhost:8008/_synapse/admin/v2/users/$user_to_change_password?access_token=$token" -curl -X PUT $curlUrl -H 'Content-Type: application/json' -d '{"password": "'"$new_password"'"}' +curlUrl="$protocol://localhost:$port/_synapse/admin/v2/users/$user_to_change_password?access_token=$token" +curl -k -X PUT "$curlUrl" -H 'Content-Type: application/json' -d '{"password": "'"$new_password"'"}' echo "" echo "Done" echo "" \ No newline at end of file diff --git a/CleanupMedia.sh b/CleanupMedia.sh index fdf72ff..0f837f8 100644 --- a/CleanupMedia.sh +++ b/CleanupMedia.sh @@ -19,26 +19,28 @@ serverDomain="" token="" +protocol="http" +port="8008" # 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" ] 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 "" fi if [ -z "$token" ] then - read -p "Enter your access token: " token + read -pr "Enter your access token: " token echo "" fi # Delete local media echo "Delete local media..." echo "" -curlUrl="http://localhost:8008/_synapse/admin/v1/media/$serverDomain/delete?before_ts=$timestamp60DaysAgo&access_token=$token" -curl -XPOST $curlUrl +curlUrl="$protocol://localhost:$port/_synapse/admin/v1/media/$serverDomain/delete?before_ts=$timestamp60DaysAgo&access_token=$token" +curl -k -X POST "$curlUrl" echo "" echo "Done" echo "" @@ -46,8 +48,8 @@ echo "" # Purge remote media echo "Purge remote media..." echo "" -curlUrl="http://localhost:8008/_synapse/admin/v1/purge_media_cache?before_ts=$timestamp60DaysAgo&access_token=$token" -curl -XPOST $curlUrl +curlUrl="$protocol://localhost:$port/_synapse/admin/v1/purge_media_cache?before_ts=$timestamp60DaysAgo&access_token=$token" +curl -k -X POST "$curlUrl" echo "" echo "Done" echo "" \ No newline at end of file diff --git a/DeactivateUser.sh b/DeactivateUser.sh index 7709b1c..0c1358e 100644 --- a/DeactivateUser.sh +++ b/DeactivateUser.sh @@ -13,6 +13,8 @@ # token="" +protocol="http" +port="8008" if [ -z "$token" ] then @@ -20,7 +22,7 @@ then echo "" 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 "" # User lower case only @@ -29,8 +31,8 @@ user_to_deactivate="${user_to_deactivate,,}" # Deactivate user echo "Deactivate user $user_to_deactivate..." echo "" -curlUrl="http://localhost:8008/_synapse/admin/v1/deactivate/$user_to_deactivate?access_token=$token" -curl -X POST $curlUrl -H 'Content-Type: application/json' -d '{"erase": true}' +curlUrl="$protocol://localhost:$port/_synapse/admin/v1/deactivate/$user_to_deactivate?access_token=$token" +curl -k -X POST "$curlUrl" -H 'Content-Type: application/json' -d '{"erase": true}' echo "" echo "Done" echo "" \ No newline at end of file diff --git a/GetAccessToken.sh b/GetAccessToken.sh index ea72d1e..d58d21c 100644 --- a/GetAccessToken.sh +++ b/GetAccessToken.sh @@ -23,7 +23,7 @@ echo "" echo "Your access token:" echo "" -echo $content +echo "$content" echo "" echo "" diff --git a/GetAllUsers.sh b/GetAllUsers.sh index 0beaf05..33386c2 100644 --- a/GetAllUsers.sh +++ b/GetAllUsers.sh @@ -13,20 +13,22 @@ # token="" +protocol="http" +ort="8008" if [ -z "$token" ] then - read -p "Enter your access token: " token + read -pr "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) +curlUrl="$protocol://localhost:$port/_synapse/admin/v2/users?access_token=$token" +output=$(curl -k "$curlUrl") echo "" -echo $output | python -m json.tool +echo "$output" | python -m json.tool echo "" echo "Done" echo "" \ No newline at end of file diff --git a/UpdateRoomVersion.sh b/UpdateRoomVersion.sh index e6ec4a4..01f7cb4 100644 --- a/UpdateRoomVersion.sh +++ b/UpdateRoomVersion.sh @@ -6,7 +6,7 @@ # Requirements: # - 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. # You can obtain it in your Element client: "All settings" > "Help & About" > scroll down > click on "" to get your access token. # Copy this token and paste it further down (variable "token"). @@ -14,25 +14,28 @@ token="" newRoomVersion="" +roomId="" +protocol="http" +port="8008" if [ -z "$newRoomVersion" ] then - read -p "Enter the new room version (e.g. 6): " newRoomVersion + read -pr "Enter the new room version (e.g. 6): " newRoomVersion echo "" fi if [ -z "$token" ] then - read -p "Enter your access token: " token + read -pr "Enter your access token: " token echo "" fi # Delete local media echo "Update room version of room $roomId..." echo "" -curlUrl="http://localhost:8008/_matrix/client/r0/rooms/$roomId/upgrade?access_token=$token" -curl -X POST $curlUrl -H 'Content-Type: application/json' -d '{"new_version": "'"$newRoomVersion"'"}' +curlUrl="$protocol://localhost:$port/_matrix/client/r0/rooms/$roomId/upgrade?access_token=$token" +curl -k -X POST "$curlUrl" -H 'Content-Type: application/json' -d '{"new_version": "'"$newRoomVersion"'"}' echo "" echo "Done" echo "" \ No newline at end of file