Ubuntu dpkg,非交互式安装

我试图安装一堆.deb文件,而不必与他们进行交互。 例如MySQL服务器会提示input交互式菜单,在dpkg的configuration中inputpipe理密码。

我努力了。

export DEBIAN_FRONTEND=noninteractive && export DEBIAN_PRIORITY=critical && sudo /usr/bin/dpkg -i ./files/* 

我知道,我可以提取没有configuration的文件。 我正在尝试创build一个bash脚本来部署预先configuration了Apache,php,mySQL等默认安装的服务器。但是,这种“交互式安装”正在引发问题。

任何想法如何禁用它? 或工作?

谢谢

你在正确的轨道上。 你一定要使用DEBIAN_FRONTEND=noninteractive 。 对于不可忽视的关键问题,您将需要预先对debconf数据库进行必要的解答。 debconf手册页包含了关于如何完成这些的所有细节。

对于一般的非交互式前端,你可以尝试:

 sudo dpkg-reconfigure debconf -f noninteractive -p critical 

要configurationMySQL凭据,您可以使用服务器configuration文件 (例如~/.my.cnf ),例如:

 [client] user=root password=root 

要select一些特定的select,请使用debconf-set-selections ,例如:

 echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections 

这应该工作:

 $ pkgadd SOMEpkg << MYINPUT y some text /usr/local n password MYINPUT 

我不得不在上面的几行之间插入一些行,或者把它格式化为一行。 无论如何,您可以在复杂的安装过程中使用“script”命令保存您的input,然后将输出修改为脚本,以便后续安装( man script )自动执行。