Be achieved through the installation and configuration of DHCP, tftp-server, xinetd, httpd, syslinux batch install Linux system
1 #!/bin/bash 2 #检查环境 3 se_state=`getenforce` 4 if [ $se_state != "Disabled" ];then 5 setenforce 0 6 sed -i's/=enforcing/=disabled/g' /etc/selinux/config 7 fi 8 systemctl start firewalld 9 systemctl enable firewalld 10 #检查yum源 11 mo_point=`ls / |grep local_dvd` 12 if [ -z $mo_point ];then 13 mkdir /local_dvd 14 mount /dev/cdrom /local_dvd 15 echo "/dev/sr0 /local_dvd iso9660 default 0 0 " >> /etc/fstab 16 rm -rf /etc/yum.repos.d/*.repo 17 echo "[local] 18 name=local 19 baseurl=file:///local_dvd 20 enabled=1 21 gpgcheck=0" >> /etc/yum.repos.d/local.repo 22 yum clean all 23 yum repolist 24 fi 25 #安装服务 26 yum -y install dhcp tftp-server xinetd httpd syslinux 27 #配置DHCP 28 IP=`ifconfig |grep -w inet |grep broad |awk '{print $2}'` 29 NETM=`ifconfig |grep -w netmask |grep broad |awk '{print $4}'` 30 NETW=`echo $IP |awk -F. '{print $1"."$2"."$3}'` 31 echo "option domain-name \"example.org\"; 32 option domain-name-servers ns1.example.org, ns2.example.org; 33 default-lease-time 600; 34 max-lease-time 7200; 35 log-facility local7; 36 subnet $NETW.0 netmask $NETM { 37 range $NETW.10 $NETW.200; 38 option routers $IP; 39 filename \"pxelinux.0\"; 40 next-server $IP; 41 }" > /etc/dhcp/dhcpd.conf 42 #配置tftp 43 mkdir /tftpboot 44 sed -i '13s/\/var\/lib//g' /etc/xinetd.d/tftp 45 sed -i '14s/yes/no/g' /etc/xinetd.d/tftp 46 #Configuration httpd, mount the optical disc system 47 mkdir / var / WWW / HTML / http_iso 48 Mount / dev / CDROM / var / WWW / HTML / http_iso 49 echo " / dev / CDROM / var / WWW / HTML / ISO9660 default http_iso 0 0 " >> / etc / fstab 50 # copy tftp boot program to the next directory 51 is CP / var / WWW / HTML / http_iso / the isolinux / vmlinuz / tftpboot 52 is CP /var/www/html/http_iso/isolinux/initrd.img / tftpboot 53 is mkdir / tftpboot / the pxelinux.cfg 54 is CP /var/www/html/http_iso/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/ default 55 CP /usr/share/syslinux/pxelinux.0 /tftpboot 56 is # modify the default startup program 57 is Sed -i 'lS / vesamenu.c32 / KS / G' /tftpboot/pxelinux.cfg/ default 58 Sed -i 120 d /tftpboot/pxelinux.cfg/ default 59 echo " label KS 60 MENU ^ 7 the Install CentOS label 61 Kernel vmlinuz 62 the append Method, the initrd = initrd.img = HTTP: // $ IP / http_iso KS = HTTP: //$IP/ks.cfg devfs = nomount 63 the MENU End " >> / tftpboot / PXELINUX .cfg / default 64 # copy ks working directory file to the httpd 65 CP ~ / Anaconda-the ks.cfg / var / WWW / HTML / the ks.cfg 66 # to increase the file read permission ks 67 the chmod A + R & lt / var / WWW / HTML / the ks.cfg 68 # system installation files modified ks 69 Sed -i '1,10s / CDROM / the install / G' / var / WWW / HTML / the ks.cfg 70 -i. 5A Sed " URL --url = \ " HTTP: // $ the IP / http_iso \ "" / var / WWW / HTML / the ks.cfg 71 is # start service 72 systemctl the restart dhcpd xinetd the httpd 73 is systemctl dhcpd enable the httpd xinetd 74 # Add a firewall 75 firewall-cmd = --add-Port 67 / udp - Permanent 76 firewall-cmd = --add-Port 69 / udp - Permanent 77 firewall-cmd --add-port=80/tcp --permanent 78 firewall-cmd --reload