mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-25 15:43:19 +00:00
Wait until DNS resolution is available
Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
parent
ba2d10c65e
commit
f80efa51aa
1 changed files with 10 additions and 17 deletions
27
gravity.sh
27
gravity.sh
|
@ -298,29 +298,22 @@ gravity_CheckDNSResolutionAvailable() {
|
||||||
|
|
||||||
# Determine if $lookupDomain is resolvable
|
# Determine if $lookupDomain is resolvable
|
||||||
if timeout 4 getent hosts "${lookupDomain}" &>/dev/null; then
|
if timeout 4 getent hosts "${lookupDomain}" &>/dev/null; then
|
||||||
# Print confirmation of resolvability if it had previously failed
|
echo -e "${OVER} ${TICK} DNS resolution is available\\n"
|
||||||
if [[ -n "${secs:-}" ]]; then
|
|
||||||
echo -e "${OVER} ${TICK} DNS resolution is now available\\n"
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
elif [[ -n "${secs:-}" ]]; then
|
else
|
||||||
echo -e "${OVER} ${CROSS} DNS resolution is not available"
|
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e " ${INFO} Waiting until DNS resolution is available..."
|
||||||
# Ensure DNS server is given time to be resolvable
|
until getent hosts github.com &> /dev/null; do
|
||||||
secs="120"
|
# Append one dot for each second waiting
|
||||||
echo -ne " ${INFO} Time until retry: ${secs}"
|
str="${str}."
|
||||||
until timeout 1 getent hosts "${lookupDomain}" &>/dev/null; do
|
echo -ne " ${OVER} ${INFO} ${str}"
|
||||||
[[ "${secs:-}" -eq 0 ]] && break
|
|
||||||
echo -ne "${OVER} ${INFO} Time until retry: ${secs}"
|
|
||||||
: $((secs--))
|
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# Try again
|
# If we reach this point, DNS resolution is available
|
||||||
gravity_CheckDNSResolutionAvailable
|
echo -e "${OVER} ${TICK} DNS resolution is available"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve blocklist URLs and parse domains from adlist.list
|
# Retrieve blocklist URLs and parse domains from adlist.list
|
||||||
|
|
Loading…
Reference in a new issue