Uma poderosa e flexível opção oferecida pelas ferramentas de pré-configuração é a opção de executar comandos ou scripts em certos pontos da instalação.
# 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
É possível usar a pré-configuração para mudar a resposta padrão para uma questão, mas ainda ter a pergunta sendo feita. Para fazer isso a “flag” seen deve ser alterada para “false” após definir um valor para a questão.
d-i foo/bar string value d-i foo/bar seen false
O mesmo efeito pode ser alcançado para todas as
perguntas definindo o parâmetro
preseed/interactive=true
pela linha de comando
na inicialização. Isso também pode ser útil para testar ou depurar seu
arquivo de pré-configuração.
Note que o dono “d-i” só deveria ser usado por variáveis usadas no próprio instalador. Para variáveis pertencendo a pacotes instalados no sistema alvo, você deveria usar o nome do pacote. Veja a nota de rodapé para Seção B.2.2, “Usando parâmetros de inicialização para pré-configurar questões”.
Se você está fazendo a pré-configuração pelos parâmetros na inicialização,
você pode fazer com que o instalador faça a pergunta correspondente usando o
operador “?=”, i.e.
(ou foo
/bar
?=valor
).
Isso, claro, irá apenas ter efeito para parâmetros que correspondem às
perguntas que são realmente exibidas durante uma instalação e não para
parâmetros “internos”.
dono
:foo/bar
?=valor
É possível incluir outros arquivos de pré-configuração a partir de um arquivo de pré-configuração. Quaisquer configurações nesses arquivos irão sobrescrever configurações pré-existentes nos arquivos lidos anteriormente. Isto torna possível colocar, por exemplo, configurações gerais de rede para o seu local em um arquivo e configurações mais específicas em outro arquivo.
# 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 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
Também é possível inicializar a partir das fases initrd ou arquivo de pré-configuração, na pré-configuração da rede, definindo preseed/url nos arquivos anteriores. Isso fará com que a pré-configuração de rede seja executada quando a rede subir. Você precisa ser cuidadoso ao fazer isso, já que haverá duas execuções distintas na pré-configuração, o que significa por exemplo que você tem outra chance de executar o comando preseed/early, a segunda acontecendo após a rede subir.