From 4113732daa52d3de7bc8d4c501c05beb3a190970 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 24 Dec 2021 23:29:36 +0100 Subject: [PATCH] fix: check if group dialout exists first check if group dialout exists on the system. then check if the current user is not part of it. only then ask for adding the user to that group --- scripts/flash_mcu.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/flash_mcu.sh b/scripts/flash_mcu.sh index c109077..0787d53 100755 --- a/scripts/flash_mcu.sh +++ b/scripts/flash_mcu.sh @@ -285,8 +285,7 @@ retrieve_id(){ } check_usergroup_dialout(){ - USER_IN_DIALOUT_GROUP=$(groups "${USER}" | grep "dialout") - if [ -z "$USER_IN_DIALOUT_GROUP" ]; then + if grep -q "dialout" Yes" - status_msg "Adding user ${USER} to group 'dialout' ..." + status_msg "Adding user '${USER}' to group 'dialout' ..." sudo usermod -a -G dialout "${USER}" && ok_msg "Done!" ok_msg "You need to relog/restart for the group to be applied!" && exit 0;; N|n|No|no) @@ -313,7 +312,5 @@ check_usergroup_dialout(){ print_msg && clear_msg;; esac done - else - ok_msg "User ${USER} already in group 'dialout'!" fi } \ No newline at end of file