check_internet 598 B

12345678910111213141516171819
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2012, license GPL3 (/usr/share/doc/legal)
  3. #call from: /usr/sbin/delayedrun, quicksetup, ...
  4. #120331 ping -4 for ipv4, refer: http://murga-linux.com/puppy/viewtopic.php?p=616090#616090
  5. export LANG=C
  6. IFCONFIG="`ifconfig | grep '^[pwe]' | grep -v 'wmaster'`"
  7. [ ! "$IFCONFIG" ] && exit 1 #no network connection.
  8. ping -4 -c 1 8.8.8.8 #64.233.169.103 #google 111110 address no longer responding.
  9. [ $? -ne 0 ] && exit 2 #ip address not accessable.
  10. ping -4 -c 1 www.google.com
  11. [ $? -ne 0 ] && exit 3 #domain name address not accessable.
  12. exit 0 #success
  13. ###END###