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 (#6196)
This commit is contained in:
commit
3cbaee7b76
34
gravity.sh
34
gravity.sh
@ -348,17 +348,24 @@ gravity_CheckDNSResolutionAvailable() {
|
|||||||
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
echo -e " ${CROSS} DNS resolution is currently unavailable"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
str="Waiting until DNS resolution is available..."
|
str="Waiting up to 120 seconds for DNS resolution..."
|
||||||
echo -ne " ${INFO} ${str}"
|
echo -ne " ${INFO} ${str}"
|
||||||
until getent hosts github.com &> /dev/null; do
|
|
||||||
# Append one dot for each second waiting
|
# Default DNS timeout is two seconds, plus 1 second for each dot > 120 seconds
|
||||||
str="${str}."
|
for ((i = 0; i < 40; i++)); do
|
||||||
echo -ne " ${OVER} ${INFO} ${str}"
|
if getent hosts github.com &> /dev/null; then
|
||||||
sleep 1
|
# 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
|
||||||
|
echo -ne "."
|
||||||
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
# If we reach this point, DNS resolution is available
|
# DNS resolution is still unavailable after 120 seconds
|
||||||
echo -e "${OVER} ${TICK} DNS resolution is available"
|
return 1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function: try_restore_backup
|
# Function: try_restore_backup
|
||||||
@ -1081,6 +1088,12 @@ for var in "$@"; do
|
|||||||
esac
|
esac
|
||||||
done
|
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
|
# Remove OLD (backup) gravity file, if it exists
|
||||||
if [[ -f "${gravityOLDfile}" ]]; then
|
if [[ -f "${gravityOLDfile}" ]]; then
|
||||||
rm "${gravityOLDfile}"
|
rm "${gravityOLDfile}"
|
||||||
@ -1121,11 +1134,6 @@ if [[ "${forceDelete:-}" == true ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Gravity downloads blocklists next
|
# 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
|
if ! gravity_DownloadBlocklists; then
|
||||||
echo -e " ${CROSS} Unable to create gravity database. Please try again later. If the problem persists, please contact support."
|
echo -e " ${CROSS} Unable to create gravity database. Please try again later. If the problem persists, please contact support."
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user