附加安装后命令

附加安装后命令

我有这个预置文件。

debconf debconf/frontend select Noninteractive
choose-mirror-bin mirror/http/proxy string
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true

# Default user
d-i passwd/user-fullname string vagrant
d-i passwd/username string vagrant
d-i passwd/user-password password vagrant
d-i passwd/user-password-again password vagrant
d-i passwd/username string vagrant

# Minimum packages (see postinstall.sh)
d-i pkgsel/include string openssh-server
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i pkgsel/upgrade select none

d-i time/zone string UTC
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
tasksel tasksel/first multiselect standard, server

安装后,我希望系统转到此位置/etc/network/interfaces,然后添加此

auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

添加后,运行sudo ifup eth0。我可以使用 kickstart 文件执行此操作,方法是将其附加在末尾

%post
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOM
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=4a71392
DEVICE=eth0
ONBOOT=yes
IPADDR=9.1
PREFIX=22
GATEWAY=9.1
DNS1=9.1
DNS2=9.1
DOMAIN=host.com
EOM

sudo systemctl restart network



%end

我知道late command这相当于%post在预置文件中。我该如何使用它来实现上述目的?

答案1

你确实在寻找preseed/late_command

在预置的底部,添加类似

d-i preseed/late_command string \
    echo -e 'auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet static\n    address 10.0.0.100\n    netmask 255.255.255.0\n    gateway 10.0.0.1' >/target/etc/network/interfaces; \
    echo -e 'server pool.ntp.org' >/target/etc/ntp.conf

相关内容