9月18日 PXE一键安装centos7系统脚本

[root@centos7 app]#cat pxe.sh 
#!/bin/bash
#
#配置静态ip
cat > /etc/sysconfig/network-scripts/ifcfg-ens33 </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 </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<

你可能感兴趣的:(9月18日 PXE一键安装centos7系统脚本)