Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 !!!!

like image 903
RamNat Avatar asked Oct 17 '11 19:10

RamNat


2 Answers

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.

like image 135
pwan Avatar answered Sep 23 '22 03:09

pwan


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

like image 20
Ken Sharp Avatar answered Sep 20 '22 03:09

Ken Sharp