pull/2/head
Hari Sekhon 7 years ago
commit f96878da14

@ -20,7 +20,7 @@ echo "==========================================================================
echo " G r a d l e I n s t a l l"
echo "================================================================================"
GRADLE_VERSION=${GRADLE_VERSION:-2.14.1}
GRADLE_VERSION=${1:-${GRADLE_VERSION:-2.14.1}}
BASE=/opt

@ -20,7 +20,7 @@ echo "==========================================================================
echo " G r o o v y I n s t a l l"
echo "================================================================================"
GROOVY_VERSION=${GROOVY_VERSION:-2.4.7}
GROOVY_VERSION=${1:-${GROOVY_VERSION:-2.4.7}}
BASE=/opt

@ -20,7 +20,7 @@ echo "==========================================================================
echo " M a v e n I n s t a l l"
echo "================================================================================"
MAVEN_VERSION=${MAVEN_VERSION:-3.3.9}
MAVEN_VERSION=${1:-${MAVEN_VERSION:-3.3.9}}
BASE=/opt

@ -20,7 +20,7 @@ echo "==========================================================================
echo " S B T I n s t a l l"
echo "================================================================================"
SBT_VERSION=${SBT_VERSION:-0.13.12}
SBT_VERSION=${1:${SBT_VERSION:-0.13.12}}
BASE=/opt

@ -278,6 +278,16 @@ when_ports_available(){
local host="$2"
local ports="${@:3}"
local retry_interval=1
if [ -z "$max_secs" ]; then
echo 'when_ports_available: max_secs $1 not set'
exit 1
elif [ -z "$host" ]; then
echo 'when_ports_available: host $2 not set'
exit 1
elif [ -z "$ports" ]; then
echo 'when_ports_available: ports $3 not set'
exit 1
fi
local max_tries=$(($max_secs / $retry_interval))
# Linux nc doens't have -z switch like Mac OSX version
local nc_cmd="nc -vw $retry_interval $host <<< ''"
@ -291,8 +301,8 @@ when_ports_available(){
echo "cmd: ${cmd// \&\>\/dev\/null}"
local found=0
if which nc &>/dev/null; then
for((i=0; i < $max_tries; i++)); do
timestamp "trying host '$host' port(s) '$ports'"
for((i=1; i <= $max_tries; i++)); do
timestamp "$i trying host '$host' port(s) '$ports'"
if eval $cmd; then
found=1
break
@ -310,5 +320,33 @@ when_ports_available(){
fi
}
when_url_content(){
local max_secs="$1"
local url="$2"
local expected_regex="$3"
local retry_interval=1
if [ -z "$max_secs" ]; then
echo 'when_url_content: max_secs $1 not set'
exit 1
elif [ -z "$url" ]; then
echo 'when_url_content: url $2 not set'
exit 1
elif [ -z "$expected_regex" ]; then
echo 'when_url_content: expected content $3 not set'
exit 1
fi
local max_tries=$(($max_secs / $retry_interval))
echo "waiting up to $max_secs secs for HTTP interface to come up with expected regex content"
for((i=1; i <= $max_tries; i++)); do
timestamp "$i trying $url"
if curl -s "$url" | grep -q "$expected_regex"; then
echo "URL content detected"
return
fi
sleep 1
done
echo 'URL content still not detected, giving up!'
}
# restore original srcdir
srcdir="$srcdir_bash_tools_utils"

Loading…
Cancel
Save