element-hq / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://element-hq.github.io/dendrite/
GNU Affero General Public License v3.0
37 stars 6 forks source link

Bulk User Creation #3362

Open matrixbot opened 3 weeks ago

matrixbot commented 3 weeks ago

This issue was originally created by @NassemKa at https://github.com/matrix-org/dendrite/issues/3362.

Background information

Description

Assuming your CSV file has two columns: username,password

Adjust accordingly if your CSV format is different

CSV_FILE="usernames_passwords.csv"

Check if CSV file exists

if [ ! -f "$CSV_FILE" ]; then echo "CSV file $CSV_FILE not found." exit 1 fi

Loop through each line in the CSV file

while IFS=',' read -r username password; do

Print the username and password

echo "Creating user: $username with password: $password"

Execute the create-account command with the username and password

/usr/bin/create-account -config /etc/dendrite/dendrite.yaml -username "$username" -password "$password"

Add a 1-second delay

sleep 1 done < "$CSV_FILE"

- Here is a sample of console i get after running the script:
```bash
Creating user: user_1001 with password: tsr0E4Mkha
INFO[0000] Created account: user_1001 (AccessToken: hmzXH1DODVbmHfTpqwT3zpg0LfrNRq53VvmX705cCBc)
Creating user: user_1002 with password: oCwwM12fHy
INFO[0000] Created account: user_1002 (AccessToken: xiGSiaOBe_FreHhOgDrRqoCC7HK7z5HAlQUL5uipCqs)
Creating user: user_1003 with password: ooCVDxYw9G
INFO[0000] Created account: user_1003 (AccessToken: qDQMH-lJYqU-KviUkJXh0wGaFrxs6fBWhlBDhQ2Bqu4)
Creating user: user_1004 with password: z8CsklxNte
INFO[0000] Created account: user_1004 (AccessToken: BdkLUF7OQ981GNKXNtzKQ88qiW0SvMlaj-tmGVPIl7A)
Creating user: user_1005 with password: caxpQYNkF9
INFO[0000] Created account: user_1005 (AccessToken: tZSzzX5wp4YX9z355CE2u7fv_8-9wr8b5_iyVP42O98)

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">

user_1001 | tsr0E4Mkha -- | -- user_1002 | oCwwM12fHy user_1003 | ooCVDxYw9G user_1004 | z8CsklxNte user_1005 | caxpQYNkF9