[root@centos7 app]#cat pxe.sh
#!/bin/bash
#
#配置静态ip
cat > /etc/sysconfig/network-scripts/ifcfg-ens33 <<end
DEVICE=ens33
IPADDR=192.168.25.21
PREFIX=24
end
systemctl restart network
echo "ip is finished"
#关闭防火墙
systemctl disabled firewalld &>/dev/null
systemctl stop firewalld &>/dev/null
iptables -F
echo "iptables is stop"
#关闭selinux
setenforce 0
sed -i '/SELINUX=/cSELINUX=disabled' /etc/selinux/config
echo "selinux is stop"
#安装软件包
yum -y -q install httpd tftp-server dhcp syslinux &>/dev/null
echo "httpd dhcp tftp syslinux is installed"
#配置文件共享服务和yum源
systemctl enable httpd &>/dev/null
systemctl start httpd &>/dev/null
mkdir /var/www/html/centos7
mount /dev/sr0 /var/www/html/centos7 &>/dev/null
echo "yum is finished"
#准备kickstart文件
mkdir /var/www/html/ksdir
install -m 644 /app/ks7.cfg /var/www/html/ksdir
echo "ks is finished"
#开启tftp服务
systemctl enable tftp.socket &>/dev/null
systemctl start tftp.socket &>/dev/null
echo "tftp is start"
#配置dhcp服务
cat > /etc/dhcp/dhcpd.conf <<end
subnet 192.168.25.0 netmask 255.255.255.0{
range 192.168.25.30 192.168.25.100;
next-server 192.168.25.21;
filename "pxelinux.0";
}
end
systemctl enable dhcpd &>/dev/null
systemctl start dhcpd &>/dev/null
echo "dhcp is finished"
#准备PXE相关文件
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
echo "PXE is finished"
#制作启动菜单
cat >/var/lib/tftpboot/pxelinux.cfg/default<<end
default menu.c32
timeout 600
menu title CentOS7 Linux PXE Install
label PXE centos7
menu label ^PXE Install CentOS Linux 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.25.21/ksdir/ks7.cfg
label manual
menu label ^Manual Install CentOS Linux 7
kernel vmlinuz
append initrd=initrd.img inst.repo=http://192.168.25.21/centos7
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
menu end
end
9月18日 PXE一键安装centos7系统脚本
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...