From 93ad356dbf68c82726f287bbdc9a758e2a2b1f50 Mon Sep 17 00:00:00 2001 From: Connor C Date: Wed, 17 Jul 2024 07:56:45 -0600 Subject: [PATCH] Add wheel group support to add_user function Signed-off-by: Connor C --- InitMate.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/InitMate.sh b/InitMate.sh index 996d28d..a7b0740 100644 --- a/InitMate.sh +++ b/InitMate.sh @@ -197,8 +197,15 @@ add_users() { echo "$USERNAME:$PASSWORD" | chpasswd if prompt_yes_no "Do you want to grant sudo access to $USERNAME?"; then - usermod -aG sudo "$USERNAME" - log "$USERNAME has been granted sudo access." + if getent group sudo >/dev/null; then + usermod -aG sudo "$USERNAME" + log "$USERNAME has been granted sudo access via sudo group." + elif getent group wheel >/dev/null; then + usermod -aG wheel "$USERNAME" + log "$USERNAME has been granted sudo access via wheel group." + else + log "Neither sudo nor wheel group exists. Cannot grant sudo access to $USERNAME." + fi fi if prompt_yes_no "Do you want to add a public key for $USERNAME?"; then