From 7e96583455bc11e870bd7c022bacf83555aa4fb7 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 15 Jan 2021 05:15:38 -0700 Subject: [PATCH] feature(HELPERSCRIPTS): conditionally update docker container - move previous prerequisite checks related to docker --- helpers/update.sh | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/helpers/update.sh b/helpers/update.sh index 9bf0cfa..1f6064b 100644 --- a/helpers/update.sh +++ b/helpers/update.sh @@ -39,25 +39,11 @@ else fi ### pre-requisites - # check if wget is installed if ! command -v wget >/dev/null 2>&1; then errMsg "Sorry, this script requires that 'wget' is installed in order to download updates. Exiting." 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 updatesAvailable=0 downloadFailed=0 @@ -113,15 +99,28 @@ done ### 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" -if ! docker pull "$containerUpdatePath"; then - errMsg "There was an error updating the container. Try again later." -else - okMsg "Container updated!" + # 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 + + 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 + ### update scripts printf "%sUpdating %s service scripts%s\n" "$info" "$containerName" "$norm"