Скрипт за IP адресою, визначає часовий пояс.
ip-timezone-info.sh
ip-timezone-info.sh
!/bin/bash
IP=$1
if [ -z "${IP}" ];then
echo "-- Missed paramter of IP"
exit
fi
function install()
{
howinstalled=$(apt list --installed 2>/dev/null | grep "^$1" | wc -l)
if [ "${howinstalled}" -lt 1 ] ;then
echo !!!!!!!!! MISSED FILE "$1", please install it : sudo apt install $1
sudo apt-get install $1
#exit
fi
}
install mmdb-bin
TZCity=$(mmdblookup --file GeoLite2-City.mmdb --ip ${IP} location time_zone |\
awk 'match( $0, /"([a-z|A-Z|/]*)"/ ,arr ) { print arr[1] }' )
TZone=$(TZ=${TZCity} date +%z)
echo "${TZCity} GMT${TZone%??}"