36 lines
978 B
Bash
Executable File
36 lines
978 B
Bash
Executable File
#!/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
|
|
|
|
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!"
|
|
echo "Make sure to save this access token! You'll need it to enable double puppeting in the bridges."
|
|
else
|
|
echo "Error: Failed to create user"
|
|
exit 1
|
|
fi
|