View previous topic :: View next topic |
Author |
Message |
Nodlehs n00b
Joined: 21 May 2005 Posts: 3
|
Posted: Tue Feb 27, 2007 10:38 pm Post subject: DST problems, determine zoneinfo used from localtime |
|
|
Ok, I have probably 1000 systems with the /etc/localtime copied from the zoneinfo file, not symlinked. So when
our companies self installer asked the users for their timezone, it copied it over. Now with the DST changes, I
am looking for a way to push a script to automatically update their localtime file without having to do a brute
force md5sum match to all zoneinfo files to find the one used.
So in essence, is there anyway, short of a brute force match search, to determine which zoneinfo file was used
as the localtime file?
If there isn't, is there a potentially better way than taking an MD5 sum of the current localtime, then comparing
it against all zoneinfo files until I find a match, save the path, then overwriting the zoneinfo files with the update,
then copying over the new one from the saved path? Any assistance would be much appreciated.
Thanks
Nodlehs |
|
Back to top |
|
|
loki_val Retired Dev
Joined: 13 Nov 2006 Posts: 418 Location: Denmark
|
Posted: Wed Feb 28, 2007 8:07 am Post subject: |
|
|
Looking at my /etc/localtime, I see this at the end of it: Code: | CET-1CEST,M3.5.0,M10.5.0/3 | perhaps there is a description out there linking that identifier to a location? |
|
Back to top |
|
|
lyallp Veteran
Joined: 15 Jul 2004 Posts: 1579 Location: Adelaide/Australia
|
Posted: Wed Feb 28, 2007 9:56 am Post subject: |
|
|
Code: |
#!/bin/bash
zoneId="$(tail -n1 /etc/localtime)"
zoneFile="$(grep "${zoneId}" /usr/share/zoneinfo/*/* /usr/share/zoneinfo/*/*/* | head -n1"
if [ "${zoneFile}" != "" ]
# cp "${zoneFile}" /etc/localtime # Uncomment to copy over determined file.
ln -s "${zoneFile}" /etc/localtime.symlink
echo "Used ${zoneFile}"
fi
|
You may not end up with exactly the same city/area but you would end up with the same timezone, at least. _________________ ...Lyall |
|
Back to top |
|
|
loki_val Retired Dev
Joined: 13 Nov 2006 Posts: 418 Location: Denmark
|
Posted: Wed Feb 28, 2007 1:15 pm Post subject: |
|
|
Hmm... tyallp, Couldn't get that to work, for some reason. With md5sum, here's a oneliner: Code: | md5sum /usr/share/zoneinfo/*/*/* 2> /dev/null|grep `md5sum /etc/localtime|sed -e "s/\/.*//g"`|sed -e "s/.*\ //g" | This will output the file you need to copy. On my comp, here's the output: Code: | loki ~ # md5sum /usr/share/zoneinfo/*/*/* 2> /dev/null|grep `md5sum /etc/localtime|sed -e "s/\/.*//g"`|sed -e "s/.*\ //g"
/usr/share/zoneinfo/posix/Europe/Copenhagen | This could be extended trivially with xargs to actually copy the right zonefile to /etc/localtime.
You haven't told us how your setup is, ie -- do these comps have the new timezone data as well as the old, do they have portage installed, etc.
In the new baselayout, timezone is set by setting the TIMEZONE variable in /etc/conf.d/clock and emerging sys-libs/timezone-data. |
|
Back to top |
|
|
Nodlehs n00b
Joined: 21 May 2005 Posts: 3
|
Posted: Wed Feb 28, 2007 5:16 pm Post subject: |
|
|
First off, thanks much for the help guys.
peteralf wrote: |
You haven't told us how your setup is, ie -- do these comps have the new timezone data as well as the old, do they have portage installed, etc.
In the new baselayout, timezone is set by setting the TIMEZONE variable in /etc/conf.d/clock and emerging sys-libs/timezone-data. |
They don't have portage, a custom livecd was built, and a package was made stripping out all non necessary packages, no gcc, etc. All
updates are delivered through a daemon that connects to a central update server, which can deliver files to be copied over to our product
as well as system updates, scripts can be sent to run on updates. Essentially the user will click update in their web interface, their box
will download the files, a script would determine which timezone file is being used, updated system files copied over, then the script would
link the proper timezone file instead of copying it over, to make future updates easier. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|