Script for changing user's passwords; cleanup
This commit is contained in:
parent
2080facee7
commit
2646aaa0bb
|
|
@ -5,22 +5,14 @@
|
|||
#
|
||||
|
||||
# Requirements:
|
||||
# - You'll need the domain of your server (variable "serverDomain").
|
||||
# - A new password for the user must be specified.
|
||||
# - 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
|
||||
|
|
@ -32,6 +24,9 @@ echo ""
|
|||
read -sp "Enter the new passwort for user: " new_password
|
||||
echo ""
|
||||
|
||||
# User lower case only
|
||||
user_to_activate="${user_to_activate,,}"
|
||||
|
||||
# Activate user
|
||||
echo "Activate user $user_to_activate..."
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Changes a password for a user
|
||||
#
|
||||
|
||||
# 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").
|
||||
# - The user (@username:mydomain.com) whose password should be changed
|
||||
#
|
||||
|
||||
token=""
|
||||
|
||||
if [ -z "$token" ]
|
||||
then
|
||||
read -p "Enter your access token: " token
|
||||
echo ""
|
||||
fi
|
||||
|
||||
read -p "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
|
||||
echo ""
|
||||
|
||||
read -sp "Confirm the new password: " new_password2
|
||||
echo ""
|
||||
|
||||
if [ $new_password != $new_password2 ]; then
|
||||
echo "Error: The passwords do not match"
|
||||
echo "The password was NOT changed"!
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# User lower case only
|
||||
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"'"}'
|
||||
echo ""
|
||||
echo "Done"
|
||||
echo ""
|
||||
|
|
@ -6,21 +6,13 @@
|
|||
|
||||
# IMPORTANT: You cannot delete a user from a Matrix server, a user can just get deactivated.
|
||||
# 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").
|
||||
#
|
||||
|
||||
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
|
||||
|
|
@ -30,6 +22,9 @@ fi
|
|||
read -p "Enter the user which should be deactivated: (e.g. @test:matrix.mydomain.com): " user_to_deactivate
|
||||
echo ""
|
||||
|
||||
# User lower case only
|
||||
user_to_deactivate="${user_to_deactivate,,}"
|
||||
|
||||
# Deactivate user
|
||||
echo "Deactivate user $user_to_deactivate..."
|
||||
echo ""
|
||||
|
|
|
|||
|
|
@ -5,22 +5,14 @@
|
|||
#
|
||||
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
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.
|
||||
* `ChangeUserPassword.sh`: Changes the password of the given user.
|
||||
* `CleanupMedia.sh`: Deletes old local and remote media.
|
||||
* `DeactivateUser.sh`: Deactivates the given user.
|
||||
* `GetAccessToken.sh`: Gets the access token with curl.
|
||||
|
|
|
|||
Loading…
Reference in New Issue