60-dev.9
This commit is contained in:
+93
-65
@@ -2,38 +2,71 @@
|
|||||||
# set -e # for testan, die on error
|
# set -e # for testan, die on error
|
||||||
startTime=$(date '+%s')
|
startTime=$(date '+%s')
|
||||||
|
|
||||||
# testing:
|
# modes:
|
||||||
|
# default:
|
||||||
|
# reinstalls non-interactively with no delays, logouts, or reboots
|
||||||
# redo these notes:
|
# bash cron-reinstall-esp-idf.sh
|
||||||
# testing:
|
#
|
||||||
# bash $HOME/esp/esp-install-custom/cron-reinstall-esp-idf.sh test
|
# test:
|
||||||
# tail -f -n 50 $HOME/esp/install.log
|
# tests the script. very fast. minimal actions taken. no reinstall is done
|
||||||
# ls $HOME/esp; echo "install.log"; cat $HOME/esp/install.log; echo "version-data.txt"; cat $HOME/esp/version-data.txt
|
# bash cron-reinstall-esp-idf.sh test
|
||||||
|
#
|
||||||
# delete logs:
|
# retool:
|
||||||
# rm -f $HOME/esp/install.log; rm -f $HOME/esp/version-data.txt
|
# reinstalls bins and export.sh, nothing else
|
||||||
|
# bash cron-reinstall-esp-idf.sh retool
|
||||||
|
#
|
||||||
|
# cron:
|
||||||
|
# runs noninteractively with forced user logout and automatic reboot, plus delays
|
||||||
|
# bash cron-reinstall-esp-idf.sh cron
|
||||||
|
#
|
||||||
|
# interactive:
|
||||||
|
# interactively installs/reinstalls esp-idf
|
||||||
|
# bash cron-reinstall-esp-idf.sh interactive
|
||||||
# cron:
|
# cron:
|
||||||
# crontab -e
|
# crontab -e
|
||||||
# 0 8 * * * bash $HOME/esp/esp-install-custom/cron-reinstall-esp-idf.sh
|
# 0 8 * * * bash $HOME/esp/esp-install-custom/cron-reinstall-esp-idf.sh cron
|
||||||
|
# manually wipe logs:
|
||||||
|
# rm $ESPIDF_INSTALLDIR/install.log; rm $ESPIDF_INSTALLDIR/version-data.txt; touch $ESPIDF_INSTALLDIR/install.log; touch $ESPIDF_INSTALLDIR/version-data.txt;
|
||||||
|
#
|
||||||
|
# monitor log file during install
|
||||||
|
# tail -n 75 $ESPIDF_INSTALLDIR/install.log;
|
||||||
|
|
||||||
myUser=princesspi
|
myUser=princesspi # user installing esp-ids
|
||||||
gitJobs=5
|
gitJobs=5 # number of jobs to download from github with
|
||||||
installDir=/home/$myUser/esp
|
gitBranch=master # branch from github
|
||||||
log=$installDir/install.log
|
rcFile=$HOME/.zshrc # shell rc file
|
||||||
versionData=$installDir/version-data.txt
|
|
||||||
gitBranch=master
|
if [ -z ESPIDF_INSTALLDIR ]; then
|
||||||
idfDir=$installDir/esp-idf
|
installDir=$HOME/esp
|
||||||
espressifLocation=$HOME/.espressif
|
else
|
||||||
customBinLocation=$installDir/.custom_bin
|
installDir=$ESPIDF_INSTALLDIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
# installDir=/home/$myUser/esp # install dir
|
||||||
|
log=$installDir/install.log # log file
|
||||||
|
versionData=$installDir/version-data.txt # version data log file
|
||||||
|
idfDir=$installDir/esp-idf # esp-idf path
|
||||||
|
espressifLocation=$HOME/.espressif # espressif tools install location
|
||||||
|
customBinLocation=$installDir/.custom_bin # where custom bin scripts are placed
|
||||||
runningDir="$( cd "$( dirname "$0" )" && pwd )"
|
runningDir="$( cd "$( dirname "$0" )" && pwd )"
|
||||||
customBinFrom=$runningDir/custom_bin
|
customBinFrom=$runningDir/custom_bin # dir where custom scripts are coming FROM
|
||||||
rcFile=${HOME}/.zshrc
|
|
||||||
# cronVers=55-dev.3 # version of this script
|
|
||||||
scriptVers=$(cat $runningDir/version.txt) # make sure version.txt does NOT have newline
|
scriptVers=$(cat $runningDir/version.txt) # make sure version.txt does NOT have newline
|
||||||
|
arg=$1 # just rename the argument var for clarity with the functions
|
||||||
|
|
||||||
arg=$1
|
# full order:
|
||||||
|
# handleStart
|
||||||
|
# handleLogoutAllUsers
|
||||||
|
# sleepHold
|
||||||
|
# handleLogoutAllUsers
|
||||||
|
# handleSetupEnvironment
|
||||||
|
# handleCustomBins
|
||||||
|
# handleDownloadInstall
|
||||||
|
# handleExport
|
||||||
|
# handleAliasEnviron
|
||||||
|
# handleLogoutAllUsers
|
||||||
|
# handleEnd
|
||||||
|
# handleReboot
|
||||||
|
# exit
|
||||||
|
|
||||||
function returnStatus() {
|
function returnStatus() {
|
||||||
strii="\treturn status: ${?}"
|
strii="\treturn status: ${?}"
|
||||||
@@ -80,7 +113,7 @@ function handleExport() {
|
|||||||
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): Handling export.sh (function ran)"
|
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): Handling export.sh (function ran)"
|
||||||
|
|
||||||
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): backing up ${idfDir}/export.sh to ${idfDir}/export.sh.bak"
|
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
|
cp $idfDir/export.sh $idfDir/export.sh.bakno
|
||||||
returnStatus
|
returnStatus
|
||||||
|
|
||||||
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): editing ${idfDir}/export.sh"
|
writeToLog "$(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): editing ${idfDir}/export.sh"
|
||||||
@@ -196,11 +229,17 @@ function handleStart() {
|
|||||||
sleepMins="disabled"
|
sleepMins="disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z $ESPIDF_INSTALLDIR ];
|
||||||
|
installdirEnvvar="not set"
|
||||||
|
else
|
||||||
|
installdirEnvvar=$ESPIDF_INSTALLDIR
|
||||||
|
fi
|
||||||
|
|
||||||
writeToLog "\n === $(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}"
|
writeToLog "Version: ${scriptVers}"
|
||||||
|
|
||||||
returnStatus
|
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"
|
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\n\t(envvar) ESPIDF_INSTALLDIR: $installdirEnvvar"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,22 +263,6 @@ function handleEnd() {
|
|||||||
writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): finished ===\n\n"
|
writeToLog " === $(date '+%d/%m/%Y %H:%M:%S %Z (%s)'): finished ===\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# full order:
|
|
||||||
# handleStart
|
|
||||||
# handleWarn
|
|
||||||
# sleepHold
|
|
||||||
# handleLogoutAllUsers
|
|
||||||
# handleSetupEnvironment
|
|
||||||
# handleCustomBins
|
|
||||||
# handleDownloadInstall
|
|
||||||
# handleExport
|
|
||||||
# handleAliasEnviron
|
|
||||||
# handleLogoutAllUsers
|
|
||||||
# handleEnd
|
|
||||||
# handleReboot
|
|
||||||
# exit
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$arg" == "test" ]; then # minimal actions taken, echo the given commands and such
|
if [ "$arg" == "test" ]; then # minimal actions taken, echo the given commands and such
|
||||||
action="TEST"
|
action="TEST"
|
||||||
|
|
||||||
@@ -256,26 +279,9 @@ if [ "$arg" == "test" ]; then # minimal actions taken, echo the given commands a
|
|||||||
handleDownloadInstall
|
handleDownloadInstall
|
||||||
handleExport
|
handleExport
|
||||||
handleAliasEnviron
|
handleAliasEnviron
|
||||||
handleEmptyLogs
|
# handleEmptyLogs
|
||||||
handleEnd
|
handleEnd
|
||||||
exit
|
|
||||||
|
|
||||||
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"
|
|
||||||
|
|
||||||
installCmd="$idfDir/install.sh all"
|
|
||||||
|
|
||||||
toolsInstallCmd="python $idfDir/tools/idf_tools.py install all"
|
|
||||||
|
|
||||||
handleStart
|
|
||||||
handleSetupEnvironment
|
|
||||||
handleCustomBins
|
|
||||||
handleDownloadInstall
|
|
||||||
handleExport
|
|
||||||
handleAliasEnviron
|
|
||||||
handleEnd
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
elif [ "$arg" == "retool" ]; then # just reinstall bins and export
|
elif [ "$arg" == "retool" ]; then # just reinstall bins and export
|
||||||
@@ -285,6 +291,7 @@ elif [ "$arg" == "retool" ]; then # just reinstall bins and export
|
|||||||
handleCustomBins
|
handleCustomBins
|
||||||
handleExport
|
handleExport
|
||||||
handleEnd
|
handleEnd
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
elif [ "$arg" == "interactive" ]; then
|
elif [ "$arg" == "interactive" ]; then
|
||||||
@@ -292,8 +299,8 @@ elif [ "$arg" == "interactive" ]; then
|
|||||||
# something here lmfao
|
# something here lmfao
|
||||||
exit
|
exit
|
||||||
|
|
||||||
else # full install with warn, sleep, and reboot
|
elif [ "$arg" == "cron" ] # full install with warn, sleep, and reboot
|
||||||
action="REINSTALL (DEFAULT)"
|
action="REINSTALL (CRON)"
|
||||||
|
|
||||||
gitCmd="git clone --jobs $gitJobs --branch $gitBranch --single-branch https://github.com/espressif/esp-idf $idfDir"
|
gitCmd="git clone --jobs $gitJobs --branch $gitBranch --single-branch https://github.com/espressif/esp-idf $idfDir"
|
||||||
|
|
||||||
@@ -310,5 +317,26 @@ else # full install with warn, sleep, and reboot
|
|||||||
handleLogoutAllUsers
|
handleLogoutAllUsers
|
||||||
handleEnd
|
handleEnd
|
||||||
handleReboot
|
handleReboot
|
||||||
|
|
||||||
exit
|
exit
|
||||||
fi
|
|
||||||
|
else # full noninteractive (re)install without logout, reboot, or sleeps
|
||||||
|
action="REINSTALL (DEFAULT)"
|
||||||
|
|
||||||
|
gitCmd="git clone --jobs $gitJobs --branch $gitBranch --single-branch https://github.com/espressif/esp-idf $idfDir"
|
||||||
|
|
||||||
|
installCmd="$idfDir/install.sh all"
|
||||||
|
|
||||||
|
toolsInstallCmd="python $idfDir/tools/idf_tools.py install all"
|
||||||
|
|
||||||
|
handleStart
|
||||||
|
handleSetupEnvironment
|
||||||
|
handleCustomBins
|
||||||
|
handleDownloadInstall
|
||||||
|
handleExport
|
||||||
|
handleAliasEnviron
|
||||||
|
handleEnd
|
||||||
|
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
60-dev.8
|
60-dev.9
|
||||||
Reference in New Issue
Block a user