虽然有动力让我的 Ubuntu kickstart 工作,但我找到了解决方案。 debconf-get-selection 的 --install 选项不起作用。您需要跳过它并仅使用裸 debconf-get-selection 来获取 debconf-set-selection 的列表。
在“apt install postfix”之后的全新安装中,我得到了这个列表:
root@pzi-ub-1:~# debconf-get-selections | grep postfix
postfix postfix/main_mailer_type select Internet with smarthost
postfix postfix/recipient_delim string +
postfix postfix/relay_restrictions_warning boolean
postfix postfix/mydomain_warning boolean
postfix postfix/not_configured error
postfix postfix/retry_upgrade_warning boolean
postfix postfix/mailname string pzi-ub-1.foobar.com
postfix postfix/chattr boolean false
postfix postfix/destinations string pzi-ub-1.foobar.com, $myhostname, pzi-ub-1, localhost.localdomain, localhost
postfix postfix/relayhost string pzi-gw-1.foobar.com
postfix postfix/procmail boolean true
postfix postfix/compat_conversion_warning boolean true
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
postfix postfix/sqlite_warning boolean
postfix postfix/kernel_version_warning boolean
postfix postfix/tlsmgr_upgrade_warning boolean
postfix postfix/mailbox_limit string 0
postfix postfix/dynamicmaps_conversion_warning boolean
postfix postfix/rfc1035_violation boolean false
postfix postfix/protocols select all
postfix postfix/main_cf_conversion_warning boolean true
postfix postfix/root_address string
postfix postfix/bad_recipient_delimiter error
为了编译预种子列表,我修剪了没有值的选项(安装程序没有要求的选项)并创建了这个脚本,我从 kickstart 的 %post 部分调用:
pzi@pzi-gw-1:~/Dropbox/notes/ks/post/ub$ cat mail
set -x
# x=mail; cd /var/tmp; wget http://gw/ks/post/ub/$x -O $x; sh ./$x
#
# ref: http://blog.delgurth.com/2009/01/19/pre-loading-debconf-values-for-easy-installation/
d=`grep search /etc/resolv.conf | sed 's/search //'`
hostname=`hostname`
fqdn=$hostname.$d
cat<<EOF | debconf-set-selections
postfix postfix/main_mailer_type select Internet with smarthost
postfix postfix/recipient_delim string +
postfix postfix/mailname string $fqdn
postfix postfix/chattr boolean false
postfix postfix/destinations string $fqdn, \$myhostname, $hostname, localhost.localdomain, localhost
postfix postfix/relayhost string mailhost.foobar.com
postfix postfix/procmail boolean true
postfix postfix/compat_conversion_warning boolean true
postfix postfix/mynetworks string 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
postfix postfix/mailbox_limit string 0
postfix postfix/rfc1035_violation boolean false
postfix postfix/protocols select all
postfix postfix/main_cf_conversion_warning boolean true
postfix postfix/root_address string
EOF
debconf-get-selections | grep postfix
apt-get -qq -y install postfix
这里是该邮件脚本的 kickstart 的 %post 部分:
%post --interpreter=/bin/bash
exec > /root/post.log 2>&1
set -x
scripts="
autofs
rootssh
users
sudo
mail
"
for x in $scripts; do
wget http://gw/ks/post/ub/$x -O $x; sh ./$x
done