#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$gAukPWdA$9KgCXs7IGuVPASkceRfjj0
# Use network installation
url --url="ftp://192.168.100.88/pub"
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx# Firewall configuration
firewall --enabled --http --ssh --ftp
# Network information
network --bootproto=dhcp --device=ens33
network --bootproto=dhcp --device=ens37
# Halt after installation
halt
# System timezone
timezone Africa/Abidjan
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1%post --interpreter=/bin/bash
#!/bin/sh
#获取网卡名称,保存到数组a中
a=(`ifconfig | grep ^[a-z] | awk -F: '{print $1}'`)
#获取IP地址,保存到数组b中
b=(`ifconfig | grep 'inet' | sed 's/^.*inet //g' | sed 's/ *netmask.*$//g'|grep -v inet6`)
#获取子网掩码,保存到数组c中
c=(`ifconfig | grep netmask |awk '{print $4}'`)
cd /etc/sysconfig/network-scripts
#修改网卡配置文件,设置静态IP地址
for ((i=0;i<${#a[@]};i++))
do
if [ ${a[$i]} != "lo" ];then
#将静态IP设置信息写入网卡配置文件
sed -i 's/dhcp/static/' ifcfg-${a[$i]}
sed -i '/IPADDR/d' ifcfg-${a[$i]}
sed -i '/NETMASK/d' ifcfg-${a[$i]}
echo "IPADDR=${b[$i]}">>ifcfg-${a[$i]}
echo "NETMASK=${c[$i]}">>ifcfg-${a[$i]}
fi
done
systemctl restart network
%end%packages
@^minimal
@core
vim
net-tools
%end
PXE批量安装Centos7,安装后脚本设置静态IP地址,应答文件
最新推荐文章于 2024-08-03 22:18:16 发布