#!/bin/bash targetHostname="$1" timeOut="$2" if test -z "$targetHostname" ; then echo "ERROR: No hostname given." echo "Usage: $0 fqdn timeOutSeconds" exit -1 fi if test -z "$timeOut" ; then timeOut=60 fi for seconds in $(seq $timeOut -1 1) ; do systemd-resolve --flush-caches if host "$targetHostname" 1>/dev/null 2>&1 ; then if ping -c1 -w1 "$targetHostname" 1>/dev/null 2>&1 ; then break else #echo "${seconds}s left" continue fi else #echo "${seconds}s left" sleep 1 fi done if test $seconds -gt 1 ; then true else false fi