How to prevent prompt that ask to restart services when installing libpq-dev

Set the environment variable DEBIAN_FRONTEND=noninteractive.

For example:

export DEBIAN_FRONTEND=noninteractive
apt-get install -y libpq-dev

This will make apt-get select the default options.


You should be able to achieve this using debconf-set-selections. From the man page:

debconf-set-selections can be used to pre-seed the debconf database
with answers, or to change answers in the database. Each question will
be marked as seen to prevent debconf from asking the question
interactively.

In order to determine the required input to debconf-set-selections if unknown, you can answer the prompt manually and then inspect the debconf database to find the correct value. To do this, install debconf-utils:

sudo apt-get -y install debconf-utils

which provides the debconf-get-selections command. Then:

sudo debconf-get-selections | grep libssl1.0.0:amd64

to check the values in the database. On my system (Ubuntu, but Debian should be similar) I am not prompted when I apt-get install libpq-dev, and I have this entry:

libssl1.0.0:amd64   libssl1.0.0/restart-services     string

so you should be able to use:

echo 'libssl1.0.0:amd64 libssl1.0.0/restart-services string' | sudo debconf-set-selections

to set the list of services to restart when upgrading libssl to 'none'.

Under Debian, there should be more information about valid values for this line in the questions.dat file under /var/lib/cdebconf. See https://www.debian.org/releases/stable/i386/apbs03.html.en for more details.


I think the existing answers may be a bit old. The following worked for me recently.

To see the settings for a package

sudo debconf-show <package-name>

E.G:

$ sudo debconf-show libssl1.1 
  libssl1.1/restart-services:
  libssl1.1/restart-failed:
* libraries/restart-without-asking: false

To change the setting

echo '<package-and-setting-string>' | sudo debconf-set-selections

E.G

echo 'libssl1.1 libraries/restart-without-asking boolean true' | sudo debconf-set-selections

Bonus tip, to set this setting for all packages use '*' in place of the package name.

E.G

echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections