my-scripts/CheckMyIP.sh

30 lines
793 B
Bash
Raw Normal View History

2023-08-03 08:39:57 +00:00
#!/bin/bash
#
## Show my remote IP address
## (c) GPL by Ulf Bartolomäus ub1x@gmx.net
VERSION="Version 0.1.0 from 03.08.2023"
## Version info
# 0.1.0
# Initial VERSION
## Variables/Constants
BaseName="$( basename $0 .sh )" # BaseName einmal ermitteln
## Aufräumfunktion bei ungeplanter Beendung
MyCleanup () {
echo -e "\n\t\*****t$(date +%F_%T) at <$(hostname)>: stopped ****"
exit 10;
}
## Define cleanup function as default if a (specific) trap is generated
trap MyCleanup SIGHUP SIGINT SIGPIPE SIGTERM
if [ -x $(which curl) ] ; then
MyIP4=$(curl -4 ifconfig.co 2> /dev/null || echo "n/a")
MyIP6=$(curl -6 ifconfig.co 2> /dev/null || echo "n/a")
echo -e "${MyIP4} / ${MyIP6}"
else
echo -e "\n\t\*****t$(date +%F_%T) at <$(hostname)>: please install 'curl' ****"
fi