changing timezone with dpkg-reconfigure tzdata and debconf-set-selections

Posted by Carlos Campderrós on Super User See other posts from Super User or by Carlos Campderrós
Published on 2012-11-02T10:45:17Z Indexed on 2012/11/02 11:04 UTC
Read the original article Hit count: 333

Filed under:
|
|
|

I want to set up a script that automatically changes the timezone on a machine (running ubuntu 11.10) and also sets the right values to the debconf database. I've tried the following, but it does not work (at the end, the current timezone remains unchanged, and if I run manually the dpkg-reconfigure tzdata command, the selected values are indeed the old ones):

#!/bin/sh -e
echo "tzdata    tzdata/Areas    select  Europe" | debconf-set-selections
echo "tzdata    tzdata/Zones/Europe select  Madrid" | debconf-set-selections
echo "tzdata    tzdata/Zones/America    select  " | debconf-set-selections
dpkg-reconfigure -f noninteractive tzdata

So, by now, I'm doing it messing with the files /etc/localtime and /etc/timezone directly, but I'd rather prefer the dpkg-reconfigure and debconf way.

© Super User or respective owner

Related posts about ubuntu

Related posts about debian