Is it possible to use the same tool to have Ubuntu guess what timezone it is currently in?
This article mentions the feature I'm looking for (just above the second pic): http://www.linuxforu.com/2012/05/ubuntu-12-04-precise-pangolin-review/
Is it possible to use the same tool to have Ubuntu guess what timezone it is currently in?
This article mentions the feature I'm looking for (just above the second pic): http://www.linuxforu.com/2012/05/ubuntu-12-04-precise-pangolin-review/
Ubuntu uses the ubuntu-geoip
package, which queries http://geoip.ubuntu.com/.
You can python-geoip
to achieve the same thing:
import GeoIP
geo = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE)
ip = '200.100.50.0'
print geo.country_code_by_addr(ip)
Sadly, it doesn't work with ipv6 yet.
wget -O - -q http://geoip.ubuntu.com/lookup
Jun 22, 2012 at 9:28
I decided to download the ubiquity source and dig for it. Greping timezone found the concerned lines, which issue the command:
wget -O - -q http://geoip.ubuntu.com/lookup
and parse the resulting xml.
Rather than load up python or something else, I just wrote a quick bash script that grabs the xml and yanks the timezone out with sed:
#!/bin/bash
# Fetch timezone from Ubuntu's geoip server
TZ=`wget -O - -q http://geoip.ubuntu.com/lookup | sed -n -e 's/.*<TimeZone>\(.*\)<\/TimeZone>.*/\1/p'`
# Set the current time
cp /usr/share/zoneinfo/$TZ /etc/localtime
CountryCode=AU
, CountryName=Australia
, TimeZone=None
. So it deduces the country successfully, but not the timezone within the country.
Oct 12, 2015 at 6:38
I believe that it uses your internet connection & ip address to find that information. When I have installed offline it always asks you to select a timezone.