testiung for release 4
This commit is contained in:
+47
-52
@@ -21,6 +21,13 @@ startTime=$(date '+%s') # to time the (re)install time for the logs
|
|||||||
|
|
||||||
# always run globals and boilerplate
|
# always run globals and boilerplate
|
||||||
|
|
||||||
|
# check for help first
|
||||||
|
if [[ "$1" == "--help" || "$1" == "help" || "$1" == "-h" || "$1" == "h" ]]; then
|
||||||
|
helpText=$ESPIDFTOOLS_INSTALLDIR/.custom_bin/help.txt
|
||||||
|
cat "$helpText"
|
||||||
|
|
||||||
|
exit
|
||||||
|
|
||||||
defShell=$(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd)
|
defShell=$(awk -F: -v user="$USER" '$1 == user {print $NF}' /etc/passwd)
|
||||||
|
|
||||||
if [[ "$defShell" =~ zsh$ ]]; then
|
if [[ "$defShell" =~ zsh$ ]]; then
|
||||||
@@ -42,13 +49,13 @@ defaultInstallDir="$HOME/esp"
|
|||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
gitBranch=master # branch from github
|
gitBranch=master # branch from github
|
||||||
else
|
else
|
||||||
gitBranch=$2
|
gitBranch="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$ESPIDFTOOLS_INSTALLDIR" ]; then
|
if [ -z "$ESPIDFTOOLS_INSTALLDIR" ]; then
|
||||||
# cant seem to get this one to use writeToLog
|
# cant seem to get this one to use writeToLog
|
||||||
echo "ESPIDFTOOLS_INSTALLDIR environment variable not found, appending to $rcFile"
|
echo "ESPIDFTOOLS_INSTALLDIR environment variable not found, appending to $rcFile"
|
||||||
echo "export ESPIDFTOOLS_INSTALLDIR=\"$defaultInstallDir\"" >> $rcFile
|
echo "export ESPIDFTOOLS_INSTALLDIR=\"$defaultInstallDir\"" >> "$rcFile"
|
||||||
installDir="$defaultInstallDir"
|
installDir="$defaultInstallDir"
|
||||||
aliasInstallDirChk=$?
|
aliasInstallDirChk=$?
|
||||||
else
|
else
|
||||||
@@ -59,17 +66,16 @@ fi
|
|||||||
|
|
||||||
gitJobs=5 # number of jobs to download from github with
|
gitJobs=5 # number of jobs to download from github with
|
||||||
rebootMins=3 # minutes of warning before reboot
|
rebootMins=3 # minutes of warning before reboot
|
||||||
log=$installDir/install.log # log file
|
log="$installDir/install.log" # log file
|
||||||
versionData=$installDir/version-data.log # version data log file
|
versionData="$installDir/version-data.log" # version data log file
|
||||||
idfDir=$installDir/esp-idf # esp-idf path
|
idfDir="$installDir/esp-idf" # esp-idf path
|
||||||
exportScript=$idfDir/export.sh # export script
|
exportScript=$idfDir/export.sh # export script
|
||||||
customBinLocation=$installDir/.custom_bin # where custom bin scripts are placed
|
customBinLocation="$installDir/.custom_bin" # where custom bin scripts are placed
|
||||||
espressifLocation=$HOME/.espressif # espressif tools install location
|
espressifLocation="$HOME/.espressif" # espressif tools install location
|
||||||
runningDir="$( cd "$( dirname "$0" )" && pwd )"
|
runningDir="$( cd "$( dirname "$0" )" && pwd )"
|
||||||
customBinFrom=$runningDir/custom_bin # dir where custom scripts are coming FROM
|
customBinFrom="$runningDir/custom_bin" # dir where custom scripts are coming FROM
|
||||||
helpText=$runningDir/help.txt
|
exportBackupScript="$runningDir/export.sh.bak" # back up to running dir
|
||||||
exportBackupScript=$runningDir/export.sh.bak # back up to running dir
|
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 # just rename the argument var for clarity with the functions
|
||||||
|
|
||||||
if [ "$gitJobs" == "default" ]; then
|
if [ "$gitJobs" == "default" ]; then
|
||||||
@@ -181,7 +187,7 @@ function handleCustomBins() {
|
|||||||
# writeToLog "Handling custon bins (function ran)\n"
|
# writeToLog "Handling custon bins (function ran)\n"
|
||||||
if [ -d $customBinLocation ]; then
|
if [ -d $customBinLocation ]; then
|
||||||
writeToLog "Deleting $customBinLocation"
|
writeToLog "Deleting $customBinLocation"
|
||||||
rm -rf $customBinLocation
|
rm -rf "$customBinLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
rmCustomBinChk=$?
|
rmCustomBinChk=$?
|
||||||
else
|
else
|
||||||
@@ -189,26 +195,26 @@ function handleCustomBins() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
writeToLog "Copying scripts from $customBinFrom to $customBinLocation"
|
writeToLog "Copying scripts from $customBinFrom to $customBinLocation"
|
||||||
cp -r $customBinFrom $customBinLocation
|
cp -r "$customBinFrom" "$customBinLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
cpCustomBinChk=$?
|
cpCustomBinChk=$?
|
||||||
|
|
||||||
writeToLog "Making scripts executable at $customBinLocation"
|
writeToLog "Making scripts executable at $customBinLocation"
|
||||||
chmod -R +x $customBinLocation
|
chmod -R +x "$customBinLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
customBinExecChk=$?
|
customBinExecChk=$?
|
||||||
|
|
||||||
writeToLog "Copying vertson.txt and help.txt from $runningDir to $customBinLocation"
|
writeToLog "Copying vertson.txt and help.txt from $runningDir to $customBinLocation"
|
||||||
cp $runningDir/help.txt $customBinLocation
|
cp "$runningDir/help.txt $customBinLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
cp $runningDir/version.txt $customBinLocation
|
cp "$runningDir/version.txt" "$customBinLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
if [ -f $exportBackupScript ]; then
|
if [ -f "$exportBackupScript" ]; then
|
||||||
writeToLog "Deleting $exportBackupScript"
|
writeToLog "Deleting $exportBackupScript"
|
||||||
rm -f $exportBackupScript
|
rm -f "$exportBackupScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
rmExportBackupChk=$?
|
rmExportBackupChk=$?
|
||||||
else
|
else
|
||||||
@@ -216,39 +222,39 @@ function handleExport() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
writeToLog "Backing up $exportScript to $exportBackupScript"
|
writeToLog "Backing up $exportScript to $exportBackupScript"
|
||||||
cp $exportScript $exportBackupScript
|
cp "$exportScript" "$exportBackupScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
backupExportScriptChk=$?
|
backupExportScriptChk=$?
|
||||||
|
|
||||||
writeToLog "Appending $runningDir/add-to-export-sh.txt to $exportScript"
|
writeToLog "Appending $runningDir/add-to-export-sh.txt to $exportScript"
|
||||||
cat $runningDir/add-to-export-sh.txt >> $exportScript
|
cat "$runningDir/add-to-export-sh.txt" >> "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportCatChk=$?
|
exportCatChk=$?
|
||||||
|
|
||||||
writeToLog "Editing $exportScript to remove ending \`return 0\`"
|
writeToLog "Editing $exportScript to remove ending \`return 0\`"
|
||||||
sed -i 's/return 0/# return 0/g' $exportScript
|
sed -i 's/return 0/# return 0/g' "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportSedReturnChk=$?
|
exportSedReturnChk=$?
|
||||||
|
|
||||||
writeToLog "Editing $exportScript with version information: $scriptVers"
|
writeToLog "Editing $exportScript with version information: $scriptVers"
|
||||||
sed -i "s/versionDataTAG/\'$scriptVers\'/g" $exportScript
|
sed -i "s/versionDataTAG/\'$scriptVers\'/g" "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportSedVersionChk=$?
|
exportSedVersionChk=$?
|
||||||
|
|
||||||
writeToLog "Editing $exportScript with branch information: $gitBranch"
|
writeToLog "Editing $exportScript with branch information: $gitBranch"
|
||||||
sed -i "s/branchDataTAG/\'$gitBranch\'/g" $exportScript
|
sed -i "s/branchDataTAG/\'$gitBranch\'/g" "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportSedVersionChk=$?
|
exportSedVersionChk=$?
|
||||||
|
|
||||||
dateStampInstall=$(date '+%d-%m-%Y %H:%M:%S %Z (%s)')
|
dateStampInstall=$(date '+%d-%m-%Y %H:%M:%S %Z (%s)')
|
||||||
|
|
||||||
writeToLog "Editing $exportScript with install date information: $dateStampInstall"
|
writeToLog "Editing $exportScript with install date information: $dateStampInstall"
|
||||||
sed -i "s/installDateTAG/\'$dateStampInstall\'/g" $exportScript
|
sed -i "s/installDateTAG/\'$dateStampInstall\'/g" "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportSedDateChk=$?
|
exportSedDateChk=$?
|
||||||
|
|
||||||
writeToLog "Editing $exportScript with git commit hash data: $commitHash"
|
writeToLog "Editing $exportScript with git commit hash data: $commitHash"
|
||||||
sed -i "s/commitTAG/\'$commitHash\'/g" $exportScript
|
sed -i "s/commitTAG/\'$commitHash\'/g" "$exportScript"
|
||||||
returnStatus
|
returnStatus
|
||||||
exportSedHashChk=$?
|
exportSedHashChk=$?
|
||||||
}
|
}
|
||||||
@@ -257,7 +263,7 @@ function handleSetupEnvironment() {
|
|||||||
# writeToLog "Handling setup environment (function ran)\n
|
# writeToLog "Handling setup environment (function ran)\n
|
||||||
if [ ! -d "$installDir" ]; then
|
if [ ! -d "$installDir" ]; then
|
||||||
writeToLog "creating $installDir"
|
writeToLog "creating $installDir"
|
||||||
mkdir $installDir
|
mkdir "$installDir"
|
||||||
returnStatus
|
returnStatus
|
||||||
mkInstallDirChk=$?
|
mkInstallDirChk=$?
|
||||||
else
|
else
|
||||||
@@ -272,7 +278,7 @@ function handleSetupEnvironment() {
|
|||||||
|
|
||||||
if [ -d "$espressifLocation" ]; then
|
if [ -d "$espressifLocation" ]; then
|
||||||
writeToLog "$espressifLocation found, deleting for reinstall"
|
writeToLog "$espressifLocation found, deleting for reinstall"
|
||||||
rm -rf $espressifLocation
|
rm -rf "$espressifLocation"
|
||||||
returnStatus
|
returnStatus
|
||||||
rmEspressifChk=$?
|
rmEspressifChk=$?
|
||||||
else
|
else
|
||||||
@@ -311,7 +317,7 @@ function handleDownloadInstall() {
|
|||||||
|
|
||||||
if [ -d "$idfDir" ]; then
|
if [ -d "$idfDir" ]; then
|
||||||
writeToLog "Deleting $idfDir"
|
writeToLog "Deleting $idfDir"
|
||||||
rm -rf $idfDir
|
rm -rf "$idfDir"
|
||||||
returnStatus
|
returnStatus
|
||||||
rmIdfDirChk=$?
|
rmIdfDirChk=$?
|
||||||
else
|
else
|
||||||
@@ -372,7 +378,7 @@ function handleDownloadInstall() {
|
|||||||
# date&time ddmmYYYY H:M:S (unix seconds) | esp-idf branch | esp-idf-tools version | action
|
# date&time ddmmYYYY H:M:S (unix seconds) | esp-idf branch | esp-idf-tools version | action
|
||||||
gitDataLog="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)') | $commitHash | $gitBranch | $scriptVers | $action"
|
gitDataLog="$(date '+%d/%m/%Y %H:%M:%S %Z (%s)') | $commitHash | $gitBranch | $scriptVers | $action"
|
||||||
writeToLog "$gitDataLog"
|
writeToLog "$gitDataLog"
|
||||||
echo "$gitDataLog" >> $versionData
|
echo "$gitDataLog" >> "$versionData"
|
||||||
returnStatus
|
returnStatus
|
||||||
gitLogChk=$?
|
gitLogChk=$?
|
||||||
}
|
}
|
||||||
@@ -415,21 +421,21 @@ function handleStart() {
|
|||||||
|
|
||||||
function handleEmptyLogs() {
|
function handleEmptyLogs() {
|
||||||
echo -e "\nDeleting $log"
|
echo -e "\nDeleting $log"
|
||||||
rm -f $log
|
rm -f "$log"
|
||||||
echo -e "\tReturn status: ${?}\n"
|
echo -e "\tReturn status: ${?}\n"
|
||||||
|
|
||||||
echo "Deleting $versionData"
|
echo "Deleting $versionData"
|
||||||
rm -f $versionData
|
rm -f "$versionData"
|
||||||
echo -e "\tReturn status: ${?}\n"
|
echo -e "\tReturn status: ${?}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUninstall() {
|
function handleUninstall() {
|
||||||
echo -e "\nDeleting $espressifLocation"
|
echo -e "\nDeleting $espressifLocation"
|
||||||
rm -rf $espressifLocation
|
rm -rf "$espressifLocation"
|
||||||
echo -e "\tReturn status: ${?}\n"
|
echo -e "\tReturn status: ${?}\n"
|
||||||
|
|
||||||
echo -e "Deleting $idfDir"
|
echo -e "Deleting $idfDir"
|
||||||
rm -rf $idfDir
|
rm -rf "$idfDir"
|
||||||
echo -e "\tReturn status: ${?}"
|
echo -e "\tReturn status: ${?}"
|
||||||
|
|
||||||
handleEmptyLogs
|
handleEmptyLogs
|
||||||
@@ -469,12 +475,7 @@ function handleEnd() {
|
|||||||
writeToLog " === Finished ===\n\n"
|
writeToLog " === Finished ===\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$arg" == "--help" || "$arg" == "help" || "$arg" == "-h" || "$arg" == "h" ]]; then
|
if [[ "$arg" == "test" || "$arg" == "t" ]]; then # minimal actions taken, echo the given commands and such
|
||||||
cat $helpText;
|
|
||||||
|
|
||||||
exit
|
|
||||||
|
|
||||||
elif [[ "$arg" == "test" || "$arg" == "t" ]]; then # minimal actions taken, echo the given commands and such
|
|
||||||
action="TEST"
|
action="TEST"
|
||||||
sleepMins=0
|
sleepMins=0
|
||||||
|
|
||||||
@@ -528,23 +529,23 @@ elif [[ "$arg" == "interactive" || "$arg" == "i" ]]; then
|
|||||||
read readIdfGet
|
read readIdfGet
|
||||||
|
|
||||||
if [ ! -z $readInstallDir ]; then
|
if [ ! -z $readInstallDir ]; then
|
||||||
installDir=$readInstallDir
|
installDir="$readInstallDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $readGitBranch ]; then
|
if [ ! -z $readGitBranch ]; then
|
||||||
gitBranch=$readGitBranch
|
gitBranch="$readGitBranch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $readRcFile ]; then
|
if [ ! -z $readRcFile ]; then
|
||||||
rcFile=$readRcFile
|
rcFile="$readRcFile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $readGitJobs ]; then
|
if [ ! -z $readGitJobs ]; then
|
||||||
gitJobs=$readGitJobs
|
gitJobs="$readGitJobs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $readIdfGet ]; then
|
if [ ! -z $readIdfGet ]; then
|
||||||
idfGet=$readIdfGet
|
idfGet="$readIdfGet"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
writeToLog "\n === New $action ===\n"
|
writeToLog "\n === New $action ===\n"
|
||||||
@@ -564,9 +565,8 @@ elif [[ "$arg" == "interactive" || "$arg" == "i" ]]; then
|
|||||||
|
|
||||||
elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sleep, and reboot
|
elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sleep, and reboot
|
||||||
action="REINSTALL (CRON)"
|
action="REINSTALL (CRON)"
|
||||||
sleepMins=1
|
sleepMins=5
|
||||||
idfGet="update"
|
idfGet="update"
|
||||||
sleepMins=0
|
|
||||||
|
|
||||||
handleStart
|
handleStart
|
||||||
messagePTS "\n\nesp-idf-tools action $action started!\nWill reboot with $sleepMins minutes delay when complete!\n\n"
|
messagePTS "\n\nesp-idf-tools action $action started!\nWill reboot with $sleepMins minutes delay when complete!\n\n"
|
||||||
@@ -583,7 +583,7 @@ elif [[ "$arg" == "cron" || "$arg" == "c" ]]; then # full install with warn, sle
|
|||||||
elif [[ "$arg" == "update" || "$arg" == "u" ]]; then # update without logouts or reboot
|
elif [[ "$arg" == "update" || "$arg" == "u" ]]; then # update without logouts or reboot
|
||||||
action="UPDATE"
|
action="UPDATE"
|
||||||
idfGet="update"
|
idfGet="update"
|
||||||
sleepMins=1
|
sleepMins=0
|
||||||
|
|
||||||
handleStart
|
handleStart
|
||||||
handleClearInstallLog
|
handleClearInstallLog
|
||||||
@@ -635,12 +635,7 @@ elif [[ "$arg" == "nukereboot" || "$arg" == "nr" ]]; then
|
|||||||
|
|
||||||
elif [ "$arg" == "uninstall" ]; then
|
elif [ "$arg" == "uninstall" ]; then
|
||||||
handleUninstall
|
handleUninstall
|
||||||
|
|
||||||
echo -e "\nAll done :3\n"
|
echo -e "\nAll done :3\n"
|
||||||
exit
|
|
||||||
|
|
||||||
elif [ ! -z $arg ]; then
|
|
||||||
writeToLog "FAIL: bad argument. Terminating"
|
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ x rebuildfull
|
|||||||
x chipinfo
|
x chipinfo
|
||||||
x esp-install-monitor
|
x esp-install-monitor
|
||||||
x esp-install-logs
|
x esp-install-logs
|
||||||
run-esp-cmd n
|
x run-esp-cmd n
|
||||||
fresh install from nothing
|
x fresh install from nothing
|
||||||
|
|
||||||
audit readme
|
audit readme
|
||||||
maybe pretty up
|
maybe pretty up
|
||||||
|
|||||||
Reference in New Issue
Block a user