diff --git a/scripts/flash_mcu.sh b/scripts/flash_mcu.sh index e75d085..a3ce472 100755 --- a/scripts/flash_mcu.sh +++ b/scripts/flash_mcu.sh @@ -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 +} \ No newline at end of file diff --git a/scripts/ui/advanced_menu.sh b/scripts/ui/advanced_menu.sh index 5f7cf5e..b07bc19 100755 --- a/scripts/ui/advanced_menu.sh +++ b/scripts/ui/advanced_menu.sh @@ -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)