#!/bin/bash
#!/bin/sh
#try to optimize my operating system.
#####################################
#get the os bit.
TEST=`uname -i`
#echo $TEST
if [ $TEST != "x86_64" ]
then
echo "_______________________________"
echo "|The platform is not 64-bit os!|"
echo "-------------------------------"
else
echo "            "
fi
#####################################
#get the version
VERSION=`lsb_release -r |awk '{print $2}'`
if [ $VERSION != '6.2' ]
then
echo "*************************"
echo "*this is for version 6.2*"
echo "*************************"
else
echo "      "
fi
cat <<EOF
################################
#This os is centos version 6.2 #
#we can potimize the os new.   #
################################


EOF
#Begin to optimize this os.
#----make a default yum repo----
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo
#----add the third-party repo----
#----add epel----
rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
#----add rpmforge----
#rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag

#----update the system -----
yum clean all
yum update -y
yum update glibc\* yum\* rpm\* python\*  -y
#----set the ntp----
yum install ntp -y
echo "*3*** /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/root
service crond restart
#-----/etc/security/limits.conf----
cat<<EOF  >>/etc/security.limits.conf
*    soft     nofile    65535
abc    -    maxlogins    1
root    -    maxlogins    2
EOF
#----stop some server----
chkconfig bluetooth off
chkconfig cups off
chkconfig ip6tables off
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config


cat <<EOF
!!!!!!!!!!!!!!!!!!!!!!!
!we just finish it!   !
!!!!!!!!!!!!!!!!!!!!!!!
EOF