mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 11:04:29 +05:00
fix: add check for membership of group 'tty'
It's possible that being part of group 'tty' is also needed to be able to flash an MCU
This commit is contained in:
@@ -286,24 +286,42 @@ retrieve_id(){
|
|||||||
|
|
||||||
check_usergroup_dialout(){
|
check_usergroup_dialout(){
|
||||||
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
if grep -q "dialout" </etc/group && ! grep -q "dialout" <(groups "${USER}"); then
|
||||||
|
group_dialout=false
|
||||||
|
else
|
||||||
|
group_dialout=true
|
||||||
|
fi
|
||||||
|
if grep -q "tty" </etc/group && ! grep -q "tty" <(groups "${USER}"); then
|
||||||
|
group_tty=false
|
||||||
|
else
|
||||||
|
group_tty=true
|
||||||
|
fi
|
||||||
|
if [ "$group_dialout" == "false" ] || [ "$group_tty" == "false" ] ; 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:${default} |"
|
||||||
|
[ "$group_tty" == "false" ] && echo -e "| ${yellow}● tty${default} |"
|
||||||
|
[ "$group_dialout" == "false" ] && echo -e "| ${yellow}● dialout${default} |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| It is very likely that you won't be able to flash the |"
|
echo -e "| It is possible that you won't be able to successfully |"
|
||||||
echo -e "| MCU without your user being a member of this group. |"
|
echo -e "| flash without your user being a member of that group. |"
|
||||||
|
echo -e "| If you want to add the current user to the group(s) |"
|
||||||
|
echo -e "| listed above, answer with 'Y'. Else skip with 'n'. |"
|
||||||
blank_line
|
blank_line
|
||||||
echo -e "| Answer 'Yes' if you want to add your current user to |"
|
echo -e "| ${yellow}INFO:${default} |"
|
||||||
echo -e "| the group 'dialout' now. You need to relog or restart |"
|
echo -e "| ${yellow}Relog required for group assignments to take effect!${default} |"
|
||||||
echo -e "| to apply that change to take effect. |"
|
|
||||||
bottom_border
|
bottom_border
|
||||||
while true; do
|
while true; do
|
||||||
read -p "${cyan}###### Add user '${USER}' to group 'dialout' now? (Y/n):${default} " yn
|
read -p "${cyan}###### Add user '${USER}' to group(s) now? (Y/n):${default} " yn
|
||||||
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(s) ..."
|
||||||
sudo usermod -a -G dialout "${USER}" && ok_msg "Done!"
|
if [ "$group_tty" == "false" ]; then
|
||||||
ok_msg "You need to relog/restart for the group to be applied!" && exit 0;;
|
sudo usermod -a -G tty "${USER}" && ok_msg "Group 'tty' assigned!"
|
||||||
|
fi
|
||||||
|
if [ "$group_dialout" == "false" ]; then
|
||||||
|
sudo usermod -a -G dialout "${USER}" && ok_msg "Group 'dialout' assigned!"
|
||||||
|
fi
|
||||||
|
ok_msg "You need to relog/restart for the group(s) to be applied!" && exit 0;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
echo -e "###### > No"
|
echo -e "###### > No"
|
||||||
break;;
|
break;;
|
||||||
|
|||||||
Reference in New Issue
Block a user