B.5. 高级选项

B.5.1. 安装过程中运行用户命令


# 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 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. 使用预置修改默认值

也可以使用预置在修改问题的默认答案同时仍会有问题提出。要这样做,需要在给问题设定值以后,seen 旗标必须重置为 “false”。

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

要对所有问题达到同样效果,可以通过在启动引导符后面设置 preseed/interactive=true。这对于测试和调试您的预置文件很有帮助。如果使用引导参数预置,您可以通过 “?=” 操作符让安装程序询问相关的问题,例如,foo/bar?=value。当然,这只会影响问题对应的参数,它们是安装时显示出来的,而不是“内部的”参数。

B.5.3. 预置文件链


# More than one file can be listed, separated by spaces; all will be
# loaded. The included files can have preseed/include directives of their
# own as well. Note that if the filenames are relative, they are taken from
# the same directory as the preconfiguration file that includes them.
#d-i preseed/include string x.cfg

# The installer can optionally verify checksums of preconfiguration files
# before using them. Currently only md5sums are supported, list the md5sums
# in the same order as the list of files to include.
#d-i preseed/include/checksum string 5da499872becccfeda2c4872f9171c3d

# More flexibly, this runs a shell command and if it outputs the names of
# preconfiguration files, includes those files. 
#d-i preseed/include_command \
#      string echo if [ "`hostname`" = bob ]; then echo bob.cfg; fi

# Most flexibly of all, this downloads a program and runs it. The program
# can use commands such as debconf-set to manipulate the debconf database.
# More than one script can be listed, separated by spaces.
# Note that if the filenames are relative, they are taken from the same
# directory as the preconfiguration file that runs them.
#d-i preseed/run string foo.sh

也可以通过在前面设置 preseed/url 从 initrd 或者文件预置链载进入网络预置。这将使网络预置在网络连通时执行。您应该小心使用,因为这是两种预置,意味着您有机会执行 preseed/early 命令,第二个可以在网络连通后使用。