#This is a configuration script for making a pxe boot server for rhel
#Packages needed are
#1.sylinux
#2.any server to share rhel cd/dvd source and kickstarts —here ve use httpd
#3.kickstart
#4.tftp-server
#5.xinet
#6.dhcp

#—————————————————————
#configuring syslinux
yum install -y syslinux

#————————————————————–
#configuring the httpd
yum install -y httpd
service httpd restart
chkconfig httpd on
#mount the rhel iso to /var/www/html/RHEL

#—————————————————————
#creating the correct kickstart file in the httpd server
echo ”
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall –disabled
# Install OS instead of upgrade
install
# Use network installation
url –url=”http://192.168.122.1/RHEL”
repo –name=”Red Hat Enterprise Linux” –baseurl=http://192.168.122.1/RHEL –cost=100

# Root password
rootpw –iscrypted $1$kUpEHfw2$tJfHCPSVuVvMn7NwcwzJG/
# System authorization information
auth  –useshadow  –passalgo=sha512
# Use text mode install
text
firstboot –disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux –disabled
# Installation logging level
logging –level=info
# Reboot after installation
reboot
# System timezone
timezone  Asia/Kolkata
# Network information
network  –bootproto=dhcp –device=eth0 –onboot=on
# System bootloader configuration
bootloader –append=”crashkernel=auto rhgb quiet” –location=mbr –driveorder=”sda”
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart –all –initlabel
# Disk partitioning information
part /boot –fstype=”ext4″ –size=200
part pv.01 –grow –size=1
volgroup myclient –pesize=4096 pv.01
logvol / –fstype=”ext4″ –vgname=myclient –size=50240 –name=redhat

%post –interpreter=/bin/bash
sed -ie ‘s/id:3:initdefault:/id:5:initdefault:/g’ /etc/inittab
touch /usr/bin/install-client < ”
virt-install -n client -r 1500  –disk path=/var/lib/libvirt/images/client,size=12  –pxe –os-type=linux”
install-client
%end

repo –name=”Red Hat Enterprise Linux” –baseurl=http://192.168.122.1/RHEL –cost=100
%packages
@base
@client-mgmt-tools
@console-internet
@core
@debugging
@basic-desktop
@desktop-debugging
@desktop-platform
@directory-client
@fonts
@general-desktop
@graphical-admin-tools
@hardware-monitoring
@input-methods
@java-platform
@kde-desktop
@large-systems
@legacy-x
@network-file-system-client
@performance
@perl-runtime
@remote-desktop-clients
@server-platform
@server-policy
@virtualization
@virtualization-client
@virtualization-platform
@virtualization-tools
@x11
mtools
pax
python-dmidecode
oddjob
squashfs-tools
sgpio
genisoimage
wodim
sabayon-apply
xguest
tigervnc-server
oprofile-gui
abrt-gui
xrestop
systemtap-grapher
bltk
qt-mysql
qt3-ODBC
qt-odbc
qt-postgresql
qt3-PostgreSQL
qt3-MySQL
certmonger
pam_krb5
krb5-workstation
cjkuni-fonts-ghostscript
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
krb5-auth-dialog
gnome-pilot-conduits
gconf-editor
dvgrab
alacarte
seahorse-plugins
rhythmbox-upnp
gnome-games
gedit-plugins
gnome-pilot
totem-upnp
vim-X11
sabayon
system-config-lvm
audit-viewer
setroubleshoot
firstaidkit-gui
system-config-kickstart
policycoreutils-gui
kdebase-workspace-akonadi
kdebase-workspace-python-applet
xorg-x11-twm
openmotif
xorg-x11-fonts-ISO8859-1-75dpi
xterm
xorg-x11-fonts-cyrillic
xorg-x11-xdm
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-9-75dpi
libXmu
xorg-x11-fonts-ISO8859-15-75dpi
libXp
openmotif22
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ethiopic
xorg-x11-fonts-ISO8859-2-100dpi
perl-DBD-SQLite
spice-xpi
tsclient
rdesktop
vinagre
tigervnc
spice-client
qemu-kvm-tools
fence-virtd-serial
fence-virtd-multicast
libvirt-java
libvirt-cim
fence-virtd-libvirt
perl-Sys-Virt
libvirt-qpid
libguestfs-java
virt-v2v
libguestfs-tools
libguestfs-mount
wacomcpl

%end”> /var/www/html/pxe.cfg
#——————————————————————————

#configure the tftp server
yum install -y tftp-server

#copying the needed file file pxelinux.0 from syslinux to /var/lib/tftpboot
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#making a directory pxelinux.cfg to store the default menu
mkdir -p /var/lib/tftpboot/pxelinux.cfg

#making the default file with kernal to load and correct shared kickstart file
touch /var/lib/tftpboot/pxelinux.cfg/default
echo ”
default menu.c32
menu title BOOT MENU

label redhat
kernel rhel/vmlinuz
append  initrd=rhel/initrd.img ks=http://192.168.122.1/pxe.cfg

” > /var/lib/tftpboot/pxelinux.cfg/default

vim /var/lib/tftpboot/pxelinux.cfg/default
#copying menu.c32 into /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/

#copiying splash image for boot menu

cp /boot/grub/splash.xpm.gz /var/lib/tftpboot/
#—————————————————————————
#configure xinet files

yum install -y xinetd

#change the disabled paremeter form yes to no in /etc/xinet.d/tftp
echo “diable = no “>> /etc/xinetd.d/tftp

vim /etc/xinetd.d/tftp

service xinetd restart
chkconfig xinetd on

#—————————————————————————-
# Before starting this script you must configure the dhcp server properly
#do the needed dhcp setting for the pxe
yum install -y dhcp

echo ”
option domain-name “server.example.com”;
option routers 192.168.122.1;
Allow booting;
Allow bootp;
next-server 192.168.122.1; <<———pxe server ip
filename “pxelinux.0″;
” >> /etc/dhcp/dhcpd.conf
#Openeing the dhcp file for editing
vim /etc/dhcp/dhcpd.conf
#dhcpd service is restarted and chkconfig is done

service dhcpd restart
chkconfig dhcpd on