2

I am looking to automate some package installations via bash script; they will be installed to a pre-existing chroot'd filesystem. Some of the packages however involve interactive user input (i.e. ddclient asks to select a dynamic DNS service provider), which I haven't been able to automate as easily.

debconf preseeding seems to be the most common way to automate interactive package installations, but all the examples I've read imply that it's for an entire Debian installation rather than just individual packages.

I've been following this How to automate interactive Debian package installations but it doesn't really explain the specifics.

Thanks in advance!

3

Short of using a “proper” deployment and configuration management tool such as Ansible or Salt, debconf preseeding can be perfectly sufficient for pre-configuring Debian packages. It’s not at all limited to full blown installations; it can be applied to any number of packages.

The simplest way to get started with it is to manually configure the packages you want to install, by installing the package and answering the questions. Then run debconf-get-selections (from the debconf-utils package); that will list all the settings that are stored, including those for the packages you just installed, along with the question text in comments — so you can easily find the questions you want to preseed. The format is

<package> <debconf key> <type> <value>

For example

# System's default paper size:
# Choices: letter, a4, note, legal, executive, halfletter, halfexecutive, 11x17, statement, folio, quarto, 10x14, ledger, tabloid, a0, a1, a2, a3, a5, a6, a7, a8, a9, a10, b0, b1, b2, b3, b4, b5, c5, DL, Comm10, Monarch, archE, archD, archC, archB, archA, flsa, flse, csheet, dsheet, esheet
libpaper1       libpaper/defaultpaper   select  a4

Store the settings you want to preseed in a file, then run debconf-set-selections (in the debconf package) on the target system, either with the file available locally and named as the first argument, or its contents piped:

cat preseed-file | ssh remotehost debconf-set-selections

Do this before installing the packages on the target system.

  • thanks! This is exactly what I'm looking for. Hopefully it's cool if I try it out and reply if I encounter any issues. – kapkong Jun 14 '18 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.