#!/bin/bash
# Program:
# system_init_shell
cat << EOF
+--------------------------------------------------------------+
| === Welcome to RedHat 6.x System init === |
+--------------------------------------------------------------+
EOF
#update 163 yum
#cd /etc/yum.repos.d
#mv CentOS-Base.repo CentOS-Base.repo.bak
#wget http://mirrors.163.com/.help/CentOS-Base-163.repo
#mv CentOS-Base-163.repo CentOS-Base.repo
#yum clean metadata
#yum makecache
#add epel
#rpm -Uvh http://download.Fedora.RedHat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
#rpm �Cimport /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
#rpm �Cimport /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
#update system pack
yum -y install gcc gcc-c++ 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-devel sudo bzip2 mlocate flex lrzsz sysstat lsof setuptool system-config-network-tui system-config-firewall-tui ntp libaio-devel wget ntp
#set ntp
echo "2 5 * * * /usr/sbin/ntpdate 10.10.2.165;/sbin/clock -w >/dev/null 2>&1" >> /var/spool/cron/root
/usr/sbin/ntpdate 10.10.2.165;/sbin/clock -w >/dev/null 2>&1
service crond restart
#set ulimit
#echo "ulimit -SHn 65536" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
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
chkconfig --level 2345 iptables off
/etc/init.d/xinetd start
chkconfig xinetd on
chkconfig rsync on
lsof -i:873
echo "service is init is ok.............."
#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 hosts.allow
cat >> /etc/security/limits.conf << EOF
sshd:10.10.1.60
sshd:10.10.1.61
sshd:10.10.2.101
sshd:10.10.2.100
EOF
#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!"
#vim setting
sed -i "8 s/^/alias vi='vim'/" /root/.bashrc
echo 'syntax on' > /root/.vimrc
cat << EOF
+--------------------------------------------------------------+
| ===System init over=== |
+--------------------------------------------------------------+
EOF
echo "###############################################################"