From 3a758863e80c8bdbe8627bd70967e89dbdce3ae0 Mon Sep 17 00:00:00 2001 From: Epic Curious <109078515+epiccurious@users.noreply.github.com> Date: Thu, 30 Nov 2023 23:43:36 -0500 Subject: [PATCH 1/2] Remove sudo requirement for dependencies and chmod --- flash_your_device | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/flash_your_device b/flash_your_device index 63f8810..06219b9 100755 --- a/flash_your_device +++ b/flash_your_device @@ -39,10 +39,20 @@ case "$(uname -s)" in Linux*) machine="Linux" echo "Detected ${machine}." - echo -n "Checking for cmake, git, pip, and venv... " - #[ -f /var/lib/apt/lists/lock ] && echo "ERROR: `apt` is locked. Are you installing system updates?" && exit 1 - sudo apt-get -qq update - sudo apt-get -qq install -y -o=Dpkg::Use-Pty=0 cmake git python3-pip python3-venv &> /dev/null + echo -n "Checking for cmake, git, pip, and virtualenv... " + if ! command -v cmake &>/dev/null; then + echo -e "\n\nERROR:\ncmake was not found on your system.\n\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n" + exit 1 + elif ! command -v git &>/dev/null; then + echo -e "\n\nERROR:\ngit was not found on your system.\n\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n" + exit 1 + elif ! command -v pip &>/dev/null; then + echo -e "\n\nERROR:\npip was not found on your system.\n\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n" + exit 1 + elif ! command -v virtualenv &>/dev/null; then + echo -e "\n\nERROR:\nvirtualenv was not found on your system.\n\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n" + exit 1 + fi echo "ok." ;; Darwin*) @@ -94,7 +104,7 @@ case "$(uname -s)" in *) echo "Unsupported OS: $(uname -s)" && exit 0 esac -echo -n "Checking for the Espressif IoT Development Framework... " +echo -n "Checking for the ESP IoT Development Framework... " if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then echo -ne "\n Downloading the framework... " git -c advice.detachedHead=false clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}" @@ -176,7 +186,11 @@ case "${machine}" in while [ ! -c "${tty_device}" ]; do read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo done - sudo chmod o+rw "${tty_device}" + tty_device_permissions="$(stat -c '%a' /dev/ttyACM0)" + if [ "${tty_device_permissions:2}" -lt 6 ]; then + echo -e "ERROR:\nYou need elevated permissions to write to the device.\nPlease update your device permissoins by running:\n\nsudo chmod o+rw ${tty_device}\n" + exit 1 + fi ;; macOS*) #macos_usb_serial=$(ioreg -p IOUSB -n "USB Single Serial" | grep "USB Serial Number" | cut -c 34-43) From aaaddd869b0b32eabe36b8cb5a117d280c675dfe Mon Sep 17 00:00:00 2001 From: Epic Curious <109078515+epiccurious@users.noreply.github.com> Date: Sat, 2 Dec 2023 08:03:41 -0500 Subject: [PATCH 2/2] Improve user messages --- flash_your_device | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flash_your_device b/flash_your_device index 06219b9..6fbd8ad 100755 --- a/flash_your_device +++ b/flash_your_device @@ -39,18 +39,18 @@ case "$(uname -s)" in Linux*) machine="Linux" echo "Detected ${machine}." - echo -n "Checking for cmake, git, pip, and virtualenv... " + echo -n "Checking for dependencies... " if ! command -v cmake &>/dev/null; then - echo -e "\n\nERROR:\ncmake was not found on your system.\n\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n" + echo -e "\n\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n" exit 1 elif ! command -v git &>/dev/null; then - echo -e "\n\nERROR:\ngit was not found on your system.\n\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n" + echo -e "\n\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n" exit 1 elif ! command -v pip &>/dev/null; then - echo -e "\n\nERROR:\npip was not found on your system.\n\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n" + echo -e "\n\nERROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n" exit 1 elif ! command -v virtualenv &>/dev/null; then - echo -e "\n\nERROR:\nvirtualenv was not found on your system.\n\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n" + echo -e "\n\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n" exit 1 fi echo "ok." @@ -104,7 +104,7 @@ case "$(uname -s)" in *) echo "Unsupported OS: $(uname -s)" && exit 0 esac -echo -n "Checking for the ESP IoT Development Framework... " +echo -n "Checking for the Espressif IoT Development Framework... " if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then echo -ne "\n Downloading the framework... " git -c advice.detachedHead=false clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 --quiet "${esp_idf_repo_url}" "${esp_idf_temp_directory}" @@ -220,4 +220,4 @@ echo ${flash_command} -echo -e "\nSUCCESS! Jade ${jade_version} is now installed on your ${chosen_device}.\nYou can close this window now.\n" +echo -e "\nSUCCESS! Jade ${jade_version} is now installed on your ${chosen_device}.\nYou can close this window.\n"