Refactor network connection test

This commit is contained in:
Manuel Thalmann 2024-07-14 21:37:39 +02:00
parent d0c8ef7a13
commit 355311425a

View file

@ -3,8 +3,14 @@ function waitNetwork -a witness
set -l timeout (math 10 \* 60) set -l timeout (math 10 \* 60)
set -l codeFile (mktemp) 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 [ -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' tmux new-session -d 'cat /etc/motd; echo "$(tput bold)Please establish an internet connection…$(tput sgr0)"; $SHELL'
fish (status filename) true & fish (status filename) true &
set -l pid "$last_pid" set -l pid "$last_pid"
@ -27,7 +33,7 @@ function waitNetwork -a witness
while true while true
set x (math $x + 1) set x (math $x + 1)
if systemctl --quiet is-active network-online.target if testNetwork
tmux kill-session &> /dev/null tmux kill-session &> /dev/null
break break
else else