Correct issue with docker group being added to user.

This commit is contained in:
Nick Hepler 2024-10-14 17:30:38 -04:00
parent fafdafa022
commit 811f61ddb4

View File

@ -6,6 +6,7 @@
# Variables # Variables
timezone="America/New_York" timezone="America/New_York"
sshd_config="/etc/ssh/sshd_config" sshd_config="/etc/ssh/sshd_config"
docker_installed=false
# Function to prompt for hostname # Function to prompt for hostname
prompt_for_hostname() { prompt_for_hostname() {
@ -48,6 +49,7 @@ 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
} }
# Function to create a limited user account # Function to create a limited user account
@ -63,9 +65,9 @@ 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."
# Check if Docker is installed and add the user to the docker group # Add the user to the docker group if Docker is installed
if command -v docker &> /dev/null; then if [ "$docker_installed" = true ]; then
usermod -aG docker "$username" usermod -aG docker "$username"
echo "User $username added to the docker group." echo "User $username added to the docker group."
fi fi