Mercurial > sat_docs
diff docker/libervia_cont.sh @ 110:51dc15fbd813
docker (libervia_cont): added check_docker_version function which return 0 if current docker version is greater than wanted one, -1 else
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 Feb 2016 21:54:41 +0100 |
parents | cb16c0a1f194 |
children | a3f9cfa2721e |
line wrap: on
line diff
--- a/docker/libervia_cont.sh Mon Feb 29 21:50:53 2016 +0100 +++ b/docker/libervia_cont.sh Mon Feb 29 21:54:41 2016 +0100 @@ -158,6 +158,30 @@ fi } +check_docker_version() { + # check if current docker version is greater than or equal to the requested one + wanted_major=$1 + wanted_minor=$2 + wanted_rev=$3 + raw=$(docker --version | grep -o '\([0-9]\+\)\.[0-9]\+\.[0-9]\+') + docker_major=$(echo "$raw" | cut -d . -f 1) + docker_minor=$(echo "$raw" | cut -d . -f 2) + docker_rev=$(echo "$raw" | cut -d . -f 3) + for name in major minor rev; do + docker_val=$(eval echo \$docker_$name) + wanted_val=$(eval echo \$wanted_$name) + if [ $docker_val -gt $wanted_val ]; then + return 0 + fi + if [ $docker_val -lt $wanted_val ]; then + return 1 + fi + done + + # wanted version and docker version are the same + return 0 +} + parse_run_args() { # manage arguments for run command @@ -299,7 +323,7 @@ # we test the presence of "starting on xxxx" (where xxxx is one of the exposed ports) # this is not really reliable as ports can be changed in configuration # but in most case it should work OK - PORTS_REGEX=$(get_dyn_var $TEST_CONT ports | sed 's/ /\\|/') + PORTS_REGEX=$(get_dyn_var $TEST_CONT ports | sed 's/ /\\|/') docker logs $TEST_CONT | grep "starting on \($PORTS_REGEX\)" > /dev/null 2>&1 if [ $? -ne 0 ]; then printf " but no server is started\n"