feature(HELPERSCRIPTS): conditionally update docker container

- move previous prerequisite checks related to docker
This commit is contained in:
Asif Bacchus 2021-01-15 05:15:38 -07:00
parent 19a8f3a082
commit 7e96583455
1 changed files with 19 additions and 20 deletions

View File

@ -39,25 +39,11 @@ else
fi fi
### pre-requisites ### pre-requisites
# check if wget is installed # check if wget is installed
if ! command -v wget >/dev/null 2>&1; then if ! command -v wget >/dev/null 2>&1; then
errMsg "Sorry, this script requires that 'wget' is installed in order to download updates. Exiting." errMsg "Sorry, this script requires that 'wget' is installed in order to download updates. Exiting."
fi fi
# include in docker section
## check if docker is installed
#if ! command -v docker >/dev/null 2>&1; then
# errMsg "Sorry, it appears that docker is not installed on this machine! Exiting."
#fi
#
## is user root or in the docker group?
#if [ ! "$(id -u)" -eq 0 ]; then
# if ! id -Gn | grep docker >/dev/null; then
# errMsg "You must either be root or in the 'docker' group to pull container updates."
# fi
#fi
# zero counters # zero counters
updatesAvailable=0 updatesAvailable=0
downloadFailed=0 downloadFailed=0
@ -113,15 +99,28 @@ done
### update container ### update container
printf "%s\n*** Updating %s container and service scripts ***\n\n%s" "$info" "$containerName" "$norm" if [ "$doDockerUpdate" -eq 1 ]; then
# check if docker is installed
if ! command -v docker >/dev/null 2>&1; then
errMsg "Sorry, it appears that docker is not installed on this machine! Exiting."
fi
printf "Updating container:\n" # is user root or in the docker group?
if ! docker pull "$containerUpdatePath"; then if [ ! "$(id -u)" -eq 0 ]; then
errMsg "There was an error updating the container. Try again later." if ! id -Gn | grep docker >/dev/null; then
else errMsg "You must either be root or in the 'docker' group to pull container updates."
okMsg "Container updated!" fi
fi
printf "%s\n*** Updating %s container ***\n\n%s" "$info" "$containerName" "$norm"
if ! docker pull "$containerUpdatePath"; then
errMsg "There was an error updating the container. Try again later."
else
okMsg "Container updated!"
fi
fi fi
### update scripts ### update scripts
printf "%sUpdating %s service scripts%s\n" "$info" "$containerName" "$norm" printf "%sUpdating %s service scripts%s\n" "$info" "$containerName" "$norm"