#jinja2: lstrip_blocks: "True"
#!/bin/bash

{% if matrix_synapse_experimental_features_msc3861_enabled %}
	echo "Registering users is handled by the Matrix Authentication Service, so you cannot use this script anymore."
	echo "Consider using the {{ matrix_synapse_register_user_script_matrix_authentication_service_path }} script instead."
	exit 2
{% else %}
if [ $# -ne 3 ]; then
	echo "Usage: "$0" <username> <password> <admin access: 0 or 1>"
	exit 1
fi

user=$1
password=$2
admin=$3

if [ "$admin" -eq "1" ]; then
	{{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse register_new_matrix_user -u "$user" -p "$password" -c /data/homeserver.yaml --admin http://localhost:{{ matrix_synapse_container_client_api_port }}
else
	{{ devture_systemd_docker_base_host_command_docker }} exec matrix-synapse register_new_matrix_user -u "$user" -p "$password" -c /data/homeserver.yaml --no-admin http://localhost:{{ matrix_synapse_container_client_api_port }}
fi
{% endif %}
