Sunday, May 5, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 901  / 1 Year 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, 1 Year  [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
tersle questions
Sat, Oct 23, 21, 00:33, 3 Years ago
Sat, Nov 20, 21, 09:58, 3 Years ago
Sun, Apr 17, 22, 23:01, 2 Years ago
Thu, May 11, 23, 22:57, 1 Year ago
;