mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 10:34:28 +05:00
fix: check if user is in group "dialout" before starting flash or build+flash routine
This commit is contained in:
@@ -282,3 +282,37 @@ retrieve_id(){
|
||||
done
|
||||
fi 2>/dev/null
|
||||
}
|
||||
|
||||
check_usergroup_dialout(){
|
||||
USER_IN_DIALOUT_GROUP=$(groups "${USER}" | grep "dialout")
|
||||
if [ -z "$USER_IN_DIALOUT_GROUP" ]; then
|
||||
top_border
|
||||
echo -e "| ${yellow}WARNING: Your current user is not in group 'dialout'!${default} |"
|
||||
blank_line
|
||||
echo -e "| It is very likely that you won't be able to flash the |"
|
||||
echo -e "| MCU without your user being a member of this group. |"
|
||||
blank_line
|
||||
echo -e "| Answer 'Yes' if you want to add your current user to |"
|
||||
echo -e "| the group 'dialout' now. You need to relog or restart |"
|
||||
echo -e "| to apply that change to take effect. |"
|
||||
bottom_border
|
||||
while true; do
|
||||
read -p "${cyan}###### Add user '${USER}' to group 'dialout' now? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
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)
|
||||
echo -e "###### > No"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
ok_msg "User ${USER} already in group 'dialout'!"
|
||||
fi
|
||||
}
|
||||
@@ -41,12 +41,14 @@ advanced_menu(){
|
||||
3)
|
||||
do_action "build_fw" "advanced_ui";;
|
||||
4)
|
||||
clear && print_header
|
||||
check_usergroup_dialout
|
||||
do_action "select_flash_method" "advanced_ui";;
|
||||
5)
|
||||
clear && print_header
|
||||
check_usergroup_dialout
|
||||
status_msg "Please wait..."
|
||||
build_fw
|
||||
select_flash_method
|
||||
build_fw && select_flash_method
|
||||
print_msg && clear_msg
|
||||
advanced_ui;;
|
||||
6)
|
||||
|
||||
Reference in New Issue
Block a user