This commit is contained in:
2024-11-12 07:32:55 -07:00
parent cf789e96f4
commit 5f4a933ec6
3 changed files with 47 additions and 211 deletions
+6 -5
View File
@@ -21,12 +21,12 @@ echo "\nEnter TTY Number You'd Like:"
read tty
ttyselect=$devarr[(($tty+1))]
echo "Set esp target (esp32, esp32s3, esp32c6, esp8266, etc)"
echo "Set esp target:\n\tOne of: esp32, esp32s2, esp32c3, esp32s3, esp32c2, esp32c6, esp32h2, esp32p4, linux, esp32c5, or esp32c61"
read esp
echo "Setting environment variables"
echo "Adding Custom bins to PATH"
export PATH="${HOME}/esp/.custom_bin:${PATH}"
export PATH="${ESPIDF_INSTALLDIR}/.custom_bin:${PATH}"
echo "ESPPORT = ${ESPPORT}"
export ESPPORT="${ttyselect}"
export ESPBAUD=460800
@@ -35,7 +35,8 @@ echo "ESPBAUD = ${ESPBAUD}"
export ESPTARGET=$esp
echo "ESPTARGET = ${ESPTARGET}"
binDir="${HOME}/esp/.custom_bin"
binDir="${ESPIDF_INSTALLDIR}/.custom_bin"
echo "Setting alias"
alias changeport="source ${binDir}/changeport.sh"
alias changebaud="source ${binDir}/changebaud.sh"
@@ -44,8 +45,8 @@ alias monitor="idf.py monitor"
alias flashmonitor="idf.py flash monitor"
alias menuconfig="idf.py menuconfig"
echo "Changing dir to ${HOME}/esp"
cd "${HOME}/esp"
echo "Changing dir to ${ESPIDF_INSTALLDIR}"
cd "${ESPIDF_INSTALLDIR}"
echo "\nAll done :3\n"
+40 -205
View File
@@ -2,6 +2,9 @@
# set -e # for testan, die on error
startTime=$(date '+%s')
# testing:
# redo these notes:
# testing:
# bash $HOME/esp/esp-install-custom/cron-reinstall-esp-idf.sh test
@@ -26,6 +29,7 @@ espressifLocation=$HOME/.espressif
customBinLocation=$installDir/.custom_bin
runningDir="$( cd "$( dirname "$0" )" && pwd )"
customBinFrom=$runningDir/custom_bin
rcFile=${HOME}/.zshrc
# cronVers=55-dev.3 # version of this script
scriptVers=$(cat $runningDir/version.txt) # make sure version.txt does NOT have newline
@@ -59,6 +63,8 @@ function handleCustomBins() {
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): deleting ${customBinLocation}"
rm -rf $customBinLocation
returnStatus
else
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): ${customBinLocation} not found, skipping delete"
fi
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): copying scripts from ${customBinFrom} to ${customBinLocation}"
@@ -108,6 +114,24 @@ function handleSetupEnvironment() {
fi
}
function handleAliasEnviron() {
if ! [ -z $(alias | grep get_idf) ]; then
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): get_idf alias not found, appending to ${$rcFile}"
echo -e "\nalias get_idf='. ${idfDir}/export.sh'" >> $rcFile
returnStatus
else
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): get_idf alias already installed, skipping"
fi
if [ -z $ESPIDF_INSTALLDIR ]; then
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): ESPIDF_INSTALLDIR environment variable not found, appending to ${rcFile}"
echo -e "export ESPIDF_INSTALLDIR=\"${installDir}\"\n"
returnStatus
else
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): ESPIDF_INSTALLDIR environment variable already installed, skipping"
fi
}
function handleDownloadInstall() {
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): Handling download and install (function ran)"
@@ -123,7 +147,6 @@ function handleDownloadInstall() {
eval "$toolsInstallCmd"
returnStatus
# check up on if dis be workan
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): getting the commit hash"
commitHash=$(git -C $idfDir rev-parse HEAD)
returnStatus
@@ -139,7 +162,7 @@ handleReboot() {
rebootMsg="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): rebooting in $sleepMins minutes. save and log out"
writeToLog "$rebootMsg"
# warn_all_users "$rebootMsg"
echo "$rebootMsg" | sudo write "$myUser"
returnStatus
}
@@ -173,10 +196,12 @@ function handleStart() {
sleepMins="disabled"
fi
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')\nvars:\n\tmyUser: $myUser\n\tscriptVers: $scriptVers\n\tversionData: $versionData\n\tlog: $log\n\tsleepMins: $sleepMins\n\tinstallDir: $installDir\n\tgitJobs: $gitJobs\n\tgitBranch: $gitBranch\n\tgitCmd: $gitCmd\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom\n\tinstallCmd: $installCmd\n\ttoolsInstallCmd: $toolsInstallCmd"
writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new ${action} ==="
writeToLog "\n === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new ${action} ==="
writeToLog "Version: ${scriptVers}"
returnStatus
writeToLog "\n$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')\nvars:\n\tmyUser: $myUser\n\tscriptVers: $scriptVers\n\tversionData: $versionData\n\tlog: $log\n\tsleepMins: $sleepMins\n\tinstallDir: $installDir\n\tgitJobs: $gitJobs\n\tgitBranch: $gitBranch\n\tgitCmd: $gitCmd\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom\n\tinstallCmd: $installCmd\n\ttoolsInstallCmd: $toolsInstallCmd\n\trcFile: $rcFile"
}
function handleEmptyLogs() {
@@ -193,6 +218,8 @@ function handleEnd() {
endTime=$(date '+%s')
timeElapsed=$(($endTime-$startTime))
echo -e "\nesp-idf re/installed! run \`source $rcFile\` and then \`get_idf\`\n to go\n\nAll done :3\n\n"
writeToLog "reinstall completed in $timeElapsed seconds"
writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): finished ===\n\n"
}
@@ -206,13 +233,14 @@ function handleEnd() {
# handleCustomBins
# handleDownloadInstall
# handleExport
# handleAliasEnviron
# handleLogoutAllUsers
# handleEnd
# handleReboot
# exit
if [ "$arg" == "test" ]; then
if [ "$arg" == "test" ]; then # minimal actions taken, echo the given commands and such
action="TEST"
gitCmd="echo git clone --jobs $gitJobs --branch $gitBranch --single-branch https://github.com/espressif/esp-idf $idfDir"
@@ -224,15 +252,15 @@ if [ "$arg" == "test" ]; then
sleepMins=0
handleStart
# handleLogoutAllUsers
handleCustomBins
handleDownloadInstall
handleExport
# handleEmptyLogs
handleAliasEnviron
handleEmptyLogs
handleEnd
exit
elif [ "$arg" == "nologout" ]; then
elif [ "$arg" == "nologout" ]; then # full reinstall without logout, reboot, or sleeps
action="REINSTALL (NOLOGOUT)"
gitCmd="git clone --jobs $gitJobs --branch $gitBranch --single-branch https://github.com/espressif/esp-idf $idfDir"
@@ -246,10 +274,11 @@ elif [ "$arg" == "nologout" ]; then
handleCustomBins
handleDownloadInstall
handleExport
handleAliasEnviron
handleEnd
exit
elif [ "$arg" == "retool" ]; then
elif [ "$arg" == "retool" ]; then # just reinstall bins and export
action="RETOOL"
handleStart
@@ -277,198 +306,4 @@ else # full install with warn, sleep, and reboot
handleEnd
handleReboot
exit
fi
# startTime=$(date '+%s')
# if [ "$arg" == "test" ]; then
# # rm -f $log
# # touch $log
# #
# # rm -f $versionData
# # touch $versionData
# else
# handleReboot
# fi
# }
# function warn_all_users() {
# who | sudo awk '$1 !~ /root/{ cmd="echo '$1' | /usr/bin/write " $1; system(cmd)}'
#}
# # writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): NOLOGOUT mode"
# action="REINSTALL (NOLOGOUT)"
#
# sleepMins=0 # minutes of warning to wait for user to log out
#
# gitCmd="git clone --recursive --jobs $gitJobs --branch $gitBranch https://github.com/espressif/esp-idf $idfDir"
# installCmd="$idfDir/install.sh all"
# toolsInstallCmd="python $idfDir/tools/idf_tools.py install all"
#
# function logout_all_users() {
# return 0;
# }
# elif [ "$arg" == "retool" ]; then
# action="RETOOL"
#
# writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new ${action} ==="
# writeToLog "Version: ${scriptVers}"
#
# writeToLog "deleting old export.sh"
# rm $idfDir/export.sh
# returnStatus
#
# writeToLog "Replacing original export.sh from export.sh.bak"
# cp $idfDir/export.sh.bak $idfDir/export.sh
# returnStatus
#
# writeToLog "Editing ${idfDir}/export.sh"
# sed -i 's/return 0/# return 0/g' $idfDir/export.sh
# returnStatus
#
# writeToLog "Appending new add-to-export-sh.txt to export.sh"
# cat $runningDir/add-to-export-sh.txt >> $idfDir/export.sh
# returnStatus
#
# handleCustomBins
#
# # writeToLog "Deleting .custom_bin dir"
# # rm -rf $customBinLocation
# # returnStatus
# #
# # writeToLog "Coppying new custom_bin and making them executable"
# # cp -r $customBinFrom $customBinLocation
# # chmod +x $customBinLocation/*
# # returnStatus
#
# exit
# else
# # writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): LIVE mode"
#
# sleepMins=3 # minutes of warning to wait for user to log out
#
# gitCmd="git clone --recursive --jobs $gitJobs --branch $gitBranch https://github.com/espressif/esp-idf $idfDir"
# installCmd="$idfDir/install.sh all"
# toolsInstallCmd="python $idfDir/tools/idf_tools.py install all"
#
# function logout_all_users() {
# who | sudo awk '$1 !~ /root/{ cmd="/usr/bin/loginctl terminate-user " $1; system(cmd)}'
# return $?
# }
# fi
#
# writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): new ${action} ==="
# writeToLog "Version: ${scriptVers}"
# sleepSecs=$((sleepMins*60)) # calculated seconds of warning to wait for user to log out
# warningString="\nWARNING:\n\tReinstalling esp-idf in ${sleepMins} minutes! You will be force logged out in ${sleepMins} minutes! Save and log out!\n\tmonitor with \`tail -f -n 50 $HOME/esp/install.log\`\n\tterminate with \`sudo killall cron-reinstall-esp-idf.sh\`\n\t$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')"
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): sending warning message to $myUser"
# writeToLog "$warningString"
# echo -e "$warningString" | sudo write "$myUser"
# # warn_all_users "$warningString"
# returnStatus
# sleepHold
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): force logging out all users"
# logout_all_users
# returnStatus
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)')\nvars:\n\tmyUser: $myUser\n\tscriptVers: $scriptVers\n\tversionData: $versionData\n\tlog: $log\n\tsleepMins: $sleepMins\n\tsleepSecs: $sleepSecs\n\tinstallDir: $installDir\n\tgitJobs: $gitJobs\n\tgitBranch: $gitBranch\n\tgitCmd: $gitCmd\n\trunningDir: $runningDir\n\tidfDir: $idfDir\n\tespressifLocation: $espressifLocation\n\tcustomBinLocation: $customBinLocation\n\tcustomBinFrom: $customBinFrom\n\tinstallCmd: $installCmd\n\ttoolsInstallCmd: $toolsInstallCmd"
# returnStatus
# if ! [ -d $installDir ]; then
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): creating ${installDir}"
# mkdir $installDir
# returnStatus
# fi
#
# if [ -d $idfDir ]; then
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): deleting ${idfDir}"
# rm -rf $idfDir
# returnStatus
# fi
#
# if [ -d $espressifLocation ]; then
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): deleting ${espressifLocation}"
# rm -rf "${espressifLocation}"
# returnStatus
# fi
# if [ -d $customBinLocation ]; then
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): deleting ${customBinLocation}"
# rm -rf $customBinLocation
# returnStatus
# fi
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): copying scripts from ${customBinFrom} to ${customBinLocation}"
# cp -r $customBinFrom $customBinLocation
# returnStatus
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): making scripts executable at ${customBinLocation}"
# chmod -R +x $customBinLocation
# returnStatus
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): cloning git branch ${gitBranch} with ${gitJobs} jobs to ${idfDir}"
# eval "$gitCmd"
# returnStatus
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): installing with ${idfDir}/install.sh all"
# eval "$installCmd"
# returnStatus
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): installing tools with python ${idfDir}/tools/idf_tools.py install all"
# eval "$toolsInstallCmd"
# returnStatus
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): backing up ${idfDir}/export.sh to ${idfDir}/export.sh.bak"
# cp $idfDir/export.sh $idfDir/export.sh.bak
# returnStatus
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): editing ${idfDir}/export.sh"
# sed -i 's/return 0/# return 0/g' $idfDir/export.sh
# returnStatus
#
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): adding ${runningDir}/add-to-export-sh.txt to ${idfDir}/export.sh"
# cat $runningDir/add-to-export-sh.txt >> $idfDir/export.sh
# returnStatus
# writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): getting the commit hash"
# commitHash=$(git -C $idfDir rev-parse HEAD)
# returnStatus
# gitDataLog="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): installed esp-idf from commit $commitHash from branch $gitBranch using $scriptVers"
# writeToLog "$gitDataLog"
# echo -e "$gitDataLog" >> $versionData
# returnStatus
# rebootMsg="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): rebooting in $sleepMins minutes. save and log out"
# writeToLog "$rebootMsg"
# # warn_all_users "$rebootMsg"
# echo "$rebootMsg" | sudo write "$myUser"
# returnStatus
# sleepHold
#writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): force logging out all users"
# logout_all_users
# returnStatus
# endTime=$(date '+%s')
# timeElapsed=$(($endTime-$startTime))
# writeToLog "reinstall completed in $timeElapsed seconds"
# writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): finished ===\n\n"
# if [ "$arg" == "test" ]; then
# echo sudo reboot
#
# rm -f $log
# touch $log
#
# rm -f $versionData
# touch $versionData
# else
# sudo reboot
# fi
fi
+1 -1
View File
@@ -1 +1 @@
60-dev.3
60-dev.5