Permalink
Browse files

Update netwake.sh

  • Loading branch information...
BlameTheNetwork committed Mar 18, 2015
1 parent 3bf614f commit 5f2b175985e84173b5fe36555903bfc623c495c9
Showing with 10 additions and 1 deletion.
  1. +10 −1 Functions/netwake.sh
View
@@ -1,6 +1,15 @@
+# Script improved 3/18/15 as submitted by akhepcat.
+# Improvement uses default interface, and loops if no interfaces are available.
echo *****************************
echo MINIMIZE THIS ACTIVE PING
echo NetPi KEEPALIVE RUNNING!
echo *****************************
-gw="$(ip route show 0.0.0.0/0 dev wlan0 | cut -d\ -f3)"
+iface=$(awk 'BEGIN { IGNORECASE=1 } /^[a-z0-9]+[ \t]+00000000/ { print $1 }' /proc/net/route)
+if [ -z "$iface" ]
+then
+ echo "no active IPv4 interface"
+ sleep 4
+ exit 1
+fi
+gw="$(ip -4 route show route default dev $iface | cut -d\ -f3)"
ping $gw

0 comments on commit 5f2b175

Please sign in to comment.