How to make apt-get accept New config files in a unattended install of debian from Repo
Asked Answered
R

3

25

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. Is there any option that I can pass to apt-get/aptitude so that it accepts the new Config Files.

Basically I need a apt/aptitude equivalent of dpkg --force-confnew

I need to answer the following question posed while apt-get installation with a Y


Configuration file `/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

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

This is flagging an Error in installation when the installation is at the Config Interactive phase.

I am on Ubuntu 10.04 apt version: 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

Thanks Guys for your Help in advance !!!!

Ramiah answered 17/10, 2011 at 19:23 Comment(1)
serverfault.com/questions/48724/…Vargueno
T
11

I tried the suggestions in the other answers and discovered that it wasn't enough when trying to install the localepurge package.

After using debconf-set-selections to set what I needed, I had to use the following:

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. 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).

Tamer answered 21/1, 2014 at 11:4 Comment(0)
D
30

I think the apt-get command line you're looking for is

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

As for your sudo -S issue, maybe try adding some spaces around the '|' character. Is not, the question How to pass the password to su/sudo/ssh without overriding the TTY? may be useful.

Duron answered 7/11, 2011 at 0:43 Comment(1)
I had to add -y too. apt-get -o Dpkg::Options::="--force-confnew" install -y your-packagePartiality
T
11

I tried the suggestions in the other answers and discovered that it wasn't enough when trying to install the localepurge package.

After using debconf-set-selections to set what I needed, I had to use the following:

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. 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).

Tamer answered 21/1, 2014 at 11:4 Comment(0)
T
3

You can also have apt configured to do that by creating /etc/apt/apt.conf.d/local and adding:

Dpkg::Options {
   "--force-confdef";
   "--force-confold";
}
Thaddeusthaddus answered 2/5, 2017 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.