32.8. Kickstart Examples


32.8.1. Set host name interactively during installation

The following example demonstrates how to interactively set the system's host name during installation. The %pre script asks to enter a host name for the installed system. The %post script configures the network according to the user's input.
%pre
chvt 3
exec </dev/tty3> /dev/tty3
clear
## Query for hostname, then write it to 'network' file
read -p "
What is my hostname (FQDN)? (This will be set on eth0)
" NAME /dev/tty3 2>&1
echo "NETWORKING=yes" > network
echo "HOSTNAME=${NAME}" >> network
echo "DEVICE=eth0" > ifcfg-eth0
echo "BOOTPROTO=dhcp" >> ifcfg-eth0
echo "ONBOOT=yes" >> ifcfg-eth0
echo "DHCP_HOSTNAME=${NAME} " >> ifcfg-eth0
cat ifcfg-eth0
chvt 1
exec < /dev/tty1 > /dev/tty1
%end

%post --nochroot
# bring in hostname collected from %pre, then source it
cp -Rvf network /mnt/sysimage/etc/sysconfig/network
# Set-up eth0 with hostname
cp ifcfg-eth0 /mnt/sysimage/etc/sysconfig/network-scripts/ifcfg-eth0
# force hostname change
/mnt/sysimage/bin/hostname $HOSTNAME
%end
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.