From 1c858c83501be726a38b826b6b1544416b7f0a56 Mon Sep 17 00:00:00 2001 From: Kars Barendrecht Date: Sat, 26 Jun 2021 22:14:03 +0200 Subject: [PATCH] Update installer.sh to wait on network connection after restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I had the same problem as some others, and hacked away at this solution for some time. - Typing `stop` & `start` seems to wait for the process to come up in terminal, but not when it's in a bash script apparently. - Just waiting with `systemctl status NetworkManager` didn't do the trick, so I used ping. - The redirects (`2>` and `2&1>`) are not to echo the ping/grep outputs to stdout - put the sleep on 2 seconds, to not spam the chosen server I was wondering if I should use `www.home-assistant.io` as the ping target. 🤔 --- installer.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/installer.sh b/installer.sh index 7c95e8a..7a1c9c6 100644 --- a/installer.sh +++ b/installer.sh @@ -115,6 +115,9 @@ fi info "Restarting NetworkManager" systemctl restart "${SERVICE_NM}" +info "Waiting for network connection" +until ping -c 1 -n -w 1 www.docker.io 2> /dev/null | grep "bytes of data" 2&1> /dev/null; do sleep 2; done + # Parse command line parameters while [[ $# -gt 0 ]]; do arg="$1"