From b29a31467ec7de2320f70c2ad7c7c6b5c32998cb Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Sat, 9 Nov 2024 02:49:42 -0700 Subject: [PATCH] workans on da cron th8ngggg --- cron-reinstall-esp-idf.sh | 104 ++++++++++++++++++++++++++++++++++++++ custom_bin/build | 0 custom_bin/changebaud | 31 ++++++++++++ custom_bin/changeesp | 8 +++ custom_bin/changeesp.sh | 0 custom_bin/changeport | 16 ++++++ custom_bin/changeport.sh | 0 custom_bin/clean | 0 custom_bin/flashmonitor | 0 custom_bin/fullclean | 0 custom_bin/menuconfig | 0 custom_bin/rebuildfull | 0 custom_bin/setup | 0 reinstall-esp-idf.sh | 21 +++++--- test-scratch.sh | 0 15 files changed, 172 insertions(+), 8 deletions(-) create mode 100644 cron-reinstall-esp-idf.sh mode change 100755 => 100644 custom_bin/build create mode 100644 custom_bin/changebaud create mode 100644 custom_bin/changeesp mode change 100755 => 100644 custom_bin/changeesp.sh create mode 100644 custom_bin/changeport mode change 100755 => 100644 custom_bin/changeport.sh mode change 100755 => 100644 custom_bin/clean mode change 100755 => 100644 custom_bin/flashmonitor mode change 100755 => 100644 custom_bin/fullclean mode change 100755 => 100644 custom_bin/menuconfig mode change 100755 => 100644 custom_bin/rebuildfull mode change 100755 => 100644 custom_bin/setup mode change 100755 => 100644 test-scratch.sh diff --git a/cron-reinstall-esp-idf.sh b/cron-reinstall-esp-idf.sh new file mode 100644 index 0000000..8237e6a --- /dev/null +++ b/cron-reinstall-esp-idf.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# lol 15 + +function return_status() { + echo -e "\treturn status: ${?}" +} + +echo " === $(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): new reinstall) ===" +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" +echo 'reinstalling esp-idf in three minutes. save and log out.\n\tmonitor with `tail -f /home/princesspi/esp/install.log`\n\tterminate with `sudo killall cron-reinstall-esp-idf.sh`' | sudo write princesspi +return_status + +sleepSecs=3 +echo "sleeping ${sleepSecs} seconds" +sleep $sleepSecs +return_status + +installDir="${HOME}/esp" +gitBranch=master +runningDir="$( cd "$( dirname "$0" )" && pwd )" +idfDir=$installDir/esp-idf +espressifLocation=$HOME/.espressif +customBinLocation=$installDir/.custom_bin +customBinFrom=$runningDir/custom_bin + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): vars: sleepSecs: $sleepSecs, installDir: $installDir, gitBranch: $gitBranch, runningDir: $runningDir, idfDir: $idfDir, espressifLocation: $espressifLocation, customBinLocation: $customBinLocation, customBinFrom: $customBinFrom" +return_status + +if ! [ -d $installDir ]; then + echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): creating ${installDir}" + mkdir $installDir + return_status +fi + +if [ -d $idfDir ]; then + echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${idfDir}" + rm -rf $idfDir + return_status +fi + +if [ -d $espressifLocation ]; then + echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${espressifLocation}" + rm -rf "${espressifLocation}" + return_status +fi + +if [ -d $customBinLocation ]; then + echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${customBinLocation}" + rm -rf $customBinLocation + return_status +fi + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): copying scripts from ${customBinFrom} to ${customBinLocation}" +cp -r $customBinFrom $customBinLocation +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): making scripts executable at ${customBinLocation}" +chmod -R +x $customBinLocation +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): cloning git branch ${gitBranch} with ${gitJobs} jobs to ${idfDir}" +git clone --recursive --single-branch --branch $gitBranch https://github.com/espressif/esp-idf $idfDir +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): installing with ${idfDir}/install.sh all" +eval "${idfDir}/install.sh all" +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): installign tools with idf_tools.py" +python $idfDir/tools/idf_tools.py install all +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): backing up export.sh" +cp $idfDir/export.sh $idfDir/export.sh.bak +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): editing export.sh" +sed -i 's/return 0/# return 0/g' $idfDir/export.sh +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): adding add-to-export-sh.txt to export.ss" +cat $runningDir/add-to-export-sh.txt >> $idfDir/export.sh +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): getting the commit hash" +commitHash=$(git -C $idfDir rev-parse HEAD) +return_status + +echo -e "Installed at:\n\t$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\n\tat commit ${commitHash}\n\tfrom branch ${gitBranch}\n\tsource: https://github.com/espressif/esp-idf" +echo -e "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)') installed at commit ${commitHash} from branch ${gitBranch}" >> $idfDir/version-data.txt +return_status + +echo "rebooting in ${sleepSecs} seconds. seave and log out" | sudo write princesspi +echo "sleeping ${sleepSecs} seconds" +sleep $sleepSecs +return_status + +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending final message and rebooting"; +echo "rebooting NOW bye bye" | sudo write princesspi +return_status + +echo -e " === finished ===\n" + +echo sudo reboot diff --git a/custom_bin/build b/custom_bin/build old mode 100755 new mode 100644 diff --git a/custom_bin/changebaud b/custom_bin/changebaud new file mode 100644 index 0000000..cbc8eec --- /dev/null +++ b/custom_bin/changebaud @@ -0,0 +1,31 @@ +#!/bin/bash + +echo -e "\nChanging ESPBAUD\n" +read -p "Select New Baudrate:\n\t1: 9600\n\t2: 115200\n\t3: 230400\n\t4: 460800\n\t5: 1152000\n\t6: 1500000\nDefault: ${ESPBAUD}" baud + +baud=${baud:-$ESPBAUD} + +echo "Select New Baudrate:\n\t1: 9600\n\t2: 115200\n\t3: 230400\n\t4: 460800\n\t5: 1152000\n\t6: 1500000" +read baud +if [ "${baud}" == 1 ]; then + selection=9600 +elif [ "${baud}" == 2 ]; then + selection=115200 +elif [ "${baud}" == 3 ]; then + selection=230400 +elif [ "${baud}" == 4 ]; then + selection=460800 +elif [ "${baud}" == 5 ]; then + selection=1152000 +elif [ "${baud}" == 5 ]; then + selection=1152000 +elif [ "${baud}" == 6 ]; then + selection=1500000 +else + echo "\nBad Selection\n" + return +fi + +export ESPBAUD=$selection + +echo "\nAll done :3\n" \ No newline at end of file diff --git a/custom_bin/changeesp b/custom_bin/changeesp new file mode 100644 index 0000000..ae5364d --- /dev/null +++ b/custom_bin/changeesp @@ -0,0 +1,8 @@ +echo "\nChanging ESPTARGET\n" +echo "Set esp target (esp32, esp32s3, esp32c6, esp8266, etc)" +read esp + +export ESPTARGET="${esp}" + +echo "\nESPTARGET set to ${ESPTARGET}\n" +echo "\nall done :3\n" \ No newline at end of file diff --git a/custom_bin/changeesp.sh b/custom_bin/changeesp.sh old mode 100755 new mode 100644 diff --git a/custom_bin/changeport b/custom_bin/changeport new file mode 100644 index 0000000..a53d32a --- /dev/null +++ b/custom_bin/changeport @@ -0,0 +1,16 @@ +echo "\nChanging ESPPORT\n" +echo "TTY devices found in dmesg:" +COUNTER=0 +devarr=() +for line in $(dmesg | tail -50 | grep -o -E "tty[A-Z]{3}[0-9]{0,2}" | sort -u); do + echo "$COUNTER /dev/$line" + devarr+=("/dev/$line") + COUNTER=$((COUNTER+1)) +done + +echo "\nEnter TTY Number You'd Like:" +read tty +ttyselect=$devarr[(($tty+1))] +export ESPPORT="${ttyselect}" +echo "\nESPPORT set to ${ESPPORT}\n" +echo "\nall done :3\n" \ No newline at end of file diff --git a/custom_bin/changeport.sh b/custom_bin/changeport.sh old mode 100755 new mode 100644 diff --git a/custom_bin/clean b/custom_bin/clean old mode 100755 new mode 100644 diff --git a/custom_bin/flashmonitor b/custom_bin/flashmonitor old mode 100755 new mode 100644 diff --git a/custom_bin/fullclean b/custom_bin/fullclean old mode 100755 new mode 100644 diff --git a/custom_bin/menuconfig b/custom_bin/menuconfig old mode 100755 new mode 100644 diff --git a/custom_bin/rebuildfull b/custom_bin/rebuildfull old mode 100755 new mode 100644 diff --git a/custom_bin/setup b/custom_bin/setup old mode 100755 new mode 100644 diff --git a/reinstall-esp-idf.sh b/reinstall-esp-idf.sh index beb77ef..3848b8b 100644 --- a/reinstall-esp-idf.sh +++ b/reinstall-esp-idf.sh @@ -2,11 +2,17 @@ echo -e "\n===== LFGGGGGGGG ======\n" echo -e "\n" -read -p "Enter directory to install/reinstall to (default ${HOME}/esp):" installDir -installDir=${installDir:-$HOME/esp} +# read -p "Enter directory to install/reinstall to (default ${HOME}/esp):" installDir +# installDir=${installDir:-$HOME/esp} -echo -e "\nInstalling prerequisites\n" -sudo apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 +installDir="${HOME}/esp" + +gitBranch=master + +gitJobs=5 + +# echo -e "\nInstalling prerequisites\n" +# sudo apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 runningDir="$( cd "$( dirname "$0" )" && pwd )" idfDir="${installDir}/esp-idf" @@ -51,7 +57,7 @@ cp -r "${customBinFrom}" "${customBinLocation}" chmod -R +x "${customBinLocation}" echo -e "\nPulling latest esp-idf code from github\n" -git clone --recursive --jobs 5 https://github.com/espressif/esp-idf.git $idfDir +git clone --recursive --jobs $gitJobs --single-branch --branch $gitBranch https://github.com/espressif/esp-idf.git $idfDir echo -e "\nRunning install script\n" bash $idfDir/install.sh all @@ -66,8 +72,7 @@ else echo -e "\nget_idf alias already installed, skipping\n" fi -echo -e "\nMaking a backup of ${idfDir}/export.sh to -${idfDir}/export.sh.bak\n" +echo -e "\nMaking a backup of ${idfDir}/export.sh to ${idfDir}/export.sh.bak\n" cp "${idfDir}/export.sh" "${idfDir}/export.sh.bak" @@ -81,7 +86,7 @@ echo -e "\nCreating version/commit and date file at ${idfDir}/version-date.txt\n datestamp=$(date +"%A, %B %-d %Y at %r %Z (epoch %s)") commitHash=$(git -C $idfDir rev-parse HEAD) -gitBranch=$(git -C $idfDir rev-parse --abbrev-ref HEAD) +# gitBranch=$(git -C $idfDir rev-parse --abbrev-ref HEAD) echo -e "Installed at:\n\t${datestamp}\n\tat commit ${commitHash}\n\tfrom branch ${gitBranch}\n\tsource: https://github.com/espressif/esp-idf" > "${idfDir}/version-data.txt" diff --git a/test-scratch.sh b/test-scratch.sh old mode 100755 new mode 100644