Add user creation script and update README instructions

This commit is contained in:
Roger Gonzalez 2024-11-27 20:15:25 -03:00
parent d128603b06
commit 3960b5884b
Signed by: rogs
GPG Key ID: C7ECE9C6C36EC2E6
2 changed files with 48 additions and 0 deletions

View File

@ -65,6 +65,19 @@ This script will create three new databases: `whatsapp`, `telegram`, and `discor
![image](https://gitlab.com/-/project/64900187/uploads/21724e8ed403f7d3a40737e39e8c5ee3/image.png)
7. Create your first user using the provided script:
```sh
./create-user.sh
```
The script will:
- Prompt you for a username
- Ask if the user should be an admin
- Create the account in your Dendrite server
You can run this script multiple times to create additional users as needed.
## That's It!
Dendrite is now up and running! You can proceed with setting up the bridges:

35
create-user.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# Prompt for username
read -p "Enter username: " USERNAME
# Validate username
if [[ ! $USERNAME =~ ^[a-zA-Z0-9_.-]+$ ]]; then
echo "Error: Username can only contain letters, numbers, underscores, dots, and hyphens"
exit 1
fi
# Prompt for admin status
while true; do
read -p "Should this user be an admin? (y/n): " ADMIN_RESPONSE
case $ADMIN_RESPONSE in
[Yy]* ) ADMIN_FLAG="--admin"; break;;
[Nn]* ) ADMIN_FLAG=""; break;;
* ) echo "Please answer y or n.";;
esac
done
# Execute the create-account command
echo "Creating user: $USERNAME"
docker compose exec monolith /usr/bin/create-account \
-config /etc/dendrite/dendrite.yaml \
-username "$USERNAME" \
$ADMIN_FLAG
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "User \"$USERNAME\" created successfully!"
else
echo "Error: Failed to create user"
exit 1
fi