2 # https://github.com/Eficode/wait-for.git
9 if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
16 $cmdname host:port [-t timeout] [-- command args]
17 -q | --quiet Do not output any status messages
18 -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout
19 -- COMMAND ARGS Execute command with args after the test finishes
26 if [ "$QUIET" -ne 1 ]; then echo "$0: probing host $HOST port $PORT"; fi
27 for i in `seq $TIMEOUT` ; do
28 nc -z "$HOST" "$PORT" > /dev/null 2>&1
30 if [ $result -eq 0 ] ; then
31 if [ "$QUIET" -ne 1 ]; then echo "$0: operation succeeded on try $i"; fi
32 if [ -n "$command" ] ; then
33 if [ "$QUIET" -ne 1 ]; then echo "$0: exec-ing command $command"; fi
38 if [ "$QUIET" -ne 1 ]; then echo "$0: sleeping after try $i"; fi
41 echo "$0: Operation timed out" >&2
49 HOST=$(printf "%s\n" "$1"| cut -d : -f 1)
50 PORT=$(printf "%s\n" "$1"| cut -d : -f 2)
59 if [ "$TIMEOUT" = "" ]; then break; fi
74 echoerr "Unknown argument: $1"
80 if [ "$HOST" = "" -o "$PORT" = "" ]; then
81 echoerr "Error: you need to provide a host and port to test."