#install cobbler-server soft
#date 2013.08.07
#disabled iptables and selinux
/etc/init.d/iptables stop
setenforce 0
IP=`ifconfig eth0 |awk -F '[ :]+' 'NR==2 {print $4}'`
#yum epel
system_version=`cat /etc/issue|grep CentOS|awk -F '[ .]+' '{print $3}'`
if [ ${system_version} == 5 ]; then
rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
else
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
fi
yum -y install cobbler httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart
#modify the file /etc/cobbler/settings,1.78 is cobbler-server's ip
sed -i 's/server: 127.0.0.1/server: '${IP}'/g' /etc/cobbler/settings
#modify the /etc/xinetd.d/tftp and /etc/xinetd.d/rsync
sed -i '/disable/c\tdisable = no' /etc/xinetd.d/tftp
sed -i 's/= yes/= no/g' /etc/xinetd.d/rsync
#或者此处也可以这样写
#sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
#sed -i '/disable/s/no/yes' /etc/xinetd.d/rsync
/etc/init.d/xinetd restart
#web_log_in and set web_log_in_user and password
sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf
#htdigest /etc/cobbler/users.digest "Cobbler" cobbler
#Avoiding repeated installations by close pxe
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings
#cobbler manage dhcp
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings
#set
sed -i 's/^#Load/Load/' /etc/httpd/conf.d/wsgi.conf
#start httpd,not nginx
sed -i 's/#ServerName www.example.com:80/ServerName '${IP}':80/g' /etc/httpd/conf/httpd.conf
/etc/init.d/httpd restart
#get the os's bootloader
cobbler get-loaders
#dedmirrors
yum -y install ed patch perl perl-Compress-Zlib perl-Cwd perl-Digest-MD5
perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
rpm -ivh ftp://fr2.rpmfind.net/linux/epel/5/ppc/debmirror-20090807-1.el5.noarch.rpm
sed -i 's/@dists/#&/g' /etc/debmirror.conf
sed -i 's/@arches/#&/g' /etc/debmirror.conf
#set the root's password
a=`openssl passwd -1 -salt 'random-phrase-here' '123456'`
echo $a
#sed -i 's/default_password_crypted:"/&'$a'"/g' /etc/cobbler/settings
sed -i '/default_password_crypted/s/^/&#/g' /etc/cobbler/settings
cat >> /etc/cobbler/settings << EOF
default_password_crypted: "$a"
EOF
#set dhcp
sed -i 's/192.168.1.[0-9];/192.168.1.1;/g' /etc/cobbler/dhcp.template
#start services
/etc/init.d/cobblerd restart
/etc/init.d/xinetd restart
cobbler sync
#mount iso
wget http://192.168.1.78/test/CentOS-6.4-x86_64-bin-DVD1.iso
mount -t auto -o loop CentOS-6.4-x86_64-bin-DVD1.iso /mnt
cobbler import --path=/mnt --name=centos6.4
cobbler sync