diff options
author | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-20 19:37:16 (GMT) |
---|---|---|
committer | Katze Miau <miaukatzemiau@priveasy.de> | 2011-12-20 19:37:16 (GMT) |
commit | bd1376e986bf8c6bb54741ab75b92d99b48c8339 (patch) | |
tree | cd1ee663f0d4804d42e979aa8baa731fdd21719b | |
parent | a823579c130a7ff245f4df4b44b6443719a642f4 (diff) |
test if interface is up during /sbin/test_connectivity
Check if the interface is running before trying to ping. This reduces
the execution time of test_connectivity in common non-gateway
deployments.
-rwxr-xr-x | files/common/sbin/test_connectivity | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/files/common/sbin/test_connectivity b/files/common/sbin/test_connectivity index 9173cca..a8fe810 100755 --- a/files/common/sbin/test_connectivity +++ b/files/common/sbin/test_connectivity @@ -3,6 +3,10 @@ TestHosts="4.2.2.4 8.8.8.8" PingTrials=2 +iftest () { + ifconfig $1 2>/dev/null | grep -q RUNNING +} + pingtest () { # TODO: replace with something parallel for i in $(seq 1 $PingTrials); do @@ -17,10 +21,10 @@ pingtest () { case "$1" in internet) - pingtest eth1 $TestHosts + iftest eth1 && pingtest eth1 $TestHosts ;; vpn) - pingtest tun0 $TestHosts + iftest tun0 && pingtest tun0 $TestHosts ;; *) echo "Usage: |