在 Ubuntu 上自动安装 postfix

sut*_*tch 74 automation ubuntu postfix installation apt

我的系统配置脚本执行“apt-get install -y postfix”。不幸的是,当 postfix 安装程序显示配置屏幕时,脚本会停止。有没有一种方法可以强制 postfix 在安装过程中使用默认值,以便自动化脚本可以持续到最后?

postfix 安装程序是否可能会检查 /etc/postfix 中的现有配置,如果存在,不要用配置屏幕打扰用户?

rap*_*ink 98

您可以为此使用预播种,debconf-set-selections在安装包之前使用命令预先回答 debconf 提出的问题。

例如:

debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
apt-get install --assume-yes postfix
Run Code Online (Sandbox Code Playgroud)

  • beporter,显然是:“无配置”、“互联网站点”、“带智能主机的互联网”、“卫星系统”、“仅限本地”,但似乎互联网站点通常是大多数人的最佳选择:https://bugs。 debian.org/cgi-bin/bugreport.cgi?bug=450787 (3认同)
  • 有人能解释一下我们如何为其他包获取这个字符串吗?(在我的例子中是 kerberos):“postfix postfix/mailname string your.hostname.com”我的意思是,第一个“postfix”是什么,第二个“postfix/”是什么,然后是“mailname”等等......哪里可以我的包裹里有这些字符串吗? (2认同)
  • 我发现 [这些都是来自 Ubuntu 20.04 中`debconf-get-selections` 的后缀设置](https://gist.github.com/gene1wood/e4dd448513cb425b5ec398f95cda2462) (2认同)

Dav*_*man 30

如果你想在全球范围内这样做:

dpkg-reconfigure debconf
Run Code Online (Sandbox Code Playgroud)

然后将其配置为“非交互式

如果您只想将其用于单次安装运行:

DEBIAN_FRONTEND=noninteractive apt-get install PACKAGE
Run Code Online (Sandbox Code Playgroud)

  • 您还可以执行 `export DEBIAN_FRONTEND=noninteractive` 以无人值守的方式全局设置它。 (2认同)