#2388 improve online check (less pinging)

This commit is contained in:
rootzoll
2021-07-02 14:02:45 +02:00
parent 098eb711ad
commit bc76dce517

View File

@@ -85,8 +85,18 @@ configWifiExists=$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 2>/dev/null|
############################################# #############################################
# check for internet connection # 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 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 # re-test with user set dns server
online=$(ping ${dnsServer} -c 1 -W 2 | grep -c '1 received') online=$(ping ${dnsServer} -c 1 -W 2 | grep -c '1 received')
fi fi