B.5. Avancerede indstillinger

B.5.1. Kørsel af tilpassede kommandoer under installationen

En meget funktionsrig og fleksibel valgmulighed tilbudt af værktøjerne til forhåndskonfiguration er muligheden for at afvikle kommandoer eller skripter på bestemte steder under installationen.

When the filesystem of the target system is mounted, it is available in /target. If an installation CD/DVD is used, when it is mounted it is available in /cdrom.

# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.

# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
#d-i partman/early_command \
#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh

B.5.2. Brug af forhåndskonfiguration til at ændre standardværdier

It is possible to use preseeding to change the default answer for a question, but still have the question asked. To do this the seen flag must be reset to false after setting the value for a question.

d-i foo/bar string value
d-i foo/bar seen false

The same effect can be achieved for all questions by setting the parameter preseed/interactive=true at the boot prompt. This can also be useful for testing or debugging your preconfiguration file.

Note that the d-i owner should only be used for variables used in the installer itself. For variables belonging to packages installed on the target system, you should use the name of that package instead. See the footnote to Afsnit B.2.2, “Brug af opstartsparametre til at forhåndskonfigurere spørgsmål”.

If you are preseeding using boot parameters, you can make the installer ask the corresponding question by using the ?= operator, i.e. foo/bar?=value (or owner:foo/bar?=value). This will of course only have effect for parameters that correspond to questions that are actually displayed during an installation and not for internal parameters.

For yderligere fejlsøgningsinformation bruges opstarstparameteren DEBCONF_DEBUG=5. Dette vil medføre at debconf udskriver langt flere detaljer om den nuværende opsætning af hver variabel og om dens status igennem hver pakkes installationsskripter.

B.5.3. Kædeindlæsning af forhåndskonfigurerede filer

Det er muligt at inkludere andre forhåndskonfigurationsfiler fra en forhåndskonfigurationsfil. Enhver indstilling i disse filer vil overskrive eksisterende indstillinger fra filer indlæst tidligere. Dette gør det muligt at placere, for eksempel, generelle netværksindstililnger for din placering i en fil og mere specifikke indstillinger for bestemte konfigurationer i andre filer.

# Mere end en fil kan angives, adskilt af mellemrum; alle vil blive
# indlæst. De inkluderede filer kan have egne preseed/include-direktiver.
# Bemærk at hvis filnavne er relative, så tages de fra den samme mappe
# som forhåndskonfigurationsfilen, som inkluderer dem.
#d-i preseed/include string x.cfg

# Installationsprogrammet kan valgfrit verificere kontrolsummer for filer
# til forhåndskonfiguration. I øjeblikket er kun md5sums understøttet, angiv
# md5sums i den samme rækkefølge som listen med filer til inklusion.
#d-i preseed/include/checksum string 5da499872becccfeda2c4872f9171c3d

# Mere fleksibelt, så afvikler dette en skalkommando og hvis den viser navnene
# på forhåndskonfigurationsfiler, så inkluder disse filer.
#d-i preseed/include_command \
#      string if [ "`hostname`" = bob ]; then echo bob.cfg; fi

# Mest fleksibelt, så hentes her et program der afvikles. Programmet
# kan bruge kommandoer såsom debconf-set til at manipulere debconf-databasen.
# Mere end et skript kan angives, adskilt af mellemrum. Bemærk at hvis
# filnavnene er relative, så tages de fra den samme mappe som 
# forhåndskonfigurationsfilen, som afvikler dem.
#d-i preseed/run string foo.sh

Det er også muligt at kædeindlæse (chainload) fra initrd- eller filforhåndskonfigurationsfasen, til netværksforhåndskonfiguration ved at angive preseed/url i de tidligere filer. Dette vil medføre at netværksforhåndskonfiguration udføres når netværket startes op. Du skal være omhyggelig når dette udføres, da der vil være to distinkte kørsler ved forhåndskonfiguration, hvilket for eksempel betyder at du får en anden chance for at afvikle kommandoen preseed/early, den anden sker efter at netværket er oppe.