dpkg-reconfigure tzdata 的非交互式方法 [英] Non-interactive method for dpkg-reconfigure tzdata

查看:24
本文介绍了dpkg-reconfigure tzdata 的非交互式方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次设置 Ubuntu 服务器时,我确保我 aptitude install tzdata,然后 dpkg-reconfigure tzdata 以便我正确设置我的时区.

When I first setup an Ubuntu server, I make sure I aptitude install tzdata, then dpkg-reconfigure tzdata so that I set my timezone properly.

我正在尝试使用脚本自动化我的服务器设置,并注意到这块是自动的,因为它需要用户干预的交互式会话.

I am trying to automate my server setup with a script, and noticed this piece sort of throws a wrench into it being automatic, as it requires an interactive session with user intervention.

有没有办法在没有交互的情况下使用 dpkg-reconfigure?

Is there a way to use dpkg-reconfigure without it being interactive?

推荐答案

swill 的答案不是如何正确完成.如果您想对软件包进行无人值守/脚本化的 dpkg 配置,那么您需要使用 debconf 预置机制.

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:

  • 设置以下环境变量以避免 debconf 试图询问用户任何问题:

  • set the following environment variables to avoid that debconf tries to ask the user any questions:

export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true

  • 然后使用以下 preseed.txt 文件(或您想要的任何其他设置)预置 debconf:

  • 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
    

  • 你通过运行来设置上面的 preseed 文件:

  • you set the above preseed file by running:

    debconf-set-selections /your/preseed.txt
    

  • 您现在可以通过 apt 安装 tzdata(如果尚未安装)或运行 dpkg-reconfigure.最后,tzdata 将根据您在 debconf preseed 文件中指定的内容进行设置.

  • you can now either install tzdata (if it is not installed yet) via apt or run dpkg-reconfigure. In the end, tzdata will be set up according to what you specified in your debconf preseed file.

    请记住,您可以使用 debconf 预置实现更多自动化.例如,在我的 preseed 中,我总是设置:

    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
    

    您始终可以通过运行 debconf-get-selections 来检查当前系统的 debconf 设置.输出应该让您了解使用 debconf 预置可以自动化多少系统配置.

    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.

    这篇关于dpkg-reconfigure tzdata 的非交互式方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆