Last active
August 29, 2015 14:22
-
-
Save madpilot/d8e28d93a460a75478d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
getMyIP() { | |
local _ip _myip _line _nl=$'\n' | |
while IFS=$': \t' read -a _line ;do | |
[ -z "${_line%inet}" ] && | |
_ip=${_line[${#_line[1]}>4?1:2]} && | |
[ "${_ip#127.0.0.1}" ] && _myip=$_ip | |
done< <(LANG=C /sbin/ifconfig) | |
printf ${1+-v} $1 "%s${_nl:0:$[${#1}>0?0:1]}" $_myip | |
} | |
getMyIP IP | |
if [ -z $1 ]; then | |
echo "Usage: xip.io domainname" | |
else | |
echo "${1}.${IP}.xip.io" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment