summaryrefslogtreecommitdiff
path: root/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh
diff options
context:
space:
mode:
authorGleb Balykov <g.balykov@samsung.com>2018-09-07 16:40:01 +0300
committerGleb Balykov <g.balykov@samsung.com>2018-09-18 15:49:14 +0300
commit526edf5f944417734d165ecd95151636f284bde5 (patch)
treeaa40aeee15d733b1392996565b7da87c8802bb0e /packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh
parent26389129ae16c6dd9b1fca19684b6d4ffbe59593 (diff)
downloadcoreclr-526edf5f944417734d165ecd95151636f284bde5.tar.gz
coreclr-526edf5f944417734d165ecd95151636f284bde5.tar.bz2
coreclr-526edf5f944417734d165ecd95151636f284bde5.zip
[Tizen] Update build tools to 2.1.0-rc1-03006-01
Diffstat (limited to 'packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh')
-rwxr-xr-xpackages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh93
1 files changed, 93 insertions, 0 deletions
diff --git a/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh
new file mode 100755
index 0000000000..af0d2c5ddd
--- /dev/null
+++ b/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/scripts/docker/init-docker.sh
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+
+# Stop script on NZEC
+set -e
+# Stop script if unbound variable found (use ${var:-} if intentional)
+set -u
+
+say_err() {
+ printf "%b\n" "Error: $1" >&2
+}
+
+showHelp() {
+ echo "Usage: $scriptName [OPTIONS] [IMAGE_NAME[:TAG|@DIGEST]]"
+ echo
+ echo "Initializes Docker by:"
+ echo " - Emitting the version of Docker that is being used"
+ echo " - Removing all containers and images that exist on the machine"
+ echo " - Ensuring the latest copy of the specified image exists on the machine"
+ echo
+ echo "Options:"
+ echo " -r, --retryCount Number of times to retry pulling image on error"
+ echo " -w, --waitFactor Time (seconds) to wait between pulls (time is multiplied each iteration)"
+}
+
+# Executes a command and retries if it fails.
+execute() {
+ local count=0
+ until "$@"; do
+ local exit=$?
+ count=$(( $count + 1 ))
+ if [ $count -lt $retries ]; then
+ local wait=$(( waitFactor ** (( count - 1 )) ))
+ echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
+ sleep $wait
+ else
+ say_err "Retry $count/$retries exited $exit, no more retries left."
+ return $exit
+ fi
+ done
+
+ return 0
+}
+
+scriptName=$0
+retries=5
+waitFactor=6
+image=
+
+while [ $# -ne 0 ]; do
+ name=$1
+ case $name in
+ -h|--help)
+ showHelp
+ exit 0
+ ;;
+ -r|--retryCount)
+ shift
+ retries=$1
+ ;;
+ -w|--waitFactor)
+ shift
+ waitFactor=$1
+ ;;
+ -*)
+ say_err "Unknown option: $1"
+ exit 1
+ ;;
+ *)
+ if [ ! -z "$image" ]; then
+ say_err "Unknown argument: \`$name\`"
+ exit 1
+ fi
+
+ image="$1"
+ ;;
+ esac
+
+ shift
+done
+
+# Capture Docker version for diagnostic purposes
+docker --version
+echo
+
+echo "Cleaning Docker Artifacts"
+sourceDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+"$sourceDir/cleanup-docker.sh"
+echo
+
+if [ ! -z "$image" ]; then
+ echo "Pulling Docker image $image"
+ execute docker pull $image
+fi