#!/bin/bash
#
#cobbler server address
ip=192.168.119.133
#DHCP server net and address fanwei
net=192.168.119.0
begin=192.168.119.150
end=192.168.119.200
dns=202.96.209.133
#firewall setting
sed -i -e ‘s/SELINUX=enforcing/SELINUX=disabled‘ /etc/sysconfig/selinux
setenforce 0
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 25151 -j ACCEPT
iptables -I INPUT -m state --state NEW -m udp -p udp --dport 69 -j ACCEPT
service iptables save
service iptables restart
#hostname setting
echo "$ip www.cobbler.com" >> /etc/hosts
#install epel and config epel
wget http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm
rpm -ivh epel-release-latest-6.noarch.rpm
rm -rf /var/run/yum.pid
yum repolist
yum -y install cobbler cobbler-web pykickstart dhcp httpd debmirror rsync cman fence-agents python-ctypes system-config-kickstart
/etc/init.d/iptables stop
/etc/init.d/httpd start
/etc/init.d/xinetd start
/etc/init.d/cobblerd start
service cobblerd restart
cobbler get-loaders
sed -i -e ‘s/= yes/= no/g‘ /etc/xinetd.d/rsync
sed -i -e ‘s/= yes/= no/g‘ /etc/xinetd.d/tftp
sed -i ‘[email protected]_server: [email protected]_server: ‘$ip‘@g‘ /etc/cobbler/settings
sed -i ‘[email protected]: [email protected]: ‘$ip‘@g‘ /etc/cobbler/settings
sed -i ‘[email protected][email protected]#[email protected]‘ /etc/cobbler/settings
echo "default_password_crypted: "$(openssl passwd -1 -salt ‘random-phrase-here‘ ‘[email protected]‘)"" >> /etc/cobbler/settings
#cp /usr/share/syslinux/pxelinux.0 /var/lib/cobbler/loaders/
#cp /usr/share/syslinux/meminfo.c32 /var/lib/cobbler/loaders/
service cobblerd restart
cobbler sync
cat > /etc/dhcp/dhcpd.conf << EOF
option domain-name "cobbler.com";
option domain-name-servers $dns;
default-lease-time 43200;
max-lease-time 86400;
log-facility local7;
subnet $net netmask 255.255.255.0 {
range $begin $end;
option routers $ip;
}
next-server $ip;
filename="pxelinux.0";
EOF
service cobblerd restart
service xinetd restart
service dhcpd start
#mount system iso file
mkdir /opt/cobbler
mount /dev/cdrom /opt/cobbler
cobbler import --name=CentOS-6.7-x86_64 --path=/opt/cobbler
cobbler profile add --name=auto_install_CentOS-6.7 --distro=CentOS-6.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/ks.cfg