Script to add users

In my Vikunja installation on Docker, I don’t want just anyone to enter and register, but the interface doesn’t have any simple area from which to manage the users who are already registered or to register new users.

So I’ve opted to create a small script to register new users, delete users who were registered, and list users. Maybe it can be useful to someone. I’ll leave it here for you.


# Function to list users
list_users() {
    echo "User list:"
    docker exec vikunja_api /app/vikunja/vikunja user list

# Function to create a user
create_user() {
    # Prompt the user for the username
    read -p "Enter the username: " username

    # Prompt the user for the password (without showing it on the screen)
    read -sp "Enter the password: " password

    # Prompt the user for the email address
    read -p "Enter the email address: " email

    # Execute the docker command with the values provided by the user
    docker exec vikunja_api /app/vikunja/vikunja user create -e "$email" -p "$password" -u "$username"

# Function to delete a user
delete_user() {
    # List users to display the IDs

    # Prompt the user for the ID of the user to delete
    read -p "Enter the ID of the user you want to delete: " userID

    # Execute the docker command to delete the user with the provided ID
    docker exec vikunja_api /app/vikunja/vikunja user delete "$userID" -c -n

# Main function
main() {
    while true; do
        echo "What action would you like to perform?"
        echo "1. List users"
        echo "2. Create user"
        echo "3. Delete user"
        echo "4. Exit"

        read -p "Enter the number of the action you want to perform: " option

        case $option in
                echo "Exiting the program."
                exit 0
                echo "Invalid option. Please select a valid option."

# Call to the main function