mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 18:44:29 +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
|
done
|
||||||
fi 2>/dev/null
|
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)
|
3)
|
||||||
do_action "build_fw" "advanced_ui";;
|
do_action "build_fw" "advanced_ui";;
|
||||||
4)
|
4)
|
||||||
|
clear && print_header
|
||||||
|
check_usergroup_dialout
|
||||||
do_action "select_flash_method" "advanced_ui";;
|
do_action "select_flash_method" "advanced_ui";;
|
||||||
5)
|
5)
|
||||||
clear && print_header
|
clear && print_header
|
||||||
|
check_usergroup_dialout
|
||||||
status_msg "Please wait..."
|
status_msg "Please wait..."
|
||||||
build_fw
|
build_fw && select_flash_method
|
||||||
select_flash_method
|
|
||||||
print_msg && clear_msg
|
print_msg && clear_msg
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
6)
|
6)
|
||||||
|
|||||||
Reference in New Issue
Block a user