When installing Debian, or any derivative such as e.g. Ubuntu on a computer, it is possible to use templates to automate the installation. Such templates are called preseed files and are explained in the Installation Guide.
Under the section Advanced options of the document linked above, one can learn about the possibility to run generic shell commands at a few places during the installation process. Namely at the start of installation, at the end of it and just before partitioning the disks. This is all great stuff, and these hooks provide the flexibility one needs.
Yet to gain the flexibility one wants, I've put the following lines in
scripting-flexibility.txt
. A file which of course needs to be sourced by the
main preseed file before those numbered commands can be used.
d-i preseed/early_command string for N in `seq 0 99`; \
do eval `/bin/debconf-get preseed/numbered_early_command_$N`; done; \
true
d-i partman/early_command string for N in `seq 0 99`; \
do eval `/bin/debconf-get partman/numbered_early_command_$N`; done; \
true
d-i preseed/late_command string for N in `seq 0 99`; \
do eval `/bin/debconf-get preseed/numbered_late_command_$N`; done; \
true
With the above, it is possible to use preseed/numbered_early_command_10
in
place of preseed/early_command
. Similarly partman/numbered_early_command_10
and preseed/numbered_late_command_10
extends their corresponding commands.
By using unique numbers for each numbered command invocation, it becomes possible to add commands in host specific preseed files, as well as in included reusable files, without the different files necessarily interfering with each other. It might be an idea to reserve defined intervals to different categories of tasks.
Please beware that some error handling is disabled by the trailing true
statements. I consider that to be an acceptable price to pay for the
functionality, but do feel free to adapt the preseed file to your needs.
My next blog post covers an example on how to use numbered commands with a pair of practical use cases.