github.com/verrazzano/verrazzano@v1.7.1/tools/scripts/retry-utils.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2021, Oracle and/or its affiliates. 4 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 5 # 6 7 # $1 The docker image to pull (required) 8 # $2 Retry limit (optional defaults to 5) 9 # $3 Sleep time (optional defaults to 5 seconds) 10 function docker_pull_retry () { 11 if [ -z "$1" ]; then 12 echo "Image to pull needs to be specified" 13 return 1 14 fi 15 local attempts=0 16 local retry_limit=${2:-"5"} 17 local sleep_time=${3:-"5"} 18 until [ ${attempts} -ge ${retry_limit} ] 19 do 20 docker pull $1 && break 21 let attempts=attempts+1 22 if [ ${attempts} -ge ${retry_limit} ]; then 23 echo "docker pull failed after ${ATTEMPTS} retry attempts" 24 return 1 25 fi 26 sleep ${sleep_time} 27 done 28 return 0 29 }