#!/bin/dash
# Inspiration: http://murga-linux.com/puppy/viewtopic.php?t=117675

TMP=/tmp/ipinfo.$$
cat > $TMP << EOF
Local IP Address(es)
--------------------
$(
ifconfig | sed -n '/^[a-z].*:/ {s/:.*/:/; N; /inet /!d; s/:.*inet /: /; s/[ ]*netmask.*//; H}; ${x;s/^\n//;p}'
)

Remote IP address
-----------------
$(curl -s https://geoip.ubuntu.com/lookup | xml2 | sed 's|/Response/||; s/=/: /')
EOF

[ -z "$DISPLAY" ] && cat "$TMP" ||
Xdialog --fixed-font --title "Network Info" --no-cancel --editbox "$TMP" 16 48 2> /dev/null
rm -f $TMP
