Browse Source

[Update] Allow to skip fetching docker-compose

andryyy 5 years ago
parent
commit
f6a41daffa
1 changed files with 31 additions and 22 deletions
  1. 31 22
      update.sh

+ 31 - 22
update.sh

@@ -150,14 +150,19 @@ while (($#)); do
       echo -e "\e[32mForcing Update...\e[0m"
       FORCE=y
     ;;
+    --no-update-compose)
+      NO_UPDATE_COMPOSE=y
+    ;;
     --help|-h)
     echo './update.sh [-c|--check, --ours, --gc, --skip-start, -h|--help]
 
-  -c|--check   -   Check for updates and exit (exit codes => 0: update available, 3: no updates)
-  --ours       -   Use merge strategy "ours" to solve conflicts in favor of non-mailcow code (local changes)
-  --gc         -   Run garbage collector to delete old image tags
-  --skip-start -   Do not start mailcow after update
-  -f|--force   -   Force update, do not ask questions
+  -c|--check           -   Check for updates and exit (exit codes => 0: update available, 3: no updates)
+  --ours               -   Use merge strategy "ours" to solve conflicts in favor of non-mailcow code (local changes)
+  --gc                 -   Run garbage collector to delete old image tags
+  --no-update-compose  -   Do not update docker-compose
+  --prefetch           -   Only prefetch new images and exit (useful to prepare updates)
+  --skip-start         -   Do not start mailcow after update
+  -f|--force           -   Force update, do not ask questions
 '
     exit 1
   esac
@@ -467,25 +472,29 @@ elif [[ ${MERGE_RETURN} != 0 ]]; then
   exit 1
 fi
 
-echo -e "\e[32mFetching new docker-compose version...\e[0m"
-sleep 2
-if [[ ! -z $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then
-  true
-  #prevent breaking a working docker-compose installed with pip
-elif [[ $(curl -sL -w "%{http_code}" https://www.servercow.de/docker-compose/latest.php -o /dev/null) == "200" ]]; then
-  LATEST_COMPOSE=$(curl -#L https://www.servercow.de/docker-compose/latest.php)
-  COMPOSE_VERSION=$(docker-compose version --short)
-  if [[ "$LATEST_COMPOSE" != "$COMPOSE_VERSION" ]]; then
-    COMPOSE_PATH=$(which docker-compose) 
-    if [[ -w ${COMPOSE_PATH} ]]; then
-      curl -#L https://github.com/docker/compose/releases/download/${LATEST_COMPOSE}/docker-compose-$(uname -s)-$(uname -m) > $COMPOSE_PATH
-      chmod +x $COMPOSE_PATH
-    else
-      echo -e "\e[33mWARNING: $COMPOSE_PATH is not writable, but new version $LATEST_COMPOSE is available (installed: $COMPOSE_VERSION)\e[0m"
+if [[ ${NO_UPDATE_COMPOSE} == "y" ]]; then
+  echo -e "\e[33mNot fetching latest docker-compose, please check for updates manually!\e[0m"
+else
+  echo -e "\e[32mFetching new docker-compose version...\e[0m"
+  sleep 1
+  if [[ ! -z $(which pip) && $(pip list --local 2>&1 | grep -v DEPRECATION | grep -c docker-compose) == 1 ]]; then
+    true
+    #prevent breaking a working docker-compose installed with pip
+  elif [[ $(curl -sL -w "%{http_code}" https://www.servercow.de/docker-compose/latest.php -o /dev/null) == "200" ]]; then
+    LATEST_COMPOSE=$(curl -#L https://www.servercow.de/docker-compose/latest.php)
+    COMPOSE_VERSION=$(docker-compose version --short)
+    if [[ "$LATEST_COMPOSE" != "$COMPOSE_VERSION" ]]; then
+      COMPOSE_PATH=$(which docker-compose)
+      if [[ -w ${COMPOSE_PATH} ]]; then
+        curl -#L https://github.com/docker/compose/releases/download/${LATEST_COMPOSE}/docker-compose-$(uname -s)-$(uname -m) > $COMPOSE_PATH
+        chmod +x $COMPOSE_PATH
+      else
+        echo -e "\e[33mWARNING: $COMPOSE_PATH is not writable, but new version $LATEST_COMPOSE is available (installed: $COMPOSE_VERSION)\e[0m"
+      fi
     fi
+  else
+    echo -e "\e[33mCannot determine latest docker-compose version, skipping...\e[0m"
   fi
-else
-  echo -e "\e[33mCannot determine latest docker-compose version, skipping...\e[0m"
 fi
 
 echo -e "\e[32mFetching new images, if any...\e[0m"