Tuesday, May 14, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 904  / 2 Years ago, wed, november 23, 2022, 5:22:56

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/


More From » installation

 Answers
7

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

[#37375] Thursday, November 24, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tersle

Total Points: 342
Total Questions: 109
Total Answers: 99

Location: Kazakhstan
Member since Mon, Sep 26, 2022
2 Years ago
;