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