From f7db085697c4f3e5cf3f3ae6b9862fcc7abf73d3 Mon Sep 17 00:00:00 2001 From: Mykola Malkov Date: Tue, 6 Nov 2018 10:53:16 +0200 Subject: [PATCH] TT#46784 Check several servers to get network status In some cases ICMP is blocked on a gateway. To get connectivity status (if the server is online) ping several servers: 1) gateway 2) deb.sipwise.com 3) dns server or 1.1.1.1 Based on the pull request https://github.com/sipwise/deployment-iso/pull/1/ Thanks: Isaac McDonald for the PR. Change-Id: Iebb31de8105e3b329bd0b8fc068abc9b55326ed8 --- templates/scripts/includes/check-for-network | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/scripts/includes/check-for-network b/templates/scripts/includes/check-for-network index a83e276..6a01c7e 100755 --- a/templates/scripts/includes/check-for-network +++ b/templates/scripts/includes/check-for-network @@ -15,8 +15,12 @@ EXIT_CODE=1 GW="$(route -n | awk '/^0\.0\.0\.0/{print $2}')" GWDEV="$(route -n | awk '/^0\.0\.0\.0/{print $NF}')" +SIPWISE_DEB='deb.sipwise.com' +DNS_SERVER="$( awk '/^nameserver/ {print $2; exit}' /etc/resolv.conf || true )" -if ping -c 3 "${GW}" >/dev/null ; then +if ping -c 3 "${GW}" >/dev/null \ + || ping -c 3 "${SIPWISE_DEB}" >/dev/null \ + || ping -c 3 "${DNS_SERVER:-1.1.1.1}" >/dev/null ; then STATUS="Online (${GWDEV})" EXIT_CODE=0 fi