I have already described how to copy answers to the configuration questions for Debian packages, but there is an easier way to read and insert new values into the debconf database.
You will need debconf-set-selections
on a target system on which you want to insert new values into the debconf database. It is provided by debconf
package, so it is installed by default.
$ dpkg-query -S /usr/bin/debconf-set-selections
debconf: /usr/bin/debconf-set-selections
You will need debconf-get-selections
on a source system on which you want to read values from the debconf database. It is provided by debconf-utils
package, so you need to install it manually.
$ dpkg-query -S /usr/bin/debconf-get-selections
debconf-utils: /usr/bin/debconf-get-selections
Install debconf-utils
package.
$ sudo apt-get install debconf-utils
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: debconf-utils 0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. Need to get 56.6 kB of archives. After this operation, 108 kB of additional disk space will be used. Get:1 http://ftp.task.gda.pl/debian stretch/main amd64 debconf-utils all 1.5.61 [56.6 kB] Fetched 56.6 kB in 0s (146 kB/s) Selecting previously unselected package debconf-utils. (Reading database ... 28000 files and directories currently installed.) Preparing to unpack .../debconf-utils_1.5.61_all.deb ... Unpacking debconf-utils (1.5.61) ... Setting up debconf-utils (1.5.61) ... Processing triggers for man-db (2.7.6.1-2) ...
Read values from the debconf database which applies to the iptables-persistent
package.
$ sudo debconf-get-selections | grep ^iptables-persistent
iptables-persistent iptables-persistent/autosave_v6 boolean true iptables-persistent iptables-persistent/autosave_v4 boolean true
Insert new values into the debconf database.
$ cat << EOF | sudo debconf-set-selections iptables-persistent iptables-persistent/autosave_v6 boolean true iptables-persistent iptables-persistent/autosave_v4 boolean false EOF
Verify contents of the debconf database.
$ sudo debconf-get-selections | grep ^iptables-persistent iptables-persistent iptables-persistent/autosave_v6 boolean true iptables-persistent iptables-persistent/autosave_v4 boolean false
It is as simple as that.