#!/bin/bash
#author shanker
#this script is only for CentOS 6 x32
#check up the OS
os=$(uname -i)
if [ $os != "i386" ]
then
     echo "this script is only for i386 system"
     exit 1
fi
echo "the os is i386"
version=$(lsb_release -r|cut -f2|cut -c1)
if [ $version != 6 ]
then
     echo "this script is only for CentOS 6"
     exit 1
fi
cat << EOF
+---------------------------------------+
|   your system is CentOS 6 x86_64      |
|        start optimizing.......        |
+---------------------------------------
EOF
#set up the 163.com as the default yum repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo
#add the third party repo
#add the epel
rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
#add the rpmforge
rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
#update the system and set up the ntp
#yum clean all
#yum install kernel-devel kernel-headers && echo exclude=kernel* >> /etc/yum.conf
#yum -y update glibc\*
#yum -y update yum\* rpm\* python\*
#yum -y update
yum -y install ntp
echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/root
service crond restart
#set the control-alt-delete disable
sed -i 's/^\(exec\)./#\1/g' /etc/init/control-alt-delete.conf
#disable selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#set ssh
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
service sshd restart
chkconfig bluetooth off
chkconfig cups off
chkconfig ip6tables off
#disable the ipv6
cat > /etc/modprobe.d/ipv6.conf << EOFI
alias net-pf-10 off
options ipv6 disable=1
EOFI
echo "NETWORKING_IPV6=off" >> /etc/sysconfig/network
#set vim
cat >>/root/.vimrc << EOF
set number
set ruler
set laststatus=2
set showcmd
set magic
set history=100
set showmatch
set ignorecase
set cursorline
let loaded_matchparen=1
set lazyredraw
set tabstop=4
set softtabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
set smartindent shiftwidth=4
set expandtab
set hlsearch
set incsearch
EOF
#grep and vim
echo "alias grep='grep --color=auto'" >> /root/.bashrc
echo "alias vi='vim'" >> /root/.bashrc
source /root/.bashrc
#set ulimit
echo "ulimit -SHn 102400" >> /etc/rc.local
cat << EOF
+-------------------------------------------------+
|               optimizer is done                               |
|   it's recommond to restart this server !             |
+-------------------------------------------------+
EOF