centos6.0初始化脚本

  1. #!/bin/bash 
  2. #author shanker
  3. #this script is only for CentOS 6 x32 
  4. #check up the OS 
  5. os=$(uname -i) 
  6. if [ $os != "i386" ] 
  7. then 
  8.     echo "this script is only for i386 system" 
  9.     exit 1 
  10. fi 
  11. echo "the os is i386" 
  12. version=$(lsb_release -r|cut -f2|cut -c1) 
  13. if [ $version != 6 ] 
  14. then 
  15.     echo "this script is only for CentOS 6" 
  16.     exit 1 
  17. fi 
  18. cat << EOF 
  19. +---------------------------------------+ 
  20. |   your system is CentOS 6 x86_64      | 
  21. |        start optimizing.......        | 
  22. +--------------------------------------- 
  23. EOF 
  24. #set up the 163.com as the default yum repo 
  25. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 
  26. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS-Base.repo 
  27.  
  28. #add the third party repo 
  29. #add the epel 
  30. rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm 
  31. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 
  32. #add the rpmforge 
  33. rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm 
  34. rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 
  35.  
  36. #update the system and set up the ntp 
  37.  
  38. #yum clean all 
  39. #yum install kernel-devel kernel-headers && echo exclude=kernel>> /etc/yum.conf 
  40. #yum -y update glibc\* 
  41. #yum -y update yum\* rpm\* python\*  
  42. #yum -y update 
  43. yum -y install ntp 
  44. echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/root 
  45. service crond restart 
  46. #set the control-alt-delete disable 
  47. sed -i 's/^\(exec\)./#\1/g' /etc/init/control-alt-delete.conf 
  48. #disable selinux 
  49. sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
  50. #set ssh 
  51. sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config 
  52. sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config 
  53. service sshd restart 
  54.  
  55. chkconfig bluetooth off 
  56. chkconfig cups off 
  57. chkconfig ip6tables off 
  58.  
  59. #disable the ipv6 
  60. cat > /etc/modprobe.d/ipv6.conf << EOFI 
  61. alias net-pf-10 off 
  62. options ipv6 disable=1 
  63. EOFI 
  64. echo "NETWORKING_IPV6=off>> /etc/sysconfig/network 
  65.  
  66. #set vim  
  67. cat >>/root/.vimrc << EOF  
  68. set number  
  69. set cindent  
  70. set autoindent  
  71. set shiftwidth=2  
  72. set tabstop=2  
  73. set softtabstop=2  
  74. set expandtab  
  75. set ruler  
  76. set mouse=v  
  77. syntax on  
  78. EOF   
  79. #grep and vim 
  80. echo "alias grep='grep --color=auto'>> /root/.bashrc 
  81. echo "alias vi='vim'>> /root/.bashrc 
  82. source /root/.bashrc 
  83.  
  84. #set ulimit 
  85. echo "ulimit -SHn 102400" >> /etc/rc.local 
  86. cat << EOF 
  87. +-------------------------------------------------+ 
  88. |               optimizer is done                               | 
  89. |   it's recommond to restart this server !             | 
  90. +-------------------------------------------------+ 
  91. EOF 

 

你可能感兴趣的:(centos,脚本)