diff --git a/README.md b/README.md index 219b523..43fa2ea 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Some take optional [branch] paramater [branch] is the esp-idf branch you desire, defaults to master if not specified. default: reinstalls non-interactively with no delays, logouts, or reboots - * `run-esp-cmd` + `run-esp-cmd` test: tests the script. very fast. minimal actions taken. no reinstall is done @@ -77,41 +77,40 @@ Some take optional [branch] paramater ``` ## Features -``` -`get-idf-tools` enter esp-idf -`help-esp-tools` show this help -`exit-esp-tools` exit esp-idf and reset terminal -`build` idf.py build -`changebaud` prompts to enter a new baud -`changeesp` change esp device - `changeesp` alone prompts to enter - `changeesp ` manually changes to - ex. `changeesp esp32p4` -`changeport` change serial port - `changeport` alone prompts to select - `changeport ` manually specifies path - ex. `changeport /dev/ttyUSB0` changes to /dev/ttyUSB0 -`clean` idf.py clean -`fullclean` fully resets a project, 'idf.py fullclean' plus remove the build dir and delete some temp and backup files -`rebuildfull` does a `fullclean` but also an `erase-flash` and also `setup` -`setup` same as running `idf.py set-target $ESPTARGET; idf.py menuconfig; idf.py build` -`flash` idf.py flash -`monitor` idf.py monitor -`erase-flash` idf.py erase-flash -`save-defconfig` idf.py save-defconfig -`step-flash-monitor` attempt clean, build, flash, then monitor, dying on error -`imagesize` get binary size, broken down in various ways including total, by componant, and by file -`chipinfo` get information from the esp chip -`espinfo` get detailed information from the esp chip -`menuconfig` run `idf.py menuconfig` -`create-project ` same as idf.py create-project - ex. `create-project hello-world` -`esp-install-monitor` monitors install.log. alias for `tail -n 75 -f $ESPIDF_INSTALLDIR/install.log` -`esp-install-logs` displays full text of install.log and version-data.txt -``` +* `get-idf-tools` enter esp-idf +* `help-esp-tools` show this help +* `exit-esp-tools` exit esp-idf and reset terminal +* `build` idf.py build +* `changebaud` prompts to enter a new baud +* `changeesp` change esp device + * `changeesp` alone prompts to enter +* `changeesp ` manually changes to + * ex. `changeesp esp32p4` +* `changeport` change serial port + * `changeport` alone prompts to select + * `changeport ` manually specifies path + * ex. `changeport /dev/ttyUSB0` changes to /dev/ttyUSB0 +* `clean` idf.py clean +* `fullclean` fully resets a project, 'idf.py fullclean' plus remove the build dir and delete some temp and backup files +* `rebuildfull` does a `fullclean` but also an `erase-flash` and also `setup` +* `setup` same as running `idf.py set-target $ESPTARGET; idf.py menuconfig; idf.py build` +* `flash` idf.py flash +* `monitor` idf.py monitor +* `erase-flash` idf.py erase-flash +* `save-defconfig` idf.py save-defconfig +* `step-flash-monitor` attempt clean, build, flash, then monitor, dying on error +* `imagesize` get binary size, broken down in various ways including total, by componant, and by file +* `chipinfo` get information from the esp chip +* `espinfo` get detailed information from the esp chip +* `menuconfig` run `idf.py menuconfig` +* `create-project ` same as idf.py create-project + * ex. `create-project hello-world` +* `esp-install-monitor` monitors install.log. alias for `tail -n 75 -f $ESPIDF_INSTALLDIR/install.log` +* `esp-install-logs` displays full text of install.log and version-data.txt ### Cronjob - reinstall from master everyday at 4am, logging out users with warn delays and rebooting after - `crontab -e` - add below to bottom of file: - `0 4 * * * bash $HOME/esp/esp-install-custom/esp-idf-tools-cmd.sh cron \ No newline at end of file + +reinstall from master everyday at 4am, logging out users with warn delays and rebooting after +* `crontab -e` +add below to bottom of file: +* `0 4 * * * bash $HOME/esp/esp-install-custom/esp-idf-tools-cmd.sh cron` \ No newline at end of file diff --git a/add-to-export-sh.txt b/add-to-export-sh.txt index c08376b..ab4ac53 100644 --- a/add-to-export-sh.txt +++ b/add-to-export-sh.txt @@ -64,17 +64,14 @@ echo -e "\nSetting alias" alias changeport="source $binDir/changeport.sh" alias changebaud="source $binDir/changebaud.sh" alias changeesp="source $binDir/changeesp.sh" -alias exit-esp-tools="source $binDir/exit-idf.sh" -alias monitor="idf.py monitor" -alias flashmonitor="idf.py flash monitor" -alias menuconfig="idf.py menuconfig" +alias exit-esp-tools="source $binDir/exit-esp-tools.sh" # echo -e "Changing dir to $ESPIDF_INSTALLDIR" cd $ESPIDF_INSTALLDIR echo -e "\nesp-idf version: $ESP_IDF_VERSION commit $commitHash from branch $branchData" -echo -e "\nrun with `run_esp_cmd`" +echo -e "\nrun with 'run_esp_cmd'" echo -e "\nWelcome to esp-idf!\nAll done :3\n" diff --git a/custom_bin/changebaud.sh b/custom_bin/changebaud.sh index 3d434fd..e94a82c 100644 --- a/custom_bin/changebaud.sh +++ b/custom_bin/changebaud.sh @@ -14,8 +14,12 @@ subprocess() { return $selection } -subprocess -ret=$? +if [ ! -z $1 ]; then + ret="$1" +else + ret='' + subprocess ret +fi export ESPBAUD=$ret echo "\nBaudrate set to $ESPBAUD\n" diff --git a/custom_bin/espinfo b/custom_bin/espinfo index 18743bf..9d982bf 100644 --- a/custom_bin/espinfo +++ b/custom_bin/espinfo @@ -1,12 +1,13 @@ -echo "esp-idf install dir: $ESPIDF_INSTALLDIR" +echo "esp-idf-tools install dir: $ESPIDF_INSTALLDIR" +echo "esp-idf-tools last install: $(tail -1 $ESPIDF_INSTALLDIR/version-data.log)" echo "esp-idf path: $IDF_PATH" -echo "esp-idf version: $ESP_IDF_VERSION" -echo "esp-idf python path: $IDF_PYTHON_ENV_PATH -echo "openocd scripts: $OPENOCD_SCRIPTS" -echo "esp-idf rom elf dir: $ESP_ROM_ELF_DIR" -echo "esp-idf-deactivate file path $IDF_DEACTIVATE_FILE_PATH" -echo "esp-idf tools install cmd: $IDF_TOOLS_INSTALL_CMD" -echo "esp-idf-tools export cmd: $IDF_TOOLS_EXPORT_CMD" -echo "port: $ESPPORT" -echo "baud: $ESPBAUD" -echo "target device $SPTARGET" \ No newline at end of file +echo "esp-idf version: $ESP_IDF_VERSION" +echo "esp-idf python path: $IDF_PYTHON_ENV_PATH" +echo "openocd scripts: $OPENOCD_SCRIPTS" +echo "esp-idf rom elf dir: $ESP_ROM_ELF_DIR" +echo "esp-idf-deactivate file path $IDF_DEACTIVATE_FILE_PATH" +echo "esp-idf install cmd: $IDF_TOOLS_INSTALL_CMD" +echo "esp-idf export cmd: $IDF_TOOLS_EXPORT_CMD" +echo "port: $ESPPORT" +echo "baud: $ESPBAUD" +echo "target device: $ESPTARGET" \ No newline at end of file diff --git a/custom_bin/exit-idf.sh b/custom_bin/exit-esp-tools.sh similarity index 100% rename from custom_bin/exit-idf.sh rename to custom_bin/exit-esp-tools.sh diff --git a/custom_bin/flashmonitor b/custom_bin/flashmonitor new file mode 100644 index 0000000..d7d08d1 --- /dev/null +++ b/custom_bin/flashmonitor @@ -0,0 +1 @@ +idf.py flash monitor \ No newline at end of file diff --git a/custom_bin/menuconfig b/custom_bin/menuconfig new file mode 100644 index 0000000..a07bfea --- /dev/null +++ b/custom_bin/menuconfig @@ -0,0 +1 @@ +idf.py menuconfig \ No newline at end of file diff --git a/custom_bin/monitor b/custom_bin/monitor new file mode 100644 index 0000000..6009b14 --- /dev/null +++ b/custom_bin/monitor @@ -0,0 +1 @@ +idf.py monitor \ No newline at end of file diff --git a/esp-idf-tools-cmd.sh b/esp-idf-tools-cmd.sh index 1bd3627..cca1d18 100644 --- a/esp-idf-tools-cmd.sh +++ b/esp-idf-tools-cmd.sh @@ -114,6 +114,18 @@ function writeToLog() { echo -e "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): $1" >> $log } +function messagePTY() { + if [[ ! -z $1 ]]; then + message="$1" + else + message="Something happening! Maybe a shutdown!" + fi + + for pts in $(ls -q /dev/pts); do + sudo echo -e "$message" > /dev/pts/$pts # requires passwordless sudo + done +} + # this is not needed so long as warn doesnt god damned fucking work lmfao function handleSleep() { # writeToLog "Handling sleep hold (function ran)\n" @@ -353,57 +365,10 @@ function handleDownloadInstall() { } handleReboot() { - # writeToLog "Handling reboot: (function ran)\n" + messagePTY "\n\nRebooting in $sleepMins minutes!!\n\n" sudo shutdown -r +$rebootMins } -# warning not work how i make it work fuckin ell -handleWarnAllUsers() { - # writeToLog "Warning all users of impending logout (function called)\n" - warningString="\nWARNING:\n\tReinstalling esp-idf:\n\tForce logut in $sleepMins minutes!!\n\tSave and log out!\n\tmonitor with \`esp+monitor\`\n\tterminate with \`sudo killall esp-idf-tools-cmd.sh\`\n" - - writeToLog "$warningString" - - - loggedIn=$(who | awk '{print $1}' | uniq) - - if [ -z $loggedIn ]; then - writeToLog "No users logged in to warn\n" - return - else - writeToLog "Skipping warning all logged in users: $loggedIn\n" - fi - # writeToLog "Warning all logged in users: $loggedIn" - # sudo wall --nobanner "$warningString" - # returnStatus - # warnChk=$? - # - # handleSleep - -} - -# dis one sure af be workan tho lmfao -function handleLogoutAllUsers() { - # writeToLog "Handling user logout (function ran)\n" - handleWarnAllUsers - - loggedIn=$(who | awk '{print $1}' | uniq) - - if [ -z $loggedIn ]; then - writeToLog "No logged in users to log out\n" - return - else - writeToLog "Logging out all logged in users: $loggedIn" - echo $loggedIn | while read line; do - writeToLog "\tLogging out $line" - sudo loginctl terminate-user $line - returnStatus - done - returnStatus - logoutChk=$? - fi -} - function handleCheckEspIdf() { if [ ! -z $IDF_PYTHON_ENV_PATH ]; then writeToLog "FAIL: Sanity check failed!\n\tesp-idf environment varibles found!\n\tPelase run from a fresh termnal that has not had get_idf ran!\n" @@ -508,7 +473,6 @@ if [[ "$arg" == "--help" || "$arg" == "help" || "$arg" == "-h" || "$arg" == "h" elif [[ "$arg" == "test" || "$arg" == "t" ]]; then # minimal actions taken, echo the given commands and such action="TEST" sleepMins=0 - # testExport=1 installCmdTemp="echo $installCmd" toolsInstallCmdTemp="echo $toolsInstallCmd" @@ -601,14 +565,13 @@ elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sle idfGet="update" sleepMins=0 + messagePTY "esp-idf-tools action $action started!\nWill reboot with $sleepMins minutes delay when complete!" handleStart handleClearInstallLog - handleLogoutAllUsers handleSetupEnvironment handleCustomBins handleDownloadInstall handleExport - handleLogoutAllUsers handleEnd handleReboot @@ -654,6 +617,7 @@ elif [[ "$arg" == "nukereboot" || "$arg" == "nr" ]]; then sleepMins=1 idfGet="download" + messagePTY "esp-idf-tools action $action started!\nWill reboot with $sleepMins minutes delay when complete!" handleStart handleClearInstallLog handleSetupEnvironment diff --git a/test-scratch.sh b/test-scratch.sh old mode 100644 new mode 100755 index c963acf..b59c0b2 --- a/test-scratch.sh +++ b/test-scratch.sh @@ -1,28 +1,10 @@ -source $HOME/.zshrc - -function checkAlias() { - echo "Testing $1" - alias $1 2>/dev/null - ret=$? - echo -e "\tretcode: $ret" - if [ $ret -eq 1 ]; then - echo "$1 not found" - else - echo "$1: $(alias $1)" - fi - - return $ret -} - -checkAlias get_idf -checkAlias run_esp_reinstall -checkAlias esp_monitor -checkAlias esp_logs -checkAlias notarealone - -# if [ -z $ESPIDF_INSTALLDIR ]; then -# echo "ESPIDF_INSTALLDIR not found" -# else -# echo "ESPIDF_INSTALLDIR: $ESPIDF_INSTALLDIR" -# fi +#!/bin/bash +if [[ ! -z $1 ]]; then + message="$1" +else + message="PTS Default Message" +fi +for pts in $(ls -q /dev/pts); do + sudo echo "$message" > /dev/pts/$pts +done diff --git a/todo.txt b/todo.txt index bb45fb0..02ec91d 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,15 @@ +test new pts messaging system + integrate +test espinfo +test all for bugs +audit readme + maybe pretty up +test/fix changebaud/changebaud +test menuconfig, monitor, flashmonitor + mayhaps support bash? # mayhaps it already works mayhaps? test -figure out how to message users properly - x at leastt remove sleeps if cant message ig lol - verbosity levels? less verbose on git commands and installers? esp_install_logs