BlameTheNetwork / NetPi

NetPi Network Analyzer based on Raspberry Pi b+/2 hardware
161 stars 44 forks source link

Feature: netwake use default interface automatically #3

Open akhepcat opened 9 years ago

akhepcat commented 9 years ago
echo *****************************
echo  MINIMIZE THIS ACTIVE PING 
echo   NetPi KEEPALIVE RUNNING! 
echo *****************************
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
BlameTheNetwork commented 9 years ago

Good call! Pinging if nothing is active doesn't do much good, you are correct. I pushed your code and provided attribution to you as a comment. Thanks for the improvement! I'll roll it into the next IMG version.