You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
deployment-iso/templates/scripts/includes/check-for-network

27 lines
541 B

#!/bin/bash
################################################################################
. /etc/grml/lsb-functions
if [ "$(id -ru)" -ne 0 ] ; then
echo "Error: please run this script with uid 0 (root)." >&2
exit 1
fi
einfon "Checking network status... "
STATUS="Offline"
EXIT_CODE=1
GW="$(route -n | awk '/^0\.0\.0\.0/{print $2}')"
GWDEV="$(route -n | awk '/^0\.0\.0\.0/{print $NF}')"
if ping -c 3 "${GW}" >/dev/null ; then
STATUS="Online (${GWDEV})"
EXIT_CODE=0
fi
printf "%s\n" "$STATUS"
eend $EXIT_CODE
exit $EXIT_CODE