#!/bin/bash
#pxe configuration
#Global config
yum install -y dhcp tftp-server vsftp syslinux
sed -e '6,6s/enforcing/disabled/' /etc/selinux/config
#DHCP config
cat<<EOF>/etc/dhcpd.conf
ddns-update-style interim;
filename "pxelinux.0";
next-server $(ifconfig eth0|grep "inet addr"|cut -d ' ' -f12|cut -d ':' -f2);
subnet 192.168.0.0 netmask 255.255.0.0{
range 192.168.0.254 192.168.0.128;
}
EOF
#VSFTP config
cat <<EOF>>/etc/rc.local
mount /dev/cdrom /var/ftp/pub/
EOF
#TFTP config
sed -i '14,14s/yes/no/' /etc/xinetd.d/tftp
cp /var/ftp/pub/isolinux/* /tftpboot/
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
mkdir /tftpboot/pxelinux.cfg
cat<<EOF>/tftpboot/pxelinux.cfg/default
default ks
prompt 1
timeout 6
label ks
kernel vmlinuz
append ks=ftp://$(ifconfig eth0|grep "inet addr"|cut -d ' ' -f12|cut -d ':' -f2)/ks.cfg initrd=initrd.img ksdevice=link
EOF
chmod 755 -R /tftpboot/*
#kickstart config
cat<<END>/var/ftp/ks.cfg
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled --port=22:tcp
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use pxe
url --url="ftp://$(ifconfig eth0|grep "inet addr"|cut -d ' ' -f12|cut -d ':' -f2)/pub"
# Network information
network --bootproto=static --device=eth0 --onboot=yes --noipv6
# Reboot after installation
reboot --eject
rootpw --iscrypted $1$M3be34zn$QA3wMXYkOGhGMVzVxLzHD/
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
autopart
%packages
--nobase
%post
cat<<EOF>/etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
EOF
cat<<EOF>/etc/rc.d/rc.local
route add -net 1.24.0.0/13 gw 10.10.0.1
EOF
sh /etc/rc.local
END
chmod 755 /var/ftp/ks.cfg
chkconfig dhcpd on
chkconfig vsftpd on
chkconfig xinetd on
chkconfig iptables off