diff --git a/install.sh b/install.sh index e212463..736f690 100644 --- a/install.sh +++ b/install.sh @@ -1,7 +1,26 @@ #!/bin/bash +echo -e "\n\nBEGINNING AUTOMATED INSTALL WITH DEFAULTS\n\n" + +# possible package manager shit for later # sudo apt update # sudo apt install git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 +# detect shell and act accordingly +defShell=$(awk -F: -v user="$(whoami)" '$1 == user {print $NF}' /etc/passwd) + +if [[ "$defShell" =~ zsh$ ]]; then + echo -e "\nSelected zsh shell automatically\n" + rcFile="$HOME/.zshrc" +elif [[ "$defShell" =~ bash$ ]]; then + echo -e "\nSelected bash shell automatically\n" + rcFile="$HOME/.bashrc" +elif [[ "$defShell" =~ sh$ ]]; then + rcFile="" # no need for rcFile var when run as cron +else + echo "unsupported shell $defShell" + exit +fi + # unset any esp-idf/-tools envvars unset ESPIDFTOOLS_INSTALLDIR unset IDF_PATH @@ -16,6 +35,13 @@ unset ESPPORT unset ESPBAUD unset ESPTARGET +# make installDir or fail silently if exists mkdir -p ~/esp + +# download da tools git clone --recursive https://github.com/PrincessPi3/esp-idf-tools.git ~/esp/esp-idf-tools -bash ~/esp/esp-idf-tools/esp-idf-tools-cmd.sh # run as default noninteractive mode \ No newline at end of file + +# do da install +bash ~/esp/esp-idf-tools/esp-idf-tools-cmd.sh # run as default noninteractive mode + +echo -e "\n\nINSTALL COMPLETE\n\n" \ No newline at end of file diff --git a/todo.txt b/todo.txt index 6799f22..345e0ef 100644 --- a/todo.txt +++ b/todo.txt @@ -32,4 +32,5 @@ uninstaller unset envvars if need be option for default nuke export - check for existance of esp model before allowing on export and changesp \ No newline at end of file + check for existance of esp model before allowing on export and changesp +tool to git pull recursive, retool, update, install as needed \ No newline at end of file diff --git a/uninstall.sh b/uninstall.sh index e77c395..16e6007 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,5 +1,19 @@ #!/bin/bash -rcFile=~/.bashrc +# detect shell and act accordingly +defShell=$(awk -F: -v user="$(whoami)" '$1 == user {print $NF}' /etc/passwd) + +if [[ "$defShell" =~ zsh$ ]]; then + echo -e "\nSelected zsh shell automatically\n" + rcFile="$HOME/.zshrc" +elif [[ "$defShell" =~ bash$ ]]; then + echo -e "\nSelected bash shell automatically\n" + rcFile="$HOME/.bashrc" +elif [[ "$defShell" =~ sh$ ]]; then + rcFile="" # no need for rcFile var when run as cron +else + echo "unsupported shell $defShell" + exit +fi echo "STARTING UNINSTALLATION" @@ -18,26 +32,26 @@ unset ESPPORT unset ESPBAUD unset ESPTARGET -# nuke dirs +# nuke dirs and supress errors echo -e "\tRemoving directories" rm -rf ~/esp/esp-idf 2>/dev/null rm -rf ~/esp/esp-dev-kits 2>/dev/null rm -rf ~/esp/esp-idf-tools 2>/dev/null rm -rf ~/.espressif 2>/dev/null -# nuke logs +# nuke logs and supress errors echo -e "\tRemoving log files" rm -f ~/esp/install.log 2>/dev/null rm -f ~/esp/version-data.log 2>/dev/null # cleanup $rcFile -echo -e "\tCleaning up $rcFile" -sed -i.bak '/# esp-idf-tools/d' $rcFile # with first one, maek a backup -sed -i '/ESPIDFTOOLS_INSTALLDIR/d' $rcFile -sed -i '/get-esp-tools/d' $rcFile -sed -i '/run-esp-cmd/d' $rcFile -sed -i '/esp-install-monitor/d' $rcFile -sed -i '/esp-install-logs/d' $rcFile -printf "%s" "$(cat $rcFile)" > $rcFile # remove leading and trailing newlines in place - +echo -e "\tCleaning up "$rcFile" +sed -i.bak '/# esp-idf-tools/d' "$rcFile" # with first one, maek a backup +sed -i '/ESPIDFTOOLS_INSTALLDIR/d' "$rcFile" +sed -i '/get-esp-tools/d' "$rcFile" +sed -i '/run-esp-cmd/d' "$rcFile +sed -i '/esp-install-monitor/d' "$rcFile" +sed -i '/esp-install-logs/d' "$rcFile" +## remove leading and trailing newlines in $rcFile in place +printf "%s" "$(cat $rcFile)" > "$rcFile" echo "DONE UNINSTALLING" \ No newline at end of file