Centos7 PXE Server Install Script

PxeCentos7Install.sh # 
# centos7 mirror mount, here Centos7 1511, pxe installation image as
configured and epel yum centos source before installation # # ip card and localip consistent
localip
= " 10.10.0.240 " eth_name = ' eth0 ' dnsmasq_install ( ) { yum -Y the install dnsmasq Music Videos /etc/dnsmasq.conf / etc / dnsmasq.conf.backup dnsmasq_conf = ' interface = ' $ eth_name ' # bind- the interfaces Domain = centos7.lan # the DHCP Range - Leases DHCP -range = '$eth_name',10.10.0.100,10.10.0.110,255.255.255.0,1h # PXE dhcp-boot=pxelinux.0,pxeserver,'$localip' # Gateway dhcp-option=3,'$localip' # DNS dhcp-option=6,'$localip',114.114.114.114 server=114.114.114.114 # Broadcast Address dhcp-option=28,10.10.0.255 # NTP Server dhcp-option=42,0.0.0.0 pxe-prompt="Press F8 for menu.",60 pxe-service=x86PC,"Install CentOS 7 from network server '$localip'", pxelinux enable-tftp tftp-root=/var/lib/tftpboot' echo "$dnsmasq_conf" > /etc/dnsmasq.conf } tftp_pxe_install() { yum -y install syslinux yum -y install tftp-server cp -r /usr/share/syslinux/* /var/lib/tftpboot/ if [[ ! -d /var/lib/tftpboot/pxelinux.cfg ]] then mkdir /var/lib/tftpboot/pxelinux.cfg touch /var/lib/tftpboot/pxelinux.cfg/default default_conf='default menu.c32 prompt 0 timeout 300 ONTIMEOUT local menu title ########## PXE Boot Menu ########## label 1 menu label ^1)InstallCentOS7 x64 withLocalRepo kernel centos7/vmlinuz append initrd=centos7/initrd.img method=ftp://'$localip'/pub devfs=nomount label 2 menu label ^2)InstallCentOS7 x64 with http://mirror.centos.org Repo kernel centos7/vmlinuz append initrd=centos7/initrd.img method=http://mirror.centos.org/centos/7/os/x86_64/ devfs=nomount ip=dhcp label 3 menu label ^3)InstallCentOS7 x64 withLocalRepousing VNC kernel centos7/vmlinuz append initrd=centos7/initrd.img method=ftp://'$localip'/pub devfs=nomount inst.vnc inst.vncpassword=password label 4 menu label ^4)Bootfromlocal drive' echo "$default_conf" > /var/lib/tftpboot/pxelinux.cfg/default fi } mount_cd() { mount|grep '^/dev/sr0' if [[ $? -eq 0 ]] then echo 'disc is mounted. ' The else Mount / dev / SR0 / mnt / &> / dev / null [? [$ -Ne 0]] IF the then COUNT = $ (($ COUNT +. 1)) IF [[$ COUNT 20 is -eq]]; the then echo 'exit timeout'; exit. 8; Fi echo "SR0 no disc, the mount fails, retry in 5 seconds" SLEEP. 5 mount_cd the else echo 'disc mount successful. '; Fi Fi } confing_pxeserver () { IF [[-d / var / lib / tftpboot / centos7]!]; The then mkdir / var / lib / tftpboot / centos7 CP / mnt / Images / pxeboot / vmlinuz / var / lib / tftpboot / centos7 / CP /mnt/images/pxeboot/initrd.img / var / lib / tftpboot / centos7 / Fi yum the install the vsftpd -Y if [[ `ls -A /var/ftp/pub/` == "" ]];then echo 'copy光盘文件到/var/ftp/pub/ ...'; cp -r /mnt/* /var/ftp/pub/ chmod -R 755 /var/ftp/pub fi } start_service() { systemctl start dnsmasq systemctl status dnsmasq systemctl start vsftpd systemctl status vsftpd systemctl enable dnsmasq systemctl enable vsftpd } dnsmasq_install tftp_pxe_install mount_cd confing_pxeserver start_service

 

Guess you like

Origin www.cnblogs.com/tianyuanchen/p/11404780.html