The answer by swill is not how it is done properly. If you want unattended/scripted dpkg configuration of packages, then you want to use the debconf preseeding mechanism.
In your case this means that you have to do the following:
-
set the following environment variables to avoid that debconf tries to ask the user any questions:
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
-
then preseed debconf with the following preseed.txt file (or whatever other settings you desire):
tzdata tzdata/Areas select Europe tzdata tzdata/Zones/Europe select Berlin
-
you set the above preseed file by running:
debconf-set-selections /your/preseed.txt
-
you can now either install tzdata (if it is not installed yet) via
apt
or rundpkg-reconfigure
. In the end, tzdata will be set up according to what you specified in your debconf preseed file.
Remember that you can automate lots more using debconf preseeding. For example in my preseeds I always set:
locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
locales locales/default_environment_locale select en_US.UTF-8
You can always inspect the debconf settings of your current system by running debconf-get-selections
. The output should give you some idea of how much of the system configuration you are able to automate using debconf preseeding.