Skip to content
Snippets Groups Projects
Commit 534ba7f5 authored by Bob Mottram's avatar Bob Mottram
Browse files

Changing matrix password

parent 46b9449b
No related branches found
No related tags found
No related merge requests found
......@@ -480,11 +480,50 @@ function install_interactive_matrix {
APP_INSTALLED=1
}
function create_matrix_user_password_script {
read_config_param ONION_ONLY
read_config_param MY_USERNAME
read_config_param MATRIX_DOMAIN_NAME
curl_command='curl'
homebase="https://$MATRIX_DOMAIN_NAME"
if [[ "$ONION_ONLY" != 'no' ]]; then
curl_command='torsocks curl'
homebase="http://$(cat /var/lib/tor/hidden_service_matrix/hostname)"
fi
matrix_passwd_filename=/usr/bin/matrix-passwd
{ echo '#!/bin/bash';
echo "cd $MATRIX_DATA_DIR || exit 1";
echo "username=\$1";
echo "if [ ! \"\$username\" ]; then";
echo ' echo "No username given"';
echo ' exit 1';
echo 'fi';
echo "new_password=\$2";
echo "if [ ! \"\$new_password\" ]; then";
echo ' echo "No password given"';
echo ' exit 2';
echo 'fi';
echo "ADMIN=\"@${MY_USERNAME}:$MATRIX_DOMAIN_NAME\"";
echo 'BUSY="pragma busy_timeout=20000"';
echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select token from access_tokens where user_id like '\$ADMIN' order by id desc limit 1;\")";
echo "TOKEN=\$(echo \$BUFFER|awk '{print \$2}')";
echo 'set -x';
echo "${curl_command} -X POST \"${homebase}/_matrix/client/r0/admin/reset_password/%40\$username%3A$MATRIX_DOMAIN_NAME?access_token=\$TOKEN\" --data '{\"new_password\":\"\$new_password\"}'"; } > $matrix_passwd_filename
chmod +x $matrix_passwd_filename
}
function change_password_matrix {
#curr_username="$1"
curr_username="$1"
new_user_password="$2"
#${PROJECT_NAME}-pass -u "$curr_username" -a matrix -p "$new_user_password"
create_matrix_user_password_script
/usr/bin/matrix-passwd "$curr_username" "$new_user_password"
"${PROJECT_NAME}-pass" -u "$curr_username" -a matrix -p "$new_user_password"
}
function reconfigure_matrix {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment