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
This commit is contained in:
th33xitus
2021-12-24 23:29:36 +01:00
parent 95808a0d5b
commit 4113732daa

View File

@@ -285,8 +285,7 @@ retrieve_id(){
} }
check_usergroup_dialout(){ check_usergroup_dialout(){
USER_IN_DIALOUT_GROUP=$(groups "${USER}" | grep "dialout") if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
if [ -z "$USER_IN_DIALOUT_GROUP" ]; then
top_border top_border
echo -e "| ${yellow}WARNING: Your current user is not in group 'dialout'!${default} |" echo -e "| ${yellow}WARNING: Your current user is not in group 'dialout'!${default} |"
blank_line blank_line
@@ -302,7 +301,7 @@ check_usergroup_dialout(){
case "$yn" in case "$yn" in
Y|y|Yes|yes|"") Y|y|Yes|yes|"")
echo -e "###### > Yes" echo -e "###### > 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!" sudo usermod -a -G dialout "${USER}" && ok_msg "Done!"
ok_msg "You need to relog/restart for the group to be applied!" && exit 0;; ok_msg "You need to relog/restart for the group to be applied!" && exit 0;;
N|n|No|no) N|n|No|no)
@@ -313,7 +312,5 @@ check_usergroup_dialout(){
print_msg && clear_msg;; print_msg && clear_msg;;
esac esac
done done
else
ok_msg "User ${USER} already in group 'dialout'!"
fi fi
} }