简体   繁体   English

如何让apt-get接受来自Repo的无人值守的debian安装中的新配置文件

[英]How to make apt-get accept New config files in a unattended install of debian from Repo

I am writing a script for a unattended install of a package that is in our Repo, It is a Software Package with one of the Debians marked config. 我正在编写一个脚本,用于无人值守安装我们的Repo中的软件包,它是一个软件包,其中一个Debian标记为config。 Is there any option that I can pass to apt-get/aptitude so that it accepts the new Config Files. 有没有我可以传递给apt-get / aptitude的选项,以便它接受新的配置文件。

Basically I need a apt/aptitude equivalent of dpkg --force-confnew 基本上我需要一个相当于dpkg --force-confnew的apt / aptitude

I need to answer the following question posed while apt-get installation with a Y 在使用Y进行apt-get安装时,我需要回答以下问题


Configuration file `/opt/application/conf/XXX.conf' 配置文件`/opt/application/conf/XXX.conf'

==> File on system created by you or by a script. ==>由您或脚本创建的系统上的文件。

==> File also in package provided by package maintainer. ==>文件也在包维护者提供的包中。

What would you like to do about it ? 你想做些什么? Your options are: 你的选择是:

Y or I  : install the package maintainer's version

N or O  : keep your currently-installed version

  D     : show the differences between the versions

  Z     : background this process to examine the 

The default action is to keep your current version. 默认操作是保留当前版本。


Additional Info: 附加信息:

Also,I am passing the sudo password in a pipe to execute the command 另外,我在管道中传递sudo密码来执行命令

echo "mysudopass"|sudo -S apt-get mypackage echo“mysudopass”| sudo -S apt-get mypackage

This is flagging an Error in installation when the installation is at the Config Interactive phase. 当安装位于Config Interactive阶段时,这会标记安装错误。

I am on Ubuntu 10.04 apt version: apt 0.7.25.3 我在Ubuntu 10.04 apt版本:apt 0.7.25.3

Why i cannotuse dpkg : These debians are to be installed from Repo and I dont have local debians on my machine 为什么我不能使用dpkg:这些debian将从Repo安装,我的机器上没有本地debian

Thanks Guys for your Help in advance !!!! 感谢大家提前帮助!!!!

I think the apt-get command line you're looking for is 我认为你正在寻找的apt-get命令行是

apt-get -o Dpkg::Options::="--force-confnew" install your-package

As for your sudo -S issue, maybe try adding some spaces around the '|' 至于你的sudo -S问题,也许可以尝试在'|'周围添加一些空格 character. 字符。 Is not, the question How to pass the password to su/sudo/ssh without overriding the TTY? 不是,问题如何在不覆盖TTY的情况下将密码传递给su / sudo / ssh? may be useful. 可能有用。

I tried the suggestions in the other answers and discovered that it wasn't enough when trying to install the localepurge package. 我尝试了其他答案中的建议,发现在尝试安装localepurge包时还不够。

After using debconf-set-selections to set what I needed, I had to use the following: 使用debconf-set-selections设置我需要的东西后,我不得不使用以下内容:

DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confnew" install localepurge

Only with the DEBIAN_FRONTEND environment variable set to noninteractive could I force localepurge to do what I had asked. 只有将DEBIAN_FRONTEND环境变量设置为非交互式,才能强制localepurge执行我所要求的操作。 This may be true of other packages. 其他包可能也是如此。

Of course with a script you could export the variable if you wanted to, but be aware that it could mess with other packages. 当然,如果您愿意,可以使用脚本导出变量,但要注意它可能会混乱其他包。 For example: 例如:

#!/bin/sh
export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confnew" install -y localepurge foo bar

Where the -y tells apt-get to stop asking questions (see the man page ). -y告诉apt-get停止提问(参见手册页 )。

You can also have apt configured to do that by creating /etc/apt/apt.conf.d/local and adding: 您也可以通过创建/etc/apt/apt.conf.d/local并添加以下apt配置:

Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM