debcnof
is a configuration management tool.deb
packages are stored in debconf
sudo
1sudo apt install debconf-utils
2
3# get configurable values for a package
4sudo debconf-get-selections | grep mysql
5
6# set values
7echo "set mysql-server/root_password YOURPASSWORD" | debconf-communicate
8# sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password YOURPASSWORD"
9# echo 'mysql-server mysql-server/root_password password YOURPASSWORD' | debconf-set-selections
10
11# show the list of debconf values configured for a package
12debconf-show phpmyadmin
debconf
is a configuration management tool for Debain. It let’s you pre-load configurations, meaning you set configuration options before instaling a package. The major benefit of this is during scripting, you can pre-configure the values via debconf-set-selections
and avoid entering values in the prompt, getting a non-interactive install.
Debconf keeps all answers to questions packages can ask during installation, both the ones you gave yourself and the implied or low-priority ones chosen by the packager.
When using .deb-packages you’re used to getting asked about licenses, values, locations, downloads etc. All these are stored in debconf. You can preload those answers before so they won’t get asked during installation (a silent, scriptable, install) or to “steer” the package into your desired config-direction.
The only issue is figuring out what the selections
mean. For example, if you have gone through the install process of PHPMyAdmin a few times, you might be able to figure out what the five different password selections correspond to.
1# install debconf-utils to get `debconf-get-selections`
2sudo apt install debconf-utils
1sudo debconf-get-selections | grep mysql
1phpmyadmin phpmyadmin/mysql/app-pass password
2mysql-server-5.7 mysql-server/root_password_again password
3dbconfig-common dbconfig-common/mysql/admin-pass password
4dbconfig-common dbconfig-common/mysql/app-pass password
5phpmyadmin phpmyadmin/mysql/admin-pass password
6mysql-server-5.7 mysql-server/root_password password
7mysql-server-5.7 mysql-server-5.7/really_downgrade boolean false
8phpmyadmin phpmyadmin/mysql/method select Unix socket
9dbconfig-common dbconfig-common/mysql/admin-user string
10dbconfig-common dbconfig-common/mysql/method select Unix socket
11phpmyadmin phpmyadmin/database-type select mysql
12mysql-server-5.7 mysql-server/password_mismatch error
13mysql-server-5.7 mysql-server/no_upgrade_when_using_ndb error
14phpmyadmin phpmyadmin/mysql/admin-user string debian-sys-maint
15mysql-server-5.7 mysql-server-5.7/nis_warning note
16mysql-server-5.7 mysql-server-5.7/postrm_remove_databases boolean false
17mysql-server-5.7 mysql-server-5.7/start_on_boot boolean true
1sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password YOURPASSWORD"
2# OR
3echo 'mysql-server mysql-server/root_password password YOURPASSWORD' | debconf-set-selections
4# OR
5echo "set mysql-server/root_password YOURPASSWORD" | debconf-communicate
Show the list of debconf values that a package has stored
1# debconf-show packagename
2debconf-show phpmyadmin
1 phpmyadmin/password-confirm: (password omitted)
2 phpmyadmin/app-password-confirm: (password omitted)
3 phpmyadmin/setup-password: (password omitted)
4 phpmyadmin/mysql/app-pass: (password omitted)
5 phpmyadmin/mysql/admin-pass: (password omitted)
6 phpmyadmin/remote/host: localhost
7 phpmyadmin/upgrade-backup: true
8 phpmyadmin/dbconfig-upgrade: true
9 phpmyadmin/dbconfig-reinstall: false
10 phpmyadmin/db/dbname: phpmyadmin
11 phpmyadmin/passwords-do-not-match:
12* phpmyadmin/mysql/admin-user: debian-sys-maint
13 phpmyadmin/internal/reconfiguring: false
14 phpmyadmin/database-type: mysql
15 phpmyadmin/setup-username: admin
16 phpmyadmin/missing-db-package-error: abort
17 phpmyadmin/remove-error: abort
18 phpmyadmin/upgrade-error: abort
19 phpmyadmin/install-error: abort
20 phpmyadmin/dbconfig-remove: true
21 phpmyadmin/remote/port:
22 phpmyadmin/purge: false
23* phpmyadmin/reconfigure-webserver: apache2
24 phpmyadmin/db/app-user: phpmyadmin
25 phpmyadmin/internal/skip-preseed: false
26 phpmyadmin/mysql/method: Unix socket
27* phpmyadmin/dbconfig-install: true
28 phpmyadmin/remote/newhost:
to query the current value of an option in the debconf database
1echo "get packagename/pgsql/app-pass" | debconf-communicate
and to change that value
1echo "set packagename/pgsql/app-pass password1" | debconf-communicate
1debconf-get-selections | grep application > file
2# and edit the file, then use
3
4debconf-set-selections < file
5# to load the changed settings.
1debconf-get-selections > debconf-selections-backup-`date +%Y%m%d`