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