0

I'd like to automate installing dnsmasq but when I apt-get install it, it prompts me to respond to a question due to an already existing /etc/dnsmasq.conf. In my case I do not want to replace it.

How can I automate this so that it doesn't block my apt-get install waiting for user input?

# apt-get install dnsmasq -y

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dnsmasq
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 16.2 kB of archives.
After this operation, 73.7 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 dnsmasq all 2.79-1 [16.2 kB]
Fetched 16.2 kB in 0s (37.2 kB/s)
Selecting previously unselected package dnsmasq.
(Reading database ... 24542 files and directories currently installed.)
Preparing to unpack .../dnsmasq_2.79-1_all.deb ...
Unpacking dnsmasq (2.79-1) ...
Setting up dnsmasq (2.79-1) ...

Configuration file '/etc/dnsmasq.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     : start a shell to examine the situation
 The default action is to keep your current version.
*** dnsmasq.conf (Y/I/N/O/D/Z) [default=N] ? 
Ryan R
  • 8,342
  • 15
  • 84
  • 111
  • Why do you need to install it so many times? May you want to move this file and paste it again after the installation. That could be done in a shell-script. – Charlie Jul 17 '18 at 17:20
  • It's only being installed once, but the config file exists already. I could delete the config manually but I'd like to make this more robust. – Ryan R Jul 17 '18 at 17:24
  • Possible duplicate of [How can I automate dpkg/apt-get?](https://stackoverflow.com/questions/702248/how-can-i-automate-dpkg-apt-get) – tripleee Jul 17 '18 at 17:40
  • See also https://stackoverflow.com/questions/4401431/disable-prompts-while-installing-a-debian-package – tripleee Jul 17 '18 at 17:47

1 Answers1

0

You can automate this by specifying the dpkg options like so:

$ apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install dnsmasq -y

This will keep the current config file.

Here is the very informative source: https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/

Ryan R
  • 8,342
  • 15
  • 84
  • 111