没有多大技术含量,就是将之前的这篇文章http://shanker.blog.51cto.com/1189689/815403写成shell了。
- #!/bin/bash
- #CentOS6.2+PXE+Apache+DHCP+tftp+kickstart
- #Author:shanker
- #Date:2012/05/12
- if [ "$UID" -ne 0 ]
- then
- echo "you must be root to run it"
- exit 0
- fi
- yum -y install httpd* tftp-server system-config-kickstart dhcp syslinux
- mount /dev/cdrom /mnt
- cp -rf /mnt/* /var/www/html
- #configure tftp server
- cat >/etc/xinetd.d/tftp <<EOF
- service tftp
- {
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /tftpboot
- disable = no
- per_source = 11
- cps = 100 2
- flags = IPv4
- }
- EOF
- service xinetd restart
- mkdir /tftpboot
- cp /usr/share/syslinux/pxelinux.0 /tftpboot
- cd /var/www/html/p_w_picpath/pxeboot/
- cp initrd.img vmlinux /tftpboot
- cp /var/www/html/isolinux/*.msg /tftpboot
- mkdir /tftpboot/pxelinux.cfg
- cp /var/www/html/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
- #configure dhcp server
- cat >/etc/dhcp/dhcpd.conf <<EOF
- option domain-name-servers 10.0.0.1;
- max-lease-time 7200;
- authoritative;
- subnet 10.0.0.0 netmask 255.255.255.0 {
- range 10.0.0.1 10.0.0.253;
- next-server 10.0.0.8;
- filename "pxelinux.0";
- }
- EOF
- service dhcpd start
- #configure ks.cfg file
- cat /var/www/html/ks.cfg <<EOF
- #platform=x86, AMD64, or Intel EM64T
- #version=DEVEL
- # Firewall configuration
- firewall --disabled
- # Install OS instead of upgrade
- install
- # Use network installation
- url --url="http://10.0.0.8/"
- # Root password
- rootpw --iscrypted $1$wi31/rmQ$GUXZKNwj/I2.JZ81uRLHk0
- # System authorization information
- auth --useshadow --passalgo=sha512
- # Use graphical install
- graphical
- firstboot --disable
- # System keyboard
- keyboard us
- # System language
- lang en_US
- # SELinux configuration
- selinux --disabled
- # Installation logging level
- logging --level=info
- # System timezone
- timezone Asia/Shanghai
- # Network information
- network --bootproto=dhcp --device=eth0 --onboot=on
- # System bootloader configuration
- bootloader --location=mbr
- # Clear the Master Boot Record
- zerombr
- # Partition clearing information
- clearpart --all --initlabel
- # Disk partitioning information
- part /boot --fstype="ext4" --size=100
- part swap --fstype="swap" --size=512
- part /home --fstype="ext4" --size=5000
- part / --fstype="ext4" --grow --size=1
- %packages
- @basic-desktop
- %end
- EOF
- cat /tftpboot/pxelinux.cfg/default <<EOF
- default linux
- prompt 1
- timeout 6
- display boot.msg
- menu background splash.jpg
- menu title Welcome to CentOS 6.2!
- menu color border 0 #ffffffff #00000000
- menu color sel 7 #ffffffff #ff000000
- menu color title 0 #ffffffff #00000000
- menu color tabmsg 0 #ffffffff #00000000
- menu color unsel 0 #ffffffff #00000000
- menu color hotsel 0 #ff000000 #ffffffff
- menu color hotkey 7 #ffffffff #ff000000
- menu color scrollbar 0 #ffffffff #00000000
- label linux
- menu label ^Install or upgrade an existing system
- menu default
- kernel vmlinuz
- append ks=http://10.0.0.8/ks.cfg initrdinitrdinitrd=initrd.img
- label vesa
- menu label Install system with ^basic video driver
- kernel vmlinuz
- append initrdinitrdinitrd=initrd.img xdriver=vesa nomodeset
- label rescue
- menu label ^Rescue installed system
- kernel vmlinuz
- append initrdinitrdinitrd=initrd.img rescue
- label local
- menu label Boot from ^local drive
- localboot 0xffff
- EOF
转载于:https://blog.51cto.com/shanker/861725