mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-20 04:37:19 +02:00
#2388 improve online check (less pinging)
This commit is contained in:
@@ -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
|
||||||
|
Reference in New Issue
Block a user