#!/bin/bash # Program: # system_init_shell # History: # 2012/06/01 25061008@qq.com # Release: # 1.1 cat << EOF +--------------------------------------------------------------+ | === Welcome to CentOS 6.x System init === | +--------------------------------------------------------------+ +---------------------------by 元心科技--------------------------+ EOF for i in `ls /etc/yum.repos.d/*` do mv ${i} ${i}_bak done cp ./configs/local.repo /etc/yum.repos.d/ yum clean all for i in gcc gcc-c++ glibc make autoconf libtool-ltdl-devel gd-devel freetype-devel libxml2-devel libjpeg-devel libpng-devel openssl-devel curl-devel bison patch unzip libmcrypt-devel libmhash-devel ncurses ncurses-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool system-config-network-tui system-config-firewall-tui ntp libaio-devel wget ntp createrepo yum-downloadonly iftop do yum -y install ${i} > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "${i} is installed" else echo "${i} is installed to error" fi done #set profile cp ./configs/profile /etc source /etc/profile #set ntp echo "*/5 * * * * /usr/sbin/ntpdate time.windows.com > /dev/null 2>&1" >> /var/spool/cron/root service crond restart #set clock hwclock --set --date="`date +%D %T`" hwclock --hctosys #set ulimit echo "ulimit -SHn 102400" >> /etc/rc.local cat >> /etc/security/limits.conf << EOF * soft nofile 102400 * hard nofile 102400 * soft nproc 102400 * hard nproc 102400 EOF #set max user processes #sed -i 's/1024/102400/' /etc/security/limits.d/90-nproc.conf # turnoff the control-alt-delete sed -i 's#exec /sbin/shutdown -r now##exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf #close useless service for i in `ls /etc/rc3.d/S*` do CURSRV=`echo $i|cut -c 15-` echo $CURSRV case $CURSRV in crond | irqbalance | network | sshd | rsyslog | sysstat ) echo "Base services, Skip!" ;; *) echo "change $CURSRV to off" chkconfig --level 2345 $CURSRV off service $CURSRV stop ;; esac done echo "service is init is ok.............." #set LANG :> /etc/sysconfig/i18n cat >> /etc/sysconfig/i18n << EOF LANG="en_US.UTF-8" EOF #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 #set sysctl true > /etc/sysctl.conf cat >> /etc/sysctl.conf << EOF net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 1024 65535 EOF /sbin/sysctl -p echo "sysctl set OK!!" #disable ipv6 #echo "alias net-pf-10 off" >> /etc/modprobe.conf #echo "alias ipv6 off" >> /etc/modprobe.conf #/sbin/chkconfig ip6tables off #echo "ipv6 is disabled!" #disable selinux sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config setenforce 0 #vim setting sed -i "8 s/^/alias vi='vim'/" /root/.bashrc echo 'syntax on' > /root/.vimrc cat << EOF +--------------------------------------------------------------+ | ===System init over=== | +--------------------------------------------------------------+ +---------------------------by 元心科技------------------------+ EOF echo "###############################################################"