drone/app/gitspace/orchestrator/template/templates/manage_user.sh
Ansuman Satapathy b6034a25aa feat: [CDE-195]: read devcontainer.json directly for gitness (#2294)
* feat: [CDE-195]: Run VS Code Web as non-root user.
* feat: [CDE-195]: read devcontainer.json directly for gitness
2024-07-26 12:44:36 +00:00

24 lines
660 B
Bash

#!/bin/sh
username={{ .Username }}
password={{ .Password }}
workingDir={{ .WorkingDirectory }}
# Check if the user already exists
if id "$username" >/dev/null 2>&1; then
echo "User $username already exists."
else
# Create a new user
adduser --disabled-password --gecos "" "$username"
if [ $? -ne 0 ]; then
echo "Failed to create user $username."
exit 1
fi
fi
# Set or update the user's password using chpasswd
echo "$username:$password" | chpasswd
# Changing ownership of everything inside user home to the newly created user
chown -R $username $workingDir
echo "Changing ownership of dir $workingDir to user $username."