#!/usr/bin/env bash
for i in `chkconfig --list | awk '{print $1}'`;do
    if [[ $i = 'atd' || $i = 'crond' || $i = 'irqbalance' || $i = 'network' || $i = 'sshd' || $i = 'rsyslog' 
    || $i = 'httpd' || $i = salt-* || $i = zabbix_* ]];then
        chkconfig --level 3 $i on
    else
        chkconfig $i off
    fi
done
grep -v "^#" /etc/ssh/sshd_config | grep -v "^$" | grep "^UseDNS no" > /dev/null
if [[ $? -ne 0 ]];then
    sed -i '122a\UseDNS no' /etc/ssh/sshd_config
    /etc/init.d/sshd restart
fi
cat  >>/etc/profile<<EOF
if [ $SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
     ulimit -c unlimited
else
     ulimit -u 16384 -n 65536 -c unlimited
fi
EOF

source /etc/profile

##set ulimit file
cat >> /etc/security/limits.conf<<EOF
*           soft    nproc   10000
*          hard    nproc   16384
*           soft    nofile   65536
*           hard    nofile  65536
EOF


## set sysctl
cat >>/etc/sysctl.conf <<EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.ip_conntrack_max = 10240
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=4194304
net.ipv4.tcp_timestamps =0
net.ipv4.tcp_sack =1
net.ipv4.tcp_window_scaling =1
EOF

sysctl -p

##install

yum install -y @base ntp gcc gcc-c++ make telnet openssl lrzsz vim openssl-devel unzip gd gd-devel libcurl-devel

##set clock

ntpdate us.pool.ntp.org


##set ssh port
#set -- $(sed -n '/^Port/'p /etc/ssh/sshd_config)

#port=$2

#if [[ "xx${port}" == "xx" ]]
#then
 #  cat >>/etc/ssh/sshd_config<<EOF
#Port 7522
#EOF
#elif [[ ${port} -eq 7522 ]]
#then
#        sed -i "s/7522/22/g" /etc/ssh/sshd_config
#        echo 'ok'
#elif [[ ${port} -eq 22 ]]
#then
#        sed -i "s/22/7522/g" /etc/ssh/sshd_config
#fi

#service sshd restart
##set ssh listener ip is Private IP.

results matching ""

    No results matching ""