From 39adadfb53b4cbef068de9fb55269eb89db4a290 Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Sat, 9 Nov 2024 03:30:57 -0700 Subject: [PATCH] aaaaaaaaaaaa --- cron-reinstall-esp-idf.sh | 56 ++++++++------- cron-reinstall-esp-idf.sh.bak | 118 ++++++++++++++++++++++++++++++ next-cron-reinstall-esp-idf.sh | 126 --------------------------------- 3 files changed, 150 insertions(+), 150 deletions(-) create mode 100644 cron-reinstall-esp-idf.sh.bak delete mode 100644 next-cron-reinstall-esp-idf.sh diff --git a/cron-reinstall-esp-idf.sh b/cron-reinstall-esp-idf.sh index fa0e7a1..dcda9aa 100644 --- a/cron-reinstall-esp-idf.sh +++ b/cron-reinstall-esp-idf.sh @@ -1,5 +1,5 @@ #!/bin/bash -cronVers=21 # version of this script +cronVers=23 # version of this script sleepSecs=3 # seconds of warning to wait for user to log out log=$HOME/esp/install.log @@ -10,7 +10,9 @@ myUser=$USER # bash ~/esp/esp-install-custom/cron-reinstall-esp-idf.sh >> ~/esp/install.log function return_status() { - echo -e "\treturn status: ${?}" + strii="\treturn status: ${?}" + echo -e $strii + echo -e $strii >> $log } function write_to_log() { @@ -18,13 +20,18 @@ function write_to_log() { echo -e "$1" >> $log } -echo " === $(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): new reinstall ===" -echo "Cron version: ${cronVers}" -echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" -echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nReinstalling esp-idf in ${sleepSecs} seconds! Save and log out!\n\tmonitor with \`tail -f $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`" | sudo write $myUser +write_to_log " === $(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): new reinstall ===" +write_to_log "Cron version: ${cronVers}" + +warningString="$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nReinstalling esp-idf in ${sleepSecs} seconds! Save and log out!\n\tmonitor with \`tail -f $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`" + +write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" +write_to_log "$warningString" +echo -e "$warningString" | sudo write $myUser return_status -echo "sleeping ${sleepSecs} seconds" +write_to_log "sleeping ${sleepSecs} seconds" sleep $sleepSecs return_status @@ -37,71 +44,72 @@ espressifLocation=$HOME/.espressif customBinLocation=$installDir/.custom_bin customBinFrom=$runningDir/custom_bin -echo -e "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nvars:\n\tsleepSecs: $sleepSecs\n\tinstallDir: $installDir\n\tgitBranch: $gitBranch\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom" +write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nvars:\n\tsleepSecs: $sleepSecs\n\tinstallDir: $installDir\n\tgitBranch: $gitBranch\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom" return_status if ! [ -d $installDir ]; then - echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): creating ${installDir}" + write_to_log "$(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}" + write_to_log "$(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}" + write_to_log "$(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}" + write_to_log "$(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}" +write_to_log "$(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}" +write_to_log "$(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}" +write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): cloning git branch ${gitBranch} with ${gitJobs} jobs to ${idfDir}" git clone --recursive --jobs $gitJobs --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" +write_to_log "$(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" +write_to_log "$(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" +write_to_log "$(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" +write_to_log "$(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" +write_to_log "$(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" +write_to_log "$(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}" -echo -e "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)') installed at commit ${commitHash} from branch ${gitBranch}" >> $idfDir/version-data.txt +gitDataLog="Installed at:\n\t$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\n\tat commit ${commitHash}\n\tfrom branch ${gitBranch}" +write_to_log $gitDataLog +echo -e $gitDataLog >> $idfDir/version-data.txt return_status echo "rebooting in ${sleepSecs} seconds. seave and log out" | sudo write princesspi @@ -109,7 +117,7 @@ echo "sleeping ${sleepSecs} seconds" sleep $sleepSecs return_status -echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending final message and rebooting"; +write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending final message and rebooting"; echo "rebooting NOW bye bye" | sudo write $myUser return_status diff --git a/cron-reinstall-esp-idf.sh.bak b/cron-reinstall-esp-idf.sh.bak new file mode 100644 index 0000000..fa0e7a1 --- /dev/null +++ b/cron-reinstall-esp-idf.sh.bak @@ -0,0 +1,118 @@ +#!/bin/bash +cronVers=21 # version of this script +sleepSecs=3 # seconds of warning to wait for user to log out +log=$HOME/esp/install.log + +myUser=$USER + +# testing: +# rm ~/esp/install.log && \ +# bash ~/esp/esp-install-custom/cron-reinstall-esp-idf.sh >> ~/esp/install.log + +function return_status() { + echo -e "\treturn status: ${?}" +} + +function write_to_log() { + echo -e "$1" + echo -e "$1" >> $log +} + +echo " === $(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): new reinstall ===" +echo "Cron version: ${cronVers}" +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" +echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nReinstalling esp-idf in ${sleepSecs} seconds! Save and log out!\n\tmonitor with \`tail -f $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`" | sudo write $myUser +return_status + +echo "sleeping ${sleepSecs} seconds" +sleep $sleepSecs +return_status + +gitJobs=4 +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 -e "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nvars:\n\tsleepSecs: $sleepSecs\n\tinstallDir: $installDir\n\tgitBranch: $gitBranch\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $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 --jobs $gitJobs --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}" +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 $myUser +return_status + +echo -e " === finished ===\n" + +echo sudo reboot diff --git a/next-cron-reinstall-esp-idf.sh b/next-cron-reinstall-esp-idf.sh deleted file mode 100644 index 5878e9e..0000000 --- a/next-cron-reinstall-esp-idf.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -cronVers=22 # version of this script -sleepSecs=3 # seconds of warning to wait for user to log out -log=$HOME/esp/install.log - -myUser=$USER - -# testing: -# rm ~/esp/install.log && \ -# bash ~/esp/esp-install-custom/cron-reinstall-esp-idf.sh >> ~/esp/install.log - -function return_status() { - strii="\treturn status: ${?}" - echo -e $strii - echo -e $strii >> $log -} - -function write_to_log() { - echo -e "$1" - echo -e "$1" >> $log -} - -write_to_log " === $(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): new reinstall ===" -write_to_log "Cron version: ${cronVers}" - -warningString="$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" -echo "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nReinstalling esp-idf in ${sleepSecs} seconds! Save and log out!\n\tmonitor with \`tail -f $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`" - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending warning message" -write_to_log "$warningString" -echo -e "$warningString" | sudo write $myUser -return_status - -write_to_log "sleeping ${sleepSecs} seconds" -sleep $sleepSecs -return_status - -gitJobs=4 -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 - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\nvars:\n\tsleepSecs: $sleepSecs\n\tinstallDir: $installDir\n\tgitBranch: $gitBranch\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom" -return_status - -if ! [ -d $installDir ]; then - write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): creating ${installDir}" - mkdir $installDir - return_status -fi - -if [ -d $idfDir ]; then - write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${idfDir}" - rm -rf $idfDir - return_status -fi - -if [ -d $espressifLocation ]; then - write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${espressifLocation}" - rm -rf "${espressifLocation}" - return_status -fi - -if [ -d $customBinLocation ]; then - write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): deleting ${customBinLocation}" - rm -rf $customBinLocation - return_status -fi - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): copying scripts from ${customBinFrom} to ${customBinLocation}" -cp -r $customBinFrom $customBinLocation -return_status - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): making scripts executable at ${customBinLocation}" -chmod -R +x $customBinLocation -return_status - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): cloning git branch ${gitBranch} with ${gitJobs} jobs to ${idfDir}" -git clone --recursive --jobs $gitJobs --branch $gitBranch https://github.com/espressif/esp-idf $idfDir -return_status - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): installing with ${idfDir}/install.sh all" -eval "${idfDir}/install.sh all" -return_status - -write_to_log "$(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 - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): backing up export.sh" -cp $idfDir/export.sh $idfDir/export.sh.bak -return_status - -write_to_log "$(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 - -write_to_log "$(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 - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): getting the commit hash" -commitHash=$(git -C $idfDir rev-parse HEAD) -return_status - -gitDataLog="Installed at:\n\t$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)')\n\tat commit ${commitHash}\n\tfrom branch ${gitBranch}" -write_to_log $gitDataLog -echo -e $gitDataLog >> $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 - -write_to_log "$(date '+%d/%m/%Y-%H.%M.%S %Z (%s)'): sending final message and rebooting"; -echo "rebooting NOW bye bye" | sudo write $myUser -return_status - -echo -e " === finished ===\n" - -echo sudo reboot