#!/bin/bash cdromdir="/mnt" tftpdir="/var/lib/tftpboot" dhcpNet="168.7.10.0" netMask="255.255.255.0" dhcpRange="168.7.10.100 168.7.10.200" nextServer="168.7.10.135" isoimage="openeuler.iso" httpServer=$nextServer #----------------------------------------------------------- iptables -F || echo "" systemctl stop firewalld systemctl disable firewalld sed -i '/SELINUX=/ s#enforcing#disabled#g' /etc/selinux/config setenforce 0 || echo "" mount /tmp/$isoimage $cdromdir || echo "" cp $cdromdir/EFI/BOOT/grubaa64.efi $tftpdir cp $cdromdir/EFI/BOOT/grub.cfg $tftpdir cp $cdromdir/images/pxeboot/* $tftpdir cd /var/www/html || mkdir -p /var/www/html/ cp -r $cdromdir/* /var/www/html/ chmod 755 -R /var/www/html/ cat>/etc/yum.repos.d/openeuler_http.repo<<EOF [openeuler_http] name=openeuler_http baseurl=http://$nextServer enabled=1 gpgcheck=0 EOF yum --disablerepo="*" --enablerepo="openeuler_http" install -y net-tools vim vsftpd tftp tftp-server dhcp #-- dhcp cat>/etc/dhcp/dhcpd.conf<<EOF subnet $dhcpNet netmask $netMask { range $dhcpRange; option subnet-mask $netMask; default-lease-time 21600; max-lease-time 43200; next-server $nextServer; filename "grubaa64.efi"; } EOF #-- tftp sed -i '/disable/ s#yes#no#g' /etc/xinetd.d/tftp || echo "" systemctl start dhcpd && systemctl enable dhcpd systemctl start tftp && systemctl enable tftp systemctl start httpd && systemctl enable httpd cat>$tftpdir/grub.cfg<<'EOF' set default="1" function load_video { if [ x$feature_all_video_module = xy ]; then insmod all_video else insmod efi_gop insmod efi_uga insmod ieee1275_fb insmod vbe insmod vga insmod video_bochs insmod video_cirrus fi } load_video set gfxpayload=keep insmod gzio insmod part_gpt insmod ext2 set timeout=3 ### END /etc/grub.d/00_header ### EOF cat>>$tftpdir/grub.cfg<<EOF ### BEGIN /etc/grub.d/10_linux ### menuentry 'Install openEuler 20.03 LTS' --class red --class gnu-linux --class gnu --class os { set root=(tftp,$nextServer) linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 inst.ks=http://$httpServer/ks/openEuler-ks.cfg initrd /initrd.img } EOF mkdir -p /var/www/html/ks/ cat>/var/www/html/ks/openEuler-ks.cfg<<EOF #version=DEVEL # Use graphical install graphical #--------------------------------------------------------- # Keyboard layouts keyboard --xlayouts='us','cn (altgr-pinyin)' #--------------------------------------------------------- # System language lang en_US.UTF-8 #--------------------------------------------------------- # Use CDROM installation media # 安装镜像 url --url=http://$httpServer #--------------------------------------------------------- %packages @^minimal-environment @development %end #--------------------------------------------------------- # System timezone timezone Asia/Shanghai --utc #--------------------------------------------------------- # Network information network --hostname=localhost.localdomain network --bootproto=dhcp --device=enp4s0 --onboot=on --ipv6=auto --activate #network --bootproto=static --device=enp4s0 --gateway=168.7.10.1 --ip=168.7.10.105 --nameserver=114.114.114.114 --netmask=255.255.255.0 --onboot=off --ipv6=off --activate # Run the Setup Agent on first boot firstboot --enable # System services services --disabled="chronyd" # 在那块磁盘安装OS ignoredisk --only-use=vda #--------------------------------------------------------- # Partition clearing information clearpart --all --initlabel #--------------------------------------------------------- # Disk partitioning information # 分区表 part swap --fstype="swap" --ondisk=vda --size=10240 part / --fstype="ext4" --ondisk=vda --size=174078 part /boot/efi --fstype="efi" --ondisk=vda --size=5120 --fsoptions="umask=0077,shortname=winnt" part /tmp --fstype="ext4" --ondisk=vda --size=51200 part /boot --fstype="ext4" --ondisk=vda --size=5120 #--------------------------------------------------------- # Root password rootpw --iscrypted $6$XpbpyyInoUzlkmbP$vCHN5jPj18a2loOIV8tZhr19xW08R7K8lpNKqU7/WhhyGo0I7E5zK01JWGTSOxDJ5Kkl7zAgF8Zdi9k5yv1M51 #--------------------------------------------------------- %addon com_redhat_kdump --disable --reserve-mb='128' %end %anaconda pwpolicy root --minlen=8 --minquality=1 --strict --nochanges --notempty pwpolicy user --minlen=8 --minquality=1 --strict --nochanges --emptyok pwpolicy luks --minlen=8 --minquality=1 --strict --nochanges --notempty %end #reboot EOF chmod 777 -R /var/lib/tftp/ chmod 777 -R /var/www/html/ks systemctl restart tftp systemctl restart dhcpd systemctl restart httpd
标签:www,cdromdir,tftpdir,html,sh,var,cp,pxe From: https://www.cnblogs.com/vmsysjack/p/18278284