Refactor network connection test

This commit is contained in:
Manuel Thalmann 2024-07-14 21:37:39 +02:00
parent abf19147bc
commit 2df5ecddcb

View file

@ -3,8 +3,14 @@ function waitNetwork -a witness
set -l timeout (math 10 \* 60)
set -l codeFile (mktemp)
function testNetwork
# Ping digitalcourage DNS server
# https://digitalcourage.de/
ping -q -c1 5.9.164.112 > /dev/null
end
if [ -z "$witness" ]
if not systemctl --quiet is-active network-online.target
if not testNetwork
tmux new-session -d 'cat /etc/motd; echo "$(tput bold)Please establish an internet connection…$(tput sgr0)"; $SHELL'
fish (status filename) true &
set -l pid "$last_pid"
@ -27,7 +33,7 @@ function waitNetwork -a witness
while true
set x (math $x + 1)
if systemctl --quiet is-active network-online.target
if testNetwork
tmux kill-session &> /dev/null
break
else