Browse Source

Update include/init_*.sh

lj2007331 8 years ago
parent
commit
56ca69af53

+ 1 - 1
include/check_download.sh

@@ -444,7 +444,7 @@ checkDownload() {
             # php 5.3
             src_url=${mirrorLink}/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src
             src_url=${mirrorLink}/php5.3patch && Download_src
-            if [[ "${Debian_version}" == "8" || "${Ubuntu_version}" == "16" ]];then
+            if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ];then
                 if [ ! -e "/usr/local/openssl/lib/libcrypto.a" ];then
                     src_url=${mirrorLink}/openssl-1.0.0s.tar.gz && Download_src
                 fi

+ 1 - 0
include/check_port.py

@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 import sys,os,socket
 def IsOpen(ip,port):
+    socket.setdefaulttimeout(5)
     s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
     try:
         s.connect((ip,int(port)))

+ 1 - 1
include/get_ipaddr_state.py

@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 #coding:utf-8
+import sys,urllib2,socket
 try:
-    import sys,urllib2,socket
     socket.setdefaulttimeout(10)
     apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1]
     content = urllib2.urlopen(apiurl).read()

+ 37 - 29
include/init_CentOS.sh

@@ -40,14 +40,11 @@ if [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ];then
     export CC="gcc44" CXX="g++44"
 fi
 
-# check sendmail
-#[ "$sendmail_yn" == 'y' ] && yum -y install sendmail && service sendmail restart
-
 # closed Unnecessary services and remove obsolete rpm package
 [ "$CentOS_RHEL_version" == '7' ] && [ "`systemctl is-active NetworkManager.service`" == 'active' ] && NM_flag=1
 for Service in `chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager'`;do chkconfig --level 3 $Service off;done
 [ "$NM_flag" == '1' ] && systemctl enable NetworkManager.service
-for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog sendmail;do chkconfig --level 3 $Service on;done
+for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog;do chkconfig --level 3 $Service on;done
 
 # Close SELINUX
 setenforce 0
@@ -58,7 +55,6 @@ cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
 PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\\\$ "
 HISTTIMEFORMAT="%F %T \`whoami\` "
-PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }'
 
 alias l='ls -AFhlt'
 alias lh='l | head'
@@ -70,6 +66,10 @@ alias egrep='egrep --color'
 alias fgrep='fgrep --color'
 EOF
 
+[ -z "`grep ^'PROMPT_COMMAND=' /etc/bashrc`" ] && cat >> /etc/bashrc << EOF
+PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }'
+EOF
+
 # /etc/security/limits.conf
 [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
 sed -i '/^# End of file/,$d' /etc/security/limits.conf
@@ -94,24 +94,43 @@ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 #nameserver 8.8.8.8
 #EOF
 
+# ip_conntrack table full dropping packets
+[ ! -e "/etc/sysconfig/modules/iptables.modules" ] && { echo modprobe ip_conntrack > /etc/sysconfig/modules/iptables.modules; chmod +x /etc/sysconfig/modules/iptables.modules; }
+modprobe ip_conntrack
+echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf
+
 # /etc/sysctl.conf
-sed -i 's/net.ipv4.tcp_syncookies.*$/net.ipv4.tcp_syncookies = 1/g' /etc/sysctl.conf
-[ -z "`grep 'fs.file-max' /etc/sysctl.conf`" ] && cat >> /etc/sysctl.conf << EOF
+[ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk}
+cat > /etc/sysctl.conf << EOF
 fs.file-max=65535
-fs.inotify.max_user_instances = 8192
-net.ipv4.tcp_fin_timeout = 30
+net.ipv4.tcp_max_tw_buckets = 60000
+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.ipv4.tcp_max_syn_backlog = 65536
+net.core.netdev_max_backlog = 32768
+net.core.somaxconn = 32768
+net.core.wmem_default = 8388608
+net.core.rmem_default = 8388608
+net.core.rmem_max = 16777216
+net.core.wmem_max = 16777216
+net.ipv4.tcp_timestamps = 0
+net.ipv4.tcp_synack_retries = 2
+net.ipv4.tcp_syn_retries = 2
+net.ipv4.tcp_tw_recycle = 1
+#net.ipv4.tcp_tw_len = 1
 net.ipv4.tcp_tw_reuse = 1
+net.ipv4.tcp_mem = 94500000 915000000 927000000
+net.ipv4.tcp_max_orphans = 3276800
 net.ipv4.tcp_tw_recycle = 1
 net.ipv4.ip_local_port_range = 1024 65000
-net.ipv4.tcp_max_syn_backlog = 65536
-net.ipv4.tcp_max_tw_buckets = 6000
-net.ipv4.route.gc_timeout = 100
-net.ipv4.tcp_syn_retries = 1
-net.ipv4.tcp_synack_retries = 1
-net.core.somaxconn = 65535
-net.core.netdev_max_backlog = 262144
-net.ipv4.tcp_timestamps = 0
-net.ipv4.tcp_max_orphans = 262144
+net.nf_conntrack_max = 6553500
+net.netfilter.nf_conntrack_max = 6553500
+net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
+net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
+net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
+net.netfilter.nf_conntrack_tcp_timeout_established = 3600
 EOF
 sysctl -p
 
@@ -123,20 +142,9 @@ elif [ "$CentOS_RHEL_version" == '6' ];then
     sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init
     sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
     sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
-    [ -z "`grep net.netfilter.nf_conntrack_max /etc/sysctl.conf`" ] && cat >> /etc/sysctl.conf << EOF
-net.nf_conntrack_max = 6553500
-net.netfilter.nf_conntrack_max = 6553500 
-net.netfilter.nf_conntrack_tcp_timeout_established = 180
-EOF
 elif [ "$CentOS_RHEL_version" == '7' ];then
     sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
-    [ -z "`grep net.netfilter.nf_conntrack_max /etc/sysctl.conf`" ] && cat >> /etc/sysctl.conf << EOF
-net.nf_conntrack_max = 6553500
-net.netfilter.nf_conntrack_max = 6553500
-net.netfilter.nf_conntrack_tcp_timeout_established = 180
-EOF
 fi
-init q
 
 # Update time
 ntpdate pool.ntp.org

+ 7 - 4
include/init_Debian.sh

@@ -29,10 +29,13 @@ done
 # Custom profile
 cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
+PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '
 HISTTIMEFORMAT="%F %T \`whoami\` "
 
-alias l='ls -AFhlt'
+alias l='ls -AFhlt --color=auto'
 alias lh='l | head'
+alias ll='ls -l --color=auto'
+alias ls='ls --color=auto'
 alias vi=vim
 
 GREP_OPTIONS="--color=auto"
@@ -41,10 +44,10 @@ alias egrep='egrep --color'
 alias fgrep='fgrep --color'
 EOF
 
-# PS1
-[ -z "`grep ^PS1 ~/.bashrc`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc
+sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
 
-[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+# history
+[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
 [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf

+ 7 - 5
include/init_Ubuntu.sh

@@ -44,16 +44,15 @@ elif [ "$Ubuntu_version" == '12' ];then
     apt-get -y install bison libcloog-ppl0
 fi
 
-# check sendmail
-#[ "$sendmail_yn" == 'y' ] && apt-get -y install sendmail
-
 # Custom profile
 cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
 HISTTIMEFORMAT="%F %T \`whoami\` "
 
-alias l='ls -AFhlt'
+alias l='ls -AFhlt --color=auto'
 alias lh='l | head'
+alias ll='ls -l --color=auto'
+alias ls='ls --color=auto'
 alias vi=vim
 
 GREP_OPTIONS="--color=auto"
@@ -62,10 +61,13 @@ alias egrep='egrep --color'
 alias fgrep='fgrep --color'
 EOF
 
+sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
+
 # PS1
 [ -z "`grep ^PS1 ~/.bashrc`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc
 
-[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+# history
+[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
 [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf

+ 4 - 4
versions.txt

@@ -22,7 +22,7 @@ mysql_5_5_version=5.5.52
 
 mariadb_10_1_version=10.1.17
 mariadb_10_0_version=10.0.27
-mariadb_5_5_version=5.5.51
+mariadb_5_5_version=5.5.52
 
 percona_5_7_version=5.7.14-7
 percona_5_6_version=5.6.32-78.0
@@ -34,8 +34,8 @@ jdk_7_version=1.7.0_80
 jdk_6_version=1.6.0_45
 
 # PHP
-php_7_version=7.0.10
-php_6_version=5.6.25
+php_7_version=7.0.11
+php_6_version=5.6.26
 php_5_version=5.5.38
 php_4_version=5.4.45
 php_3_version=5.3.29
@@ -80,7 +80,7 @@ jemalloc_version=4.2.1
 tcmalloc_version=2.5
 
 # boost
-boost_version=1.60.0
+boost_version=1.59.0
 
 # Others
 libevent_version=2.0.22-stable