Move usermod to install_docker function.

This commit is contained in:
Nick Hepler 2024-10-14 17:57:19 -04:00
parent 811f61ddb4
commit e9e19af507

View File

@ -49,7 +49,10 @@ install_docker() {
systemctl start docker systemctl start docker
systemctl enable docker systemctl enable docker
echo "Docker installation complete." echo "Docker installation complete."
docker_installed=true # Set the flag to true
usermod -aG docker "$username"
echo "User $username added to the docker group."
} }
# Function to create a limited user account # Function to create a limited user account
@ -65,12 +68,6 @@ create_user_account() {
useradd -m -G wheel "$username" useradd -m -G wheel "$username"
echo "$username:$password" | chpasswd echo "$username:$password" | chpasswd
echo "User $username created and added to the wheel group." echo "User $username created and added to the wheel group."
# Add the user to the docker group if Docker is installed
if [ "$docker_installed" = true ]; then
usermod -aG docker "$username"
echo "User $username added to the docker group."
fi
fi fi
} }