scripts

scripts to make my pc work
Index Commits Files Refs
gip/gip (514B)
   1 #!/bin/sh
   2 
   3 # gets information about a public ip address
   4 # usage: gip <PUBLIC IP>
   5 
   6 if [ "$#" -eq 1 ]; then
   7     if expr "$@": '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
   8         for i in 1 2 3 4; do
   9             if [ $(echo "$@" | cut -d. -f$i) -gt 255 ]; then
  10               echo "\"$@\" not an ip adress"
  11               exit 1
  12             fi
  13         done
  14         curl --silent https://ipinfo.io/$@ | sed -e 's/"\|,\|  \|}//g' -e '1d' -e '/readme/d'
  15     else
  16         echo "usage: gip <PUBLIC IP>"
  17         exit 1
  18     fi
  19 else
  20     echo "usage: gip <PUBLIC IP>"
  21     exit 1
  22 fi