feature(HELPERSCRIPTS): add conditionality to script update

This commit is contained in:
Asif Bacchus 2021-01-15 05:18:55 -07:00
parent 7e96583455
commit cbaadc40c4

View File

@ -122,24 +122,25 @@ fi
### update scripts ### update scripts
printf "%sUpdating %s service scripts%s\n" "$info" "$containerName" "$norm" if [ "$doScriptUpdate" -eq 1 ]; then
printf "%s*** Updating %s service scripts ***%s\n" "$info" "$containerName" "$norm"
## download latest checksums ## download latest checksums
printf "Getting latest checksums... " printf "Getting latest checksums... "
if ! wget --quiet --tries=3 --timeout=10 -N "${server}${checksumFilename}"; then if ! wget --quiet --tries=3 --timeout=10 -N "${server}${checksumFilename}"; then
errNotify errNotify
errMsg "Unable to download checksums. Try again later." errMsg "Unable to download checksums. Try again later."
else else
okNotify okNotify
fi fi
## check for updates to this script ## check for updates to this script
printf "Checking for updates to this script... " printf "Checking for updates to this script... "
repoScriptChecksum=$(grep "$repoScriptName" "$checksumFilename" | grep -o '^\S*') repoScriptChecksum=$(grep "$repoScriptName" "$checksumFilename" | grep -o '^\S*')
localScriptChecksum=$(sha256sum "$localScriptName" | grep -o '^\S*') localScriptChecksum=$(sha256sum "$localScriptName" | grep -o '^\S*')
if [ "$localScriptChecksum" = "$repoScriptChecksum" ]; then if [ "$localScriptChecksum" = "$repoScriptChecksum" ]; then
printf "[NONE]\n" printf "[NONE]\n"
else else
printf "[AVAILABLE]\n" printf "[AVAILABLE]\n"
printf "Getting updated script... " printf "Getting updated script... "
# download updated script # download updated script
@ -163,10 +164,10 @@ else
mv -f ./update.sh.tmp "$localScriptName" mv -f ./update.sh.tmp "$localScriptName"
fi fi
fi fi
fi fi
## update files ## update files
while IFS=' ' read -r field1 field2; do while IFS=' ' read -r field1 field2; do
printf "\nChecking '%s' for updates... " "$field2" printf "\nChecking '%s' for updates... " "$field2"
updateFilename="$field2" updateFilename="$field2"
repoFileChecksum="$field1" repoFileChecksum="$field1"
@ -208,8 +209,8 @@ while IFS=' ' read -r field1 field2; do
else else
printf "[NONE]\n" printf "[NONE]\n"
fi fi
done <"$checksumFilename" done <"$checksumFilename"
fi
### display results ### display results
printf "\n%sResults:%s\n" "$info" "$norm" printf "\n%sResults:%s\n" "$info" "$norm"