From bc76dce51725081667859dc73002d9b00340000e Mon Sep 17 00:00:00 2001 From: rootzoll Date: Fri, 2 Jul 2021 14:02:45 +0200 Subject: [PATCH] #2388 improve online check (less pinging) --- home.admin/config.scripts/internet.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/home.admin/config.scripts/internet.sh b/home.admin/config.scripts/internet.sh index c512f68d5..359cfd388 100755 --- a/home.admin/config.scripts/internet.sh +++ b/home.admin/config.scripts/internet.sh @@ -85,8 +85,18 @@ configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null| ############################################# # check for internet connection + +# first quick check if bitcoind has peers - if so the client is online +# if not then recheck by pinging different sources if online +# used cached results to not delay (cache will be updated by background process) +source <(/home/admin/config.scripts/network.monitor.sh peer-status) + online=0 -if [ "${dnsServer}" != "" ]; then +if [ "${peers}" != "0" ]; then + # bitcoind has peers - so device is online + online=1 +fi +if [ ${online} -eq 0 ] && [ "${dnsServer}" != "" ]; then # re-test with user set dns server online=$(ping ${dnsServer} -c 1 -W 2 | grep -c '1 received') fi