Pre-loading debconf values for easy installation

Debian’s configuration management might take some getting used to, but after you learn your way around /etc/{default,init.d,} it makes good sense.

Now when you have to do the same thing over and over again (ever said yes 25 times to Sun’s java license?), or you find that after a dist-upgrade your ldap configurations are gone because you pressed ‘enter’ one too many times…; you could either keep lots of tarballs or digg deeper. The latter could be done with debconf. 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.

You can set those values yourself quite easily, once you know how.

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.

You have to find out the values first. I usually check out my own base-line installation and then search a bit in newsgroups and forums for finer details and tuning.

For example, you want to pre-accept Sun’s DLJ java license:

# debconf-get-selections|grep java
sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true

You can now script that installation like so, copying the value from line #3 into a small script (You could do this in a one-liner as well, but since we are scripting anyway) :
echo -n Will now install jre, silently...
echo "sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true" | debconf-set-selections
apt-get -qq -y install sun-java6-jre
echo done.
exit 0

White space is ofcourse important in line 3 but tabs work as well as spaces.

debconf-set-selections should always be there. To get debconf-get-selections on your master-install you will need the debconf-utils package (at least on ubuntu hardy and up and debian etch).
Both tools need to be run as root, so be careful! You can imagine you can ruin a perfectly good install to beyond repair!
I suggest something like: # debconf-get-selections > debconf-selections-backup-`date +%Y%m%d`as backup-measure before trying.

Bonus points: now you know why Ubuntu is ‘easy’ and debian is not!

1 thought on “Pre-loading debconf values for easy installation

  1. Pingback: Setting up a WordPress development environment with Vagrant | caffeine to code

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>