mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-07-28 08:04:11 +02:00
Fix gravity waiting forever for DNS
Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
parent
60485fdc51
commit
72a52807d1
34
gravity.sh
34
gravity.sh
@ -348,17 +348,24 @@ gravity_CheckDNSResolutionAvailable() {
|
||||
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||
fi
|
||||
|
||||
str="Waiting until DNS resolution is available..."
|
||||
str="Waiting 120 seconds if DNS resolution becomes available..."
|
||||
echo -ne " ${INFO} ${str}"
|
||||
until getent hosts github.com &> /dev/null; do
|
||||
# Append one dot for each second waiting
|
||||
str="${str}."
|
||||
echo -ne " ${OVER} ${INFO} ${str}"
|
||||
sleep 1
|
||||
|
||||
for ((i = 0; i < 120; i++)); do
|
||||
if getent hosts github.com &> /dev/null; then
|
||||
# If we reach this point, DNS resolution is available
|
||||
echo -e "${OVER} ${TICK} DNS resolution is available"
|
||||
break
|
||||
fi
|
||||
# Append one dot for each second waiting
|
||||
str="${str}."
|
||||
echo -ne " ${OVER} ${INFO} ${str}"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# If we reach this point, DNS resolution is available
|
||||
echo -e "${OVER} ${TICK} DNS resolution is available"
|
||||
# DNS resolution is still unavailable after 120 seconds
|
||||
return 1
|
||||
|
||||
}
|
||||
|
||||
# Function: try_restore_backup
|
||||
@ -1081,6 +1088,12 @@ for var in "$@"; do
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if DNS is available, no need to do any database manipulation if we're not able to download adlists
|
||||
if ! timeit gravity_CheckDNSResolutionAvailable; then
|
||||
echo -e " ${CROSS} No DNS resolution available. Please contact support."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove OLD (backup) gravity file, if it exists
|
||||
if [[ -f "${gravityOLDfile}" ]]; then
|
||||
rm "${gravityOLDfile}"
|
||||
@ -1121,11 +1134,6 @@ if [[ "${forceDelete:-}" == true ]]; then
|
||||
fi
|
||||
|
||||
# Gravity downloads blocklists next
|
||||
if ! timeit gravity_CheckDNSResolutionAvailable; then
|
||||
echo -e " ${CROSS} Can not complete gravity update, no DNS is available. Please contact support."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! gravity_DownloadBlocklists; then
|
||||
echo -e " ${CROSS} Unable to create gravity database. Please try again later. If the problem persists, please contact support."
|
||||
exit 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user