Advertisement
FancyKing

Linux tcp.sh BBR

Dec 22nd, 2020
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 67.27 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH
  4.  
  5. #=================================================
  6. #   System Required: CentOS 6/7/8,Debian 8/9/10,ubuntu 16/18/19
  7. #   Description: BBR+BBRplus+Lotserver
  8. #   Version: 1.3.2.60
  9. #   Author: 千影,cx9208,YLX
  10. #   更新内容及反馈:  https://blog.ylx.me/archives/783.html
  11. #=================================================
  12.  
  13. sh_ver="1.3.2.60"
  14. github="github.000060000.xyz"
  15.  
  16. Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
  17. Info="${Green_font_prefix}[信息]${Font_color_suffix}"
  18. Error="${Red_font_prefix}[错误]${Font_color_suffix}"
  19. Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
  20.  
  21. #安装BBR内核
  22. installbbr(){
  23.     kernel_version="5.9.6"
  24.     bit=`uname -m`
  25.     rm -rf bbr
  26.     mkdir bbr && cd bbr
  27.    
  28.     if [[ "${release}" == "centos" ]]; then
  29.         # if [[ ${version} = "6" ]]; then
  30.             # if [[ ${bit} = "x86_64" ]]; then
  31.                 # wget -N -O kernel-headers-c6.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EUCmObDQnMZEmKnhxS67sJkBG8kjbx0bjNF-XwTtzvgtAA?download=1
  32.                 # wget -N -O kernel-c6.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EeC72joP3HVNmrIbjlPg_coBs7kj29Md4f9psAjZOuqOdg?download=1
  33.            
  34.                 # yum install -y kernel-c6.rpm
  35.                 # yum install -y kernel-headers-c6.rpm
  36.            
  37.                 # kernel_version="5.5.5"
  38.             # else
  39.                 # echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  40.             # fi
  41.        
  42.         if [[ ${version} = "7" ]]; then
  43.             if [[ ${bit} = "x86_64" ]]; then
  44.                 kernel_version="5.10.2"
  45.                 detele_kernel_head
  46.                 wget -N -O kernel-headers-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EZ_a_I1mzcdGl-xz-7jWci8BoE_BjgPjclYc844G81ZFiA?download=1
  47.                 wget -N -O kernel-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EePhYI2CjAVIjcpPJ3vDLIQBPWe_7k8SBGdZUBb3B_YbqA?download=1
  48.                
  49.                 yum install -y kernel-c7.rpm
  50.                 yum install -y kernel-headers-c7.rpm
  51.             else
  52.                 echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  53.             fi 
  54.            
  55.         elif [[ ${version} = "8" ]]; then
  56.             kernel_version="5.6.15"
  57.             detele_kernel_head
  58.             wget -N -O kernel-c8.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/ETadaTIeeQJCgxEXKlOFiCEBsBa-Y15QbDkv-HQGo2EHSQ?download=1
  59.             wget -N -O kernel-headers-c8.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EZEZyLBjDplMgSqDzyaqkvYBW06OOKDCcIQq27381fa5-A?download=1
  60.  
  61.             yum install -y kernel-c8.rpm
  62.             yum install -y kernel-headers-c8.rpm
  63.         fi
  64.    
  65.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  66.         if [[ ${bit} = "x86_64" ]]; then
  67.             kernel_version="5.10.2"
  68.             detele_kernel_head
  69.             wget -N -O linux-headers-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EUFAnbAni8tFok4BRGQUo6gBdlFfEZvuRnLLRmHSgq6Smw?download=1
  70.             wget -N -O linux-image-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EZI4LXrCLsREka-Jtfv733UBhp71FFpfT2DOjQ7BW0S7SA?download=1
  71.                
  72.             dpkg -i linux-image-d10.deb
  73.             dpkg -i linux-headers-d10.deb
  74.         else
  75.             echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1 
  76.         fi 
  77.     fi
  78.    
  79.     cd .. && rm -rf bbr
  80.    
  81.     detele_kernel
  82.     BBR_grub
  83.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  84.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  85.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBR${Font_color_suffix}"   
  86.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn
  87.     [ -z "${yn}" ] && yn="y"
  88.     if [[ $yn == [Yy] ]]; then
  89.         echo -e "${Info} VPS 重启中..."
  90.         reboot
  91.     fi
  92.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  93. }
  94.  
  95. #安装BBRplus内核 4.14.129
  96. installbbrplus(){
  97.     kernel_version="4.14.160-bbrplus"
  98.     bit=`uname -m`
  99.     rm -rf bbrplus
  100.     mkdir bbrplus && cd bbrplus
  101.     if [[ "${release}" == "centos" ]]; then
  102.         if [[ ${version} = "7" ]]; then
  103.             if [[ ${bit} = "x86_64" ]]; then
  104.                 kernel_version="4.14.129_bbrplus"
  105.                 detele_kernel_head
  106.                 wget -N -O kernel-headers-c7.rpm https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-headers-4.14.129-bbrplus.rpm
  107.                 wget -N -O kernel-c7.rpm https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-4.14.129-bbrplus.rpm
  108.                
  109.                 yum install -y kernel-c7.rpm
  110.                 yum install -y kernel-headers-c7.rpm
  111.             else
  112.                     echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  113.             fi
  114.         fi 
  115.        
  116.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  117.         kernel_version="4.14.129-bbrplus"
  118.         detele_kernel_head
  119.         wget -N -O linux-headers.deb https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-headers-4.14.129-bbrplus.deb
  120.         wget -N -O linux-image.deb https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-image-4.14.129-bbrplus.deb
  121.        
  122.         dpkg -i linux-image.deb
  123.         dpkg -i linux-headers.deb
  124.     fi
  125.    
  126.     cd .. && rm -rf bbrplus
  127.     detele_kernel
  128.     BBR_grub
  129.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  130.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  131.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBRplus${Font_color_suffix}"
  132.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBRplus,是否现在重启 ? [Y/n] :" yn
  133.     [ -z "${yn}" ] && yn="y"
  134.     if [[ $yn == [Yy] ]]; then
  135.         echo -e "${Info} VPS 重启中..."
  136.         reboot
  137.     fi
  138.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  139. }
  140.  
  141. #安装Lotserver内核
  142. installlot(){
  143.     if [[ "${release}" == "centos" ]]; then
  144.         rpm --import http://${github}/lotserver/${release}/RPM-GPG-KEY-elrepo.org
  145.         yum remove -y kernel-firmware
  146.         yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-firmware-${kernel_version}.rpm
  147.         yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-${kernel_version}.rpm
  148.         yum remove -y kernel-headers
  149.         yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-headers-${kernel_version}.rpm
  150.         yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-devel-${kernel_version}.rpm
  151.     elif [[ "${release}" == "ubuntu" ]]; then
  152.         bash <(wget -qO- "https://${github}/Debian_Kernel.sh")
  153.     elif [[ "${release}" == "debian" ]]; then
  154.         bash <(wget -qO- "https://${github}/Debian_Kernel.sh")
  155.     fi
  156.    
  157.     detele_kernel
  158.     BBR_grub
  159.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  160.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  161.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}Lotserver${Font_color_suffix}"
  162.     stty erase '^H' && read -p "需要重启VPS后,才能开启Lotserver,是否现在重启 ? [Y/n] :" yn
  163.     [ -z "${yn}" ] && yn="y"
  164.     if [[ $yn == [Yy] ]]; then
  165.         echo -e "${Info} VPS 重启中..."
  166.         reboot
  167.     fi
  168.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  169. }
  170.  
  171. #安装xanmod内核  from xanmod.org
  172. installxanmod(){
  173.     kernel_version="5.5.1-xanmod1"
  174.     bit=`uname -m`
  175.     rm -rf xanmod
  176.     mkdir xanmod && cd xanmod
  177.     if [[ "${release}" == "centos" ]]; then
  178.         if [[ ${version} = "7" ]]; then
  179.             if [[ ${bit} = "x86_64" ]]; then
  180.                 kernel_version="5.9.6_xanmod"
  181.                 detele_kernel_head
  182.                 wget -N -O kernel-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/ETLw9F6MgjBBlkkNGmFZu70B9p0kMOdqrF6ntv2QNI5I4g?download=1
  183.                 wget -N -O kernel-headers-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EcFnSZfa6JBKqZOkE5xFd8oBPJCa6Lo7DzTPPM0INWsk-w?download=1
  184.                
  185.                 yum install -y kernel-c7.rpm
  186.                 yum install -y kernel-headers-c7.rpm           
  187.             else
  188.                 echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  189.             fi
  190.         elif [[ ${version} = "8" ]]; then
  191.                 kernel_version="5.5.1_xanmod1"
  192.                 detele_kernel_head
  193.                 wget -N -O kernel-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.5.1xanmod/kernel-5.5.1_xanmod1-1-c8.x86_64.rpm
  194.                 wget -N -O kernel-headers-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.5.1xanmod/kernel-headers-5.5.1_xanmod1-1-c8.x86_64.rpm
  195.                
  196.                 yum install -y kernel-c8.rpm
  197.                 yum install -y kernel-headers-c8.rpm
  198.         fi
  199.        
  200.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  201.         if [[ ${bit} = "x86_64" ]]; then
  202.             kernel_version="5.10.2-xanmod"
  203.             detele_kernel_head
  204.             wget -N -O linux-headers-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EX2Ba-jo29ZMiqgPxtpE7XQB1WOluu7knD0RxZZqkfdb5w?download=1
  205.             wget -N -O linux-image-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/ES00Tt-nOlZEow3GbdxzS2IB3jt1YKi7Y67v_fWIr55eCQ?download=1
  206.                
  207.             dpkg -i linux-image-d10.deb
  208.             dpkg -i linux-headers-d10.deb
  209.         else
  210.             echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1 
  211.         fi     
  212.     fi
  213.    
  214.     cd .. && rm -rf xanmod
  215.     detele_kernel
  216.     BBR_grub
  217.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  218.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  219.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBR${Font_color_suffix}"
  220.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn
  221.     [ -z "${yn}" ] && yn="y"
  222.     if [[ $yn == [Yy] ]]; then
  223.         echo -e "${Info} VPS 重启中..."
  224.         reboot
  225.     fi
  226.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  227. }
  228.  
  229. #安装bbr2内核
  230. installbbr2(){
  231.     kernel_version="5.4.0-rc6"
  232.     bit=`uname -m`
  233.     rm -rf bbr2
  234.     mkdir bbr2 && cd bbr2
  235.     if [[ "${release}" == "centos" ]]; then
  236.         if [[ ${version} = "7" ]]; then
  237.             if [[ ${bit} = "x86_64" ]]; then
  238.                 kernel_version="5.4.0_rc6"
  239.                 detele_kernel_head
  240.                 wget -N -O kernel-c7.rpm https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/kernel-5.4.0_rc6-1-bbr2-c7.x86_64.rpm
  241.                 wget -N -O kernel-headers-c7.rpm https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/kernel-headers-5.4.0_rc6-1-bbr2-c7.x86_64.rpm
  242.                
  243.                 yum install -y kernel-c7.rpm
  244.                 yum install -y kernel-headers-c7.rpm
  245.             else
  246.                 echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  247.             fi
  248.         elif [[ ${version} = "8" ]]; then
  249.                 kernel_version="5.4.0_rc6"
  250.                 detele_kernel_head
  251.                 wget -N -O kernel-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/kernel-5.4.0_rc6-1-bbr2-c8.x86_64.rpm
  252.                 wget -N -O kernel-headers-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/kernel-headers-5.4.0_rc6-1-bbr2-c8.x86_64.rpm
  253.                
  254.                 yum install -y kernel-c8.rpm
  255.                 yum install -y kernel-headers-c8.rpm
  256.         fi
  257.        
  258.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  259.         if [[ ${bit} = "x86_64" ]]; then
  260.             kernel_version="5.4.0_rc6"
  261.             detele_kernel_head
  262.             wget -N -O linux-headers-d10.deb https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/linux-headers-5.4.0-rc6_5.4.0-rc6-1-bbr2-d10_amd64.deb
  263.             wget -N -O linux-image-d10.deb https://github.com/ylx2016/kernel/releases/download/5.4.0r6bbr2/linux-image-5.4.0-rc6_5.4.0-rc6-1-bbr2-d10_amd64.deb
  264.                    
  265.             dpkg -i linux-image-d10.deb
  266.             dpkg -i linux-headers-d10.deb
  267.         else
  268.             echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1 
  269.         fi     
  270.     fi
  271.    
  272.     cd .. && rm -rf bbr2
  273.     detele_kernel
  274.     BBR_grub
  275.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  276.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  277.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBR2${Font_color_suffix}"
  278.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBR2,是否现在重启 ? [Y/n] :" yn
  279.     [ -z "${yn}" ] && yn="y"
  280.     if [[ $yn == [Yy] ]]; then
  281.         echo -e "${Info} VPS 重启中..."
  282.         reboot
  283.     fi
  284.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  285. }
  286.  
  287. #安装Zen内核
  288. installzen(){
  289.     kernel_version="5.5.2-zen"
  290.     bit=`uname -m`
  291.     rm -rf zen
  292.     mkdir zen && cd zen
  293.     if [[ "${release}" == "centos" ]]; then
  294.         if [[ ${version} = "7" ]]; then
  295.             if [[ ${bit} = "x86_64" ]]; then
  296.                 kernel_version="5.5.10_zen"
  297.                 detele_kernel_head
  298.                 wget -N -O kernel-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EfQb4N8c2bxDlF3mj3SBVHIBGFSg_d1uR4LFzzT0Ii5FWA?download=1
  299.                 wget -N -O kernel-headers-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EfKgMa8vsZBOt0zwXM_lHcUBOYlyH1CyRHrYSRJ5r6a0EQ?download=1
  300.                
  301.                 yum install -y kernel-c7.rpm
  302.                 yum install -y kernel-headers-c7.rpm
  303.             else
  304.                 echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  305.             fi
  306.         elif [[ ${version} = "8" ]]; then
  307.                 kernel_version="5.5.2_zen"
  308.                 detele_kernel_head
  309.                 wget -N -O kernel-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.5.2zen/kernel-5.5.2_zen-1-c8.x86_64.rpm
  310.                 wget -N -O kernel-headers-c8.rpm https://github.com/ylx2016/kernel/releases/download/5.5.2zen/kernel-headers-5.5.2_zen-1-c8.x86_64.rpm
  311.                
  312.                 yum install -y kernel-c8.rpm
  313.                 yum install -y kernel-headers-c8.rpm   
  314.         fi
  315.        
  316.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  317.         if [[ ${bit} = "x86_64" ]]; then
  318.             kernel_version="5.5.10-zen"
  319.             detele_kernel_head
  320.             wget -N -O linux-headers-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EShzFq8Jlv1PthbYlNNvLjIB2-hktrkPXxwd9mqcXgmcyg?download=1
  321.             wget -N -O linux-image-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/ERXzOc-2BzJInOxBgKo62OkBgcI9-O-fw0M8U2B4NazuLg?download=1
  322.                    
  323.             dpkg -i linux-image-d10.deb
  324.             dpkg -i linux-headers-d10.deb  
  325.         else
  326.             echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1 
  327.         fi     
  328.     fi
  329.    
  330.     cd .. && rm -rf zen
  331.     detele_kernel
  332.     BBR_grub
  333.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  334.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  335.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBR${Font_color_suffix}"
  336.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBR,是否现在重启 ? [Y/n] :" yn
  337.     [ -z "${yn}" ] && yn="y"
  338.     if [[ $yn == [Yy] ]]; then
  339.         echo -e "${Info} VPS 重启中..."
  340.         reboot
  341.     fi
  342.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  343. }
  344.  
  345. #安装bbrplus 新内核
  346. installbbrplusnew(){
  347.     kernel_version="4.14.182-bbrplus"
  348.     bit=`uname -m`
  349.     rm -rf bbrplusnew
  350.     mkdir bbrplusnew && cd bbrplusnew
  351.     if [[ "${release}" == "centos" ]]; then
  352.         if [[ ${version} = "7" ]]; then
  353.             if [[ ${bit} = "x86_64" ]]; then
  354.                 kernel_version="4.14.182_bbrplus"
  355.                 detele_kernel_head
  356.                 wget -N -O kernel-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EWtxHt1RiAlHgqERl5bvYzcBUrkKa_n1mWQ-uM2-Na7gmQ?download=1
  357.                 wget -N -O kernel-headers-c7.rpm https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EYkNoi17pKJBi7KnhUGRqEIBEK_26-bzkCL-fuQYZmrHWA?download=1
  358.                
  359.                 yum install -y kernel-c7.rpm
  360.                 yum install -y kernel-headers-c7.rpm
  361.             else
  362.                 echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  363.             fi
  364.         fi
  365.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  366.         if [[ ${bit} = "x86_64" ]]; then
  367.             kernel_version="4.14.182-bbrplus"
  368.             detele_kernel_head
  369.             wget -N -O linux-headers-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/Ef9pJn1wp-pBk4FIPxT1qBoBqpWhTVCawoKzEB0_vpiMRw?download=1
  370.             wget -N -O linux-image-d10.deb https://chinagz2018-my.sharepoint.com/:u:/g/personal/ylx_chinagz2018_onmicrosoft_com/EaFJshr8za9Bq9FGjEBLds0B4ZfrYThLH8E35xe9-qWX_Q?download=1
  371.                    
  372.             dpkg -i linux-image-d10.deb
  373.             dpkg -i linux-headers-d10.deb
  374.         else
  375.             echo -e "${Error} 还在用32位内核,别再见了 !" && exit 1
  376.         fi
  377.     fi
  378.  
  379.     cd .. && rm -rf bbrplusnew
  380.     detele_kernel
  381.     BBR_grub
  382.     echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  383.     echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  384.     echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}BBRplus${Font_color_suffix}"
  385.     stty erase '^H' && read -p "需要重启VPS后,才能开启BBRplus,是否现在重启 ? [Y/n] :" yn
  386.     [ -z "${yn}" ] && yn="y"
  387.     if [[ $yn == [Yy] ]]; then
  388.         echo -e "${Info} VPS 重启中..."
  389.         reboot
  390.     fi
  391.     #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  392.  
  393. }
  394.  
  395. #启用BBR+fq
  396. startbbrfq(){
  397.     remove_bbr_lotserver
  398.     echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/99-sysctl.conf
  399.     echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/99-sysctl.conf
  400.     sysctl --system
  401.     echo -e "${Info}BBR+FQ修改成功,重启生效!"
  402. }
  403.  
  404. #启用BBR+fq_pie
  405. startbbrfqpie(){
  406.     remove_bbr_lotserver
  407.     echo "net.core.default_qdisc=fq_pie" >> /etc/sysctl.d/99-sysctl.conf
  408.     echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/99-sysctl.conf
  409.     sysctl --system
  410.     echo -e "${Info}BBR+FQ_PIE修改成功,重启生效!"
  411. }
  412.  
  413. #启用BBR+cake
  414. startbbrcake(){
  415.     remove_bbr_lotserver
  416.     echo "net.core.default_qdisc=cake" >> /etc/sysctl.d/99-sysctl.conf
  417.     echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.d/99-sysctl.conf
  418.     sysctl --system
  419.     echo -e "${Info}BBR+cake修改成功,重启生效!"
  420. }
  421.  
  422. #启用BBRplus
  423. startbbrplus(){
  424.     remove_bbr_lotserver
  425.     echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/99-sysctl.conf
  426.     echo "net.ipv4.tcp_congestion_control=bbrplus" >> /etc/sysctl.d/99-sysctl.conf
  427.     sysctl --system
  428.     echo -e "${Info}BBRplus修改成功,重启生效!"
  429. }
  430.  
  431. #启用Lotserver
  432. startlotserver(){
  433.     remove_bbr_lotserver
  434.     if [[ "${release}" == "centos" ]]; then
  435.         yum install ethtool
  436.     else
  437.         apt-get update
  438.         apt-get install ethtool
  439.     fi
  440.     #bash <(wget -qO- https://git.io/lotServerInstall.sh) install
  441.     bash <(wget --no-check-certificate -qO- https://github.com/xidcn/LotServer_Vicer/raw/master/Install.sh) install
  442.     sed -i '/advinacc/d' /appex/etc/config
  443.     sed -i '/maxmode/d' /appex/etc/config
  444.     echo -e "advinacc=\"1\"
  445. maxmode=\"1\"">>/appex/etc/config
  446.     /appex/bin/lotServer.sh restart
  447.     start_menu
  448. }
  449.  
  450. #启用BBR2+FQ
  451. startbbr2fq(){
  452.     remove_bbr_lotserver
  453.     echo "net.ipv4.tcp_ecn=0" >> /etc/sysctl.d/99-sysctl.conf
  454.     echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/99-sysctl.conf
  455.     echo "net.ipv4.tcp_congestion_control=bbr2" >> /etc/sysctl.d/99-sysctl.conf
  456.     sysctl --system
  457.     echo -e "${Info}BBR2修改成功,重启生效!"
  458. }
  459.  
  460. #启用BBR2+CAKE
  461. startbbr2cake(){
  462.     remove_bbr_lotserver
  463.     echo "net.ipv4.tcp_ecn=0" >> /etc/sysctl.d/99-sysctl.conf
  464.     echo "net.core.default_qdisc=cake" >> /etc/sysctl.d/99-sysctl.conf
  465.     echo "net.ipv4.tcp_congestion_control=bbr2" >> /etc/sysctl.d/99-sysctl.conf
  466.     sysctl --system
  467.     echo -e "${Info}BBR2修改成功,重启生效!"
  468. }
  469.  
  470. #启用BBR2+FQ+ecn
  471. startbbr2fqecn(){
  472.     remove_bbr_lotserver
  473.     echo "net.ipv4.tcp_ecn=1" >> /etc/sysctl.d/99-sysctl.conf
  474.     echo "net.core.default_qdisc=fq" >> /etc/sysctl.d/99-sysctl.conf
  475.     echo "net.ipv4.tcp_congestion_control=bbr2" >> /etc/sysctl.d/99-sysctl.conf
  476.     sysctl --system
  477.     echo -e "${Info}BBR2修改成功,重启生效!"
  478. }
  479.  
  480. #启用BBR2+CAKE+ecn
  481. startbbr2cakeecn(){
  482.     remove_bbr_lotserver
  483.     echo "net.ipv4.tcp_ecn=1" >> /etc/sysctl.d/99-sysctl.conf
  484.     echo "net.core.default_qdisc=cake" >> /etc/sysctl.d/99-sysctl.conf
  485.     echo "net.ipv4.tcp_congestion_control=bbr2" >> /etc/sysctl.d/99-sysctl.conf
  486.     sysctl --system
  487.     echo -e "${Info}BBR2修改成功,重启生效!"
  488. }
  489.  
  490. #卸载bbr+锐速
  491. remove_bbr_lotserver(){
  492.     sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  493.     sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
  494.     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
  495.     sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  496.     sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  497.     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  498.     sysctl --system
  499.        
  500.     rm -rf bbrmod
  501.    
  502.     if [[ -e /appex/bin/lotServer.sh ]]; then
  503.         bash <(wget -qO- https://git.io/lotServerInstall.sh) uninstall
  504.     fi
  505.     clear
  506.     # echo -e "${Info}:清除bbr/lotserver加速完成。"
  507.     # sleep 1s
  508. }
  509.  
  510. #卸载全部加速
  511. remove_all(){
  512.     sed -i '/#!!! Do not change these settings unless you know what you are doing !!!/d' /etc/sysctl.d/99-sysctl.conf
  513.     sed -i '/#############################/d' /etc/sysctl.d/99-sysctl.conf
  514.     sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.d/99-sysctl.conf
  515.     sed -i '/net.ipv4.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  516.     sed -i '/net.ipv4.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  517.     sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  518.     sed -i '/net.ipv6.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  519.     sed -i '/net.ipv6.conf.lo.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  520.     sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  521.     sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  522.     sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  523.     sed -i '/net.ipv6.conf.all.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  524.     sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  525.     sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  526.     sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.d/99-sysctl.conf
  527.     sed -i '/net.core.netdev_budget/d' /etc/sysctl.d/99-sysctl.conf
  528.     sed -i '/net.core.netdev_budget_usecs/d' /etc/sysctl.d/99-sysctl.conf
  529.     sed -i '/fs.file-max /d' /etc/sysctl.d/99-sysctl.conf
  530.     sed -i '/net.core.rmem_max/d' /etc/sysctl.d/99-sysctl.conf
  531.     sed -i '/net.core.wmem_max/d' /etc/sysctl.d/99-sysctl.conf
  532.     sed -i '/net.core.rmem_default/d' /etc/sysctl.d/99-sysctl.conf
  533.     sed -i '/net.core.wmem_default/d' /etc/sysctl.d/99-sysctl.conf
  534.     sed -i '/net.core.somaxconn/d' /etc/sysctl.d/99-sysctl.conf
  535.     sed -i '/net.ipv4.icmp_echo_ignore_all/d' /etc/sysctl.d/99-sysctl.conf
  536.     sed -i '/net.ipv4.icmp_echo_ignore_broadcasts/d' /etc/sysctl.d/99-sysctl.conf
  537.     sed -i '/net.ipv4.icmp_ignore_bogus_error_responses/d' /etc/sysctl.d/99-sysctl.conf
  538.     sed -i '/net.ipv4.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  539.     sed -i '/net.ipv4.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  540.     sed -i '/net.ipv4.conf.all.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  541.     sed -i '/net.ipv4.conf.default.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  542.     sed -i '/net.ipv4.conf.all.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  543.     sed -i '/net.ipv4.conf.default.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  544.     sed -i '/net.ipv4.conf.default.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  545.     sed -i '/net.ipv4.conf.all.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  546.     sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.d/99-sysctl.conf
  547.     sed -i '/net.ipv4.tcp_keepalive_intvl/d' /etc/sysctl.d/99-sysctl.conf
  548.     sed -i '/net.ipv4.tcp_keepalive_probes/d' /etc/sysctl.d/99-sysctl.conf
  549.     sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.d/99-sysctl.conf
  550.     sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.d/99-sysctl.conf
  551.     sed -i '/net.ipv4.tcp_rfc1337/d' /etc/sysctl.d/99-sysctl.conf
  552.     sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.d/99-sysctl.conf
  553.     sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.d/99-sysctl.conf
  554.     sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.d/99-sysctl.conf
  555.     sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.d/99-sysctl.conf
  556.     sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.d/99-sysctl.conf
  557.     sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.d/99-sysctl.conf
  558.     sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.d/99-sysctl.conf
  559.     sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.d/99-sysctl.conf
  560.     sed -i '/net.ipv4.udp_rmem_min/d' /etc/sysctl.d/99-sysctl.conf
  561.     sed -i '/net.ipv4.udp_wmem_min/d' /etc/sysctl.d/99-sysctl.conf
  562.     sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.d/99-sysctl.conf
  563.     sed -i '/net.ipv4.conf.all.arp_ignore /d' /etc/sysctl.d/99-sysctl.conf
  564.     sed -i '/net.ipv4.conf.default.arp_ignore/d' /etc/sysctl.d/99-sysctl.conf
  565.     sed -i '/net.ipv4.conf.all.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  566.     sed -i '/net.ipv4.conf.default.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  567.     sed -i '/net.ipv4.tcp_autocorking/d' /etc/sysctl.d/99-sysctl.conf
  568.     sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.d/99-sysctl.conf
  569.     sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.d/99-sysctl.conf
  570.     sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
  571.     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
  572.     sed -i '/net.ipv4.tcp_notsent_lowat/d' /etc/sysctl.d/99-sysctl.conf
  573.     sed -i '/net.ipv4.tcp_no_metrics_save/d' /etc/sysctl.d/99-sysctl.conf
  574.     sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  575.     sed -i '/net.ipv4.tcp_ecn_fallback/d' /etc/sysctl.d/99-sysctl.conf
  576.     sed -i '/net.ipv4.tcp_frto/d' /etc/sysctl.d/99-sysctl.conf
  577.     sed -i '/net.ipv6.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  578.     sed -i '/net.ipv6.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  579.     sed -i '/vm.swappiness/d' /etc/sysctl.d/99-sysctl.conf
  580.     sed -i '/net.ipv4.ip_unprivileged_port_start/d' /etc/sysctl.d/99-sysctl.conf
  581.     sed -i '/vm.overcommit_memory/d' /etc/sysctl.d/99-sysctl.conf
  582.     sed -i '/net.ipv4.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  583.     sed -i '/net.ipv4.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  584.     sed -i '/net.ipv4.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  585.     sed -i '/net.ipv6.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  586.     sed -i '/net.ipv6.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  587.     sed -i '/net.ipv6.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  588.     sed -i '/net.netfilter.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  589.     sed -i '/net.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  590.    
  591.     sed -i '/#!!! Do not change these settings unless you know what you are doing !!!/d' /etc/sysctl.conf
  592.     sed -i '/#############################/d' /etc/sysctl.conf
  593.     sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  594.     sed -i '/net.ipv4.conf.all.forwarding/d' /etc/sysctl.conf
  595.     sed -i '/net.ipv4.conf.default.forwarding/d' /etc/sysctl.conf
  596.     sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.conf
  597.     sed -i '/net.ipv6.conf.default.forwarding/d' /etc/sysctl.conf
  598.     sed -i '/net.ipv6.conf.lo.forwarding/d' /etc/sysctl.conf
  599.     sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.conf
  600.     sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.conf
  601.     sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.conf
  602.     sed -i '/net.ipv6.conf.all.accept_ra/d' /etc/sysctl.conf
  603.     sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.conf
  604.     sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.conf
  605.     sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  606.     sed -i '/net.core.netdev_budget/d' /etc/sysctl.conf
  607.     sed -i '/net.core.netdev_budget_usecs/d' /etc/sysctl.conf
  608.     sed -i '/fs.file-max /d' /etc/sysctl.conf
  609.     sed -i '/net.core.rmem_max/d' /etc/sysctl.conf
  610.     sed -i '/net.core.wmem_max/d' /etc/sysctl.conf
  611.     sed -i '/net.core.rmem_default/d' /etc/sysctl.conf
  612.     sed -i '/net.core.wmem_default/d' /etc/sysctl.conf
  613.     sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  614.     sed -i '/net.ipv4.icmp_echo_ignore_all/d' /etc/sysctl.conf
  615.     sed -i '/net.ipv4.icmp_echo_ignore_broadcasts/d' /etc/sysctl.conf
  616.     sed -i '/net.ipv4.icmp_ignore_bogus_error_responses/d' /etc/sysctl.conf
  617.     sed -i '/net.ipv4.conf.all.accept_redirects/d' /etc/sysctl.conf
  618.     sed -i '/net.ipv4.conf.default.accept_redirects/d' /etc/sysctl.conf
  619.     sed -i '/net.ipv4.conf.all.secure_redirects/d' /etc/sysctl.conf
  620.     sed -i '/net.ipv4.conf.default.secure_redirects/d' /etc/sysctl.conf
  621.     sed -i '/net.ipv4.conf.all.send_redirects/d' /etc/sysctl.conf
  622.     sed -i '/net.ipv4.conf.default.send_redirects/d' /etc/sysctl.conf
  623.     sed -i '/net.ipv4.conf.default.rp_filter/d' /etc/sysctl.conf
  624.     sed -i '/net.ipv4.conf.all.rp_filter/d' /etc/sysctl.conf
  625.     sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.conf
  626.     sed -i '/net.ipv4.tcp_keepalive_intvl/d' /etc/sysctl.conf
  627.     sed -i '/net.ipv4.tcp_keepalive_probes/d' /etc/sysctl.conf
  628.     sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
  629.     sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  630.     sed -i '/net.ipv4.tcp_rfc1337/d' /etc/sysctl.conf
  631.     sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
  632.     sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  633.     sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  634.     sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  635.     sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  636.     sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
  637.     sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.conf
  638.     sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.conf
  639.     sed -i '/net.ipv4.udp_rmem_min/d' /etc/sysctl.conf
  640.     sed -i '/net.ipv4.udp_wmem_min/d' /etc/sysctl.conf
  641.     sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.conf
  642.     sed -i '/net.ipv4.conf.all.arp_ignore /d' /etc/sysctl.conf
  643.     sed -i '/net.ipv4.conf.default.arp_ignore/d' /etc/sysctl.conf
  644.     sed -i '/net.ipv4.conf.all.arp_announce/d' /etc/sysctl.conf
  645.     sed -i '/net.ipv4.conf.default.arp_announce/d' /etc/sysctl.conf
  646.     sed -i '/net.ipv4.tcp_autocorking/d' /etc/sysctl.conf
  647.     sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
  648.     sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  649.     sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  650.     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  651.     sed -i '/net.ipv4.tcp_notsent_lowat/d' /etc/sysctl.conf
  652.     sed -i '/net.ipv4.tcp_no_metrics_save/d' /etc/sysctl.conf
  653.     sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  654.     sed -i '/net.ipv4.tcp_ecn_fallback/d' /etc/sysctl.conf
  655.     sed -i '/net.ipv4.tcp_frto/d' /etc/sysctl.conf
  656.     sed -i '/net.ipv6.conf.all.accept_redirects/d' /etc/sysctl.conf
  657.     sed -i '/net.ipv6.conf.default.accept_redirects/d' /etc/sysctl.conf
  658.     sed -i '/vm.swappiness/d' /etc/sysctl.conf
  659.     sed -i '/net.ipv4.ip_unprivileged_port_start/d' /etc/sysctl.conf
  660.     sed -i '/vm.overcommit_memory/d' /etc/sysctl.conf
  661.     sed -i '/net.ipv4.neigh.default.gc_thresh3/d' /etc/sysctl.conf
  662.     sed -i '/net.ipv4.neigh.default.gc_thresh2/d' /etc/sysctl.conf
  663.     sed -i '/net.ipv4.neigh.default.gc_thresh1/d' /etc/sysctl.conf
  664.     sed -i '/net.ipv6.neigh.default.gc_thresh3/d' /etc/sysctl.conf
  665.     sed -i '/net.ipv6.neigh.default.gc_thresh2/d' /etc/sysctl.conf
  666.     sed -i '/net.ipv6.neigh.default.gc_thresh1/d' /etc/sysctl.conf
  667.     sed -i '/net.netfilter.nf_conntrack_max/d' /etc/sysctl.conf
  668.     sed -i '/net.nf_conntrack_max/d' /etc/sysctl.conf
  669.     sysctl --system
  670.     sed -i '/DefaultTimeoutStartSec/d' /etc/systemd/system.conf
  671.     sed -i '/DefaultTimeoutStopSec/d' /etc/systemd/system.conf
  672.     sed -i '/DefaultRestartSec/d' /etc/systemd/system.conf
  673.     sed -i '/DefaultLimitCORE/d' /etc/systemd/system.conf
  674.     sed -i '/DefaultLimitNOFILE/d' /etc/systemd/system.conf
  675.     sed -i '/DefaultLimitNPROC/d' /etc/systemd/system.conf
  676.    
  677.     sed -i '/soft nofile/d' /etc/security/limits.conf
  678.     sed -i '/hard nofile/d' /etc/security/limits.conf
  679.     sed -i '/soft nproc/d' /etc/security/limits.conf
  680.     sed -i '/hard nproc/d' /etc/security/limits.conf
  681.  
  682.     sed -i '/ulimit -SHn/d' /etc/profile
  683.     sed -i '/ulimit -SHn/d' /etc/profile
  684.     sed -i '/required pam_limits.so/d' /etc/pam.d/common-session
  685.  
  686.     systemctl daemon-reload
  687.    
  688.     rm -rf bbrmod
  689.     sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
  690.     sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
  691.     sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
  692.     sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  693.     sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  694.     sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  695.     sed -i '/fs.file-max/d' /etc/sysctl.conf
  696.     sed -i '/net.core.rmem_max/d' /etc/sysctl.conf
  697.     sed -i '/net.core.wmem_max/d' /etc/sysctl.conf
  698.     sed -i '/net.core.rmem_default/d' /etc/sysctl.conf
  699.     sed -i '/net.core.wmem_default/d' /etc/sysctl.conf
  700.     sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  701.     sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  702.     sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  703.     sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  704.     sed -i '/net.ipv4.tcp_tw_recycle/d' /etc/sysctl.conf
  705.     sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  706.     sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.conf
  707.     sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  708.     sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  709.     sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  710.     sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.conf
  711.     sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.conf
  712.     sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.conf
  713.     sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  714.     sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
  715.     sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  716.     sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  717.     sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  718.     sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  719.     sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  720.     sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  721.     sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
  722.     sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
  723.     sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
  724.     sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  725.     sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  726.     sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
  727.     sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
  728.     if [[ -e /appex/bin/lotServer.sh ]]; then
  729.         bash <(wget -qO- https://git.io/lotServerInstall.sh) uninstall
  730.     fi
  731.     clear
  732.     echo -e "${Info}:清除加速完成。"
  733.     sleep 1s
  734. }
  735.  
  736. #优化系统配置
  737. optimizing_system(){
  738.     sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
  739.     sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
  740.     sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
  741.     sed -i '/fs.file-max/d' /etc/sysctl.conf
  742.     sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
  743.     sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  744.     sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  745.     sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  746.     sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  747.     sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  748.     sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  749.     sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
  750.     sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
  751.     sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
  752.     sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  753.     sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  754.     sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
  755.     sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
  756.     sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  757.  
  758. echo "net.ipv4.tcp_retries2 = 8
  759. net.ipv4.tcp_slow_start_after_idle = 0
  760. fs.file-max = 1000000
  761. fs.inotify.max_user_instances = 8192
  762. net.ipv4.tcp_syncookies = 1
  763. net.ipv4.tcp_fin_timeout = 30
  764. net.ipv4.tcp_tw_reuse = 1
  765. net.ipv4.ip_local_port_range = 1024 65000
  766. net.ipv4.tcp_max_syn_backlog = 16384
  767. net.ipv4.tcp_max_tw_buckets = 6000
  768. net.ipv4.route.gc_timeout = 100
  769. net.ipv4.tcp_syn_retries = 1
  770. net.ipv4.tcp_synack_retries = 1
  771. net.core.somaxconn = 32768
  772. net.core.netdev_max_backlog = 32768
  773. net.ipv4.tcp_timestamps = 0
  774. net.ipv4.tcp_max_orphans = 32768
  775. # forward ipv4
  776. #net.ipv4.ip_forward = 1">>/etc/sysctl.conf
  777. sysctl -p
  778.     echo "*               soft    nofile           1000000
  779. *               hard    nofile          1000000">/etc/security/limits.conf
  780.     echo "ulimit -SHn 1000000">>/etc/profile
  781.     read -p "需要重启VPS后,才能生效系统优化配置,是否现在重启 ? [Y/n] :" yn
  782.     [ -z "${yn}" ] && yn="y"
  783.     if [[ $yn == [Yy] ]]; then
  784.         echo -e "${Info} VPS 重启中..."
  785.         reboot
  786.     fi
  787. }
  788.  
  789. optimizing_system_johnrosen1()
  790. {
  791. sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.d/99-sysctl.conf
  792. sed -i '/net.ipv4.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  793. sed -i '/net.ipv4.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  794. sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  795. sed -i '/net.ipv6.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  796. sed -i '/net.ipv6.conf.lo.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  797. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  798. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  799. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  800. sed -i '/net.ipv6.conf.all.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  801. sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  802. sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  803. sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.d/99-sysctl.conf
  804. sed -i '/net.core.netdev_budget/d' /etc/sysctl.d/99-sysctl.conf
  805. sed -i '/net.core.netdev_budget_usecs/d' /etc/sysctl.d/99-sysctl.conf
  806. sed -i '/fs.file-max /d' /etc/sysctl.d/99-sysctl.conf
  807. sed -i '/net.core.rmem_max/d' /etc/sysctl.d/99-sysctl.conf
  808. sed -i '/net.core.wmem_max/d' /etc/sysctl.d/99-sysctl.conf
  809. sed -i '/net.core.rmem_default/d' /etc/sysctl.d/99-sysctl.conf
  810. sed -i '/net.core.wmem_default/d' /etc/sysctl.d/99-sysctl.conf
  811. sed -i '/net.core.somaxconn/d' /etc/sysctl.d/99-sysctl.conf
  812. sed -i '/net.ipv4.icmp_echo_ignore_all/d' /etc/sysctl.d/99-sysctl.conf
  813. sed -i '/net.ipv4.icmp_echo_ignore_broadcasts/d' /etc/sysctl.d/99-sysctl.conf
  814. sed -i '/net.ipv4.icmp_ignore_bogus_error_responses/d' /etc/sysctl.d/99-sysctl.conf
  815. sed -i '/net.ipv4.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  816. sed -i '/net.ipv4.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  817. sed -i '/net.ipv4.conf.all.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  818. sed -i '/net.ipv4.conf.default.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  819. sed -i '/net.ipv4.conf.all.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  820. sed -i '/net.ipv4.conf.default.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  821. sed -i '/net.ipv4.conf.default.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  822. sed -i '/net.ipv4.conf.all.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  823. sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.d/99-sysctl.conf
  824. sed -i '/net.ipv4.tcp_keepalive_intvl/d' /etc/sysctl.d/99-sysctl.conf
  825. sed -i '/net.ipv4.tcp_keepalive_probes/d' /etc/sysctl.d/99-sysctl.conf
  826. sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.d/99-sysctl.conf
  827. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.d/99-sysctl.conf
  828. sed -i '/net.ipv4.tcp_rfc1337/d' /etc/sysctl.d/99-sysctl.conf
  829. sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.d/99-sysctl.conf
  830. sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.d/99-sysctl.conf
  831. sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.d/99-sysctl.conf
  832. sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.d/99-sysctl.conf
  833. sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.d/99-sysctl.conf
  834. sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.d/99-sysctl.conf
  835. sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.d/99-sysctl.conf
  836. sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.d/99-sysctl.conf
  837. sed -i '/net.ipv4.udp_rmem_min/d' /etc/sysctl.d/99-sysctl.conf
  838. sed -i '/net.ipv4.udp_wmem_min/d' /etc/sysctl.d/99-sysctl.conf
  839. sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.d/99-sysctl.conf
  840. sed -i '/net.ipv4.conf.all.arp_ignore /d' /etc/sysctl.d/99-sysctl.conf
  841. sed -i '/net.ipv4.conf.default.arp_ignore/d' /etc/sysctl.d/99-sysctl.conf
  842. sed -i '/net.ipv4.conf.all.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  843. sed -i '/net.ipv4.conf.default.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  844. sed -i '/net.ipv4.tcp_autocorking/d' /etc/sysctl.d/99-sysctl.conf
  845. sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.d/99-sysctl.conf
  846. sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.d/99-sysctl.conf
  847. sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
  848. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
  849. sed -i '/net.ipv4.tcp_notsent_lowat/d' /etc/sysctl.d/99-sysctl.conf
  850. sed -i '/net.ipv4.tcp_no_metrics_save/d' /etc/sysctl.d/99-sysctl.conf
  851. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  852. sed -i '/net.ipv4.tcp_ecn_fallback/d' /etc/sysctl.d/99-sysctl.conf
  853. sed -i '/net.ipv4.tcp_frto/d' /etc/sysctl.d/99-sysctl.conf
  854. sed -i '/net.ipv6.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  855. sed -i '/net.ipv6.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  856. sed -i '/vm.swappiness/d' /etc/sysctl.d/99-sysctl.conf
  857. sed -i '/net.ipv4.ip_unprivileged_port_start/d' /etc/sysctl.d/99-sysctl.conf
  858. sed -i '/vm.overcommit_memory/d' /etc/sysctl.d/99-sysctl.conf
  859. sed -i '/net.ipv4.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  860. sed -i '/net.ipv4.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  861. sed -i '/net.ipv4.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  862. sed -i '/net.ipv6.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  863. sed -i '/net.ipv6.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  864. sed -i '/net.ipv6.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  865. sed -i '/net.netfilter.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  866. sed -i '/net.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  867.  
  868. cat > '/etc/sysctl.d/99-sysctl.conf' << EOF
  869. #!!! Do not change these settings unless you know what you are doing !!!
  870. #net.ipv4.ip_forward = 1
  871. #net.ipv4.conf.all.forwarding = 1
  872. #net.ipv4.conf.default.forwarding = 1
  873.  
  874. net.ipv6.conf.all.forwarding = 1
  875. net.ipv6.conf.default.forwarding = 1
  876. net.ipv6.conf.lo.forwarding = 1
  877.  
  878. net.ipv6.conf.all.disable_ipv6 = 0
  879. net.ipv6.conf.default.disable_ipv6 = 0
  880. net.ipv6.conf.lo.disable_ipv6 = 0
  881.  
  882. net.ipv6.conf.all.accept_ra = 2
  883. net.ipv6.conf.default.accept_ra = 2
  884.  
  885. net.core.netdev_max_backlog = 100000
  886. net.core.netdev_budget = 50000
  887. net.core.netdev_budget_usecs = 5000
  888. #fs.file-max = 51200
  889. net.core.rmem_max = 67108864
  890. net.core.wmem_max = 67108864
  891. net.core.rmem_default = 67108864
  892. net.core.wmem_default = 67108864
  893. net.core.somaxconn = 10000
  894.  
  895. net.ipv4.icmp_echo_ignore_all = 0
  896. net.ipv4.icmp_echo_ignore_broadcasts = 1
  897. net.ipv4.icmp_ignore_bogus_error_responses = 1
  898. net.ipv4.conf.all.accept_redirects = 0
  899. net.ipv4.conf.default.accept_redirects = 0
  900. net.ipv4.conf.all.secure_redirects = 0
  901. net.ipv4.conf.default.secure_redirects = 0
  902. net.ipv4.conf.all.send_redirects = 0
  903. net.ipv4.conf.default.send_redirects = 0
  904. net.ipv4.conf.default.rp_filter = 0
  905. net.ipv4.conf.all.rp_filter = 0
  906. net.ipv4.tcp_keepalive_time = 1200
  907. net.ipv4.tcp_keepalive_intvl = 15
  908. net.ipv4.tcp_keepalive_probes = 5
  909. net.ipv4.tcp_synack_retries = 2
  910. net.ipv4.tcp_syncookies = 0
  911. net.ipv4.tcp_rfc1337 = 0
  912. net.ipv4.tcp_timestamps = 1
  913. net.ipv4.tcp_tw_reuse = 1
  914. net.ipv4.tcp_fin_timeout = 15
  915. net.ipv4.ip_local_port_range = 10000 65000
  916. net.ipv4.tcp_max_tw_buckets = 2000000
  917. #net.ipv4.tcp_fastopen = 3
  918. net.ipv4.tcp_rmem = 4096 87380 67108864
  919. net.ipv4.tcp_wmem = 4096 65536 67108864
  920. net.ipv4.udp_rmem_min = 8192
  921. net.ipv4.udp_wmem_min = 8192
  922. net.ipv4.tcp_mtu_probing = 0
  923.  
  924. #net.ipv4.conf.all.arp_ignore = 2
  925. #net.ipv4.conf.default.arp_ignore = 2
  926. #net.ipv4.conf.all.arp_announce = 2
  927. #net.ipv4.conf.default.arp_announce = 2
  928.  
  929. net.ipv4.tcp_autocorking = 0
  930. net.ipv4.tcp_slow_start_after_idle = 0
  931. net.ipv4.tcp_max_syn_backlog = 30000
  932. net.core.default_qdisc = fq
  933. net.ipv4.tcp_congestion_control = bbr
  934. net.ipv4.tcp_notsent_lowat = 16384
  935. net.ipv4.tcp_no_metrics_save = 1
  936. net.ipv4.tcp_ecn = 2
  937. net.ipv4.tcp_ecn_fallback = 1
  938. net.ipv4.tcp_frto = 0
  939.  
  940. net.ipv6.conf.all.accept_redirects = 0
  941. net.ipv6.conf.default.accept_redirects = 0
  942. vm.swappiness = 1
  943. #net.ipv4.ip_unprivileged_port_start = 0
  944. vm.overcommit_memory = 1
  945. net.ipv4.neigh.default.gc_thresh3=8192
  946. net.ipv4.neigh.default.gc_thresh2=4096
  947. net.ipv4.neigh.default.gc_thresh1=2048
  948. net.ipv6.neigh.default.gc_thresh3=8192
  949. net.ipv6.neigh.default.gc_thresh2=4096
  950. net.ipv6.neigh.default.gc_thresh1=2048
  951. net.netfilter.nf_conntrack_max = 262144
  952. net.nf_conntrack_max = 262144
  953. EOF
  954. sysctl --system
  955. echo madvise > /sys/kernel/mm/transparent_hugepage/enabled
  956.  
  957. sed -i '/DefaultTimeoutStartSec/d' /etc/systemd/system.conf
  958. sed -i '/DefaultTimeoutStopSec/d' /etc/systemd/system.conf
  959. sed -i '/DefaultRestartSec/d' /etc/systemd/system.conf
  960. sed -i '/DefaultLimitCORE/d' /etc/systemd/system.conf
  961. sed -i '/DefaultLimitNOFILE/d' /etc/systemd/system.conf
  962. sed -i '/DefaultLimitNPROC/d' /etc/systemd/system.conf
  963.  
  964. cat > '/etc/systemd/system.conf' << EOF
  965. [Manager]
  966. #DefaultTimeoutStartSec=90s
  967. DefaultTimeoutStopSec=30s
  968. #DefaultRestartSec=100ms
  969. DefaultLimitCORE=infinity
  970. DefaultLimitNOFILE=51200
  971. DefaultLimitNPROC=51200
  972. EOF
  973.  
  974. sed -i '/soft nofile/d' /etc/security/limits.conf
  975. sed -i '/hard nofile/d' /etc/security/limits.conf
  976. sed -i '/soft nproc/d' /etc/security/limits.conf
  977. sed -i '/hard nproc/d' /etc/security/limits.conf
  978. cat > '/etc/security/limits.conf' << EOF
  979. * soft nofile 51200
  980. * hard nofile 51200
  981. * soft nproc 51200
  982. * hard nproc 51200
  983. EOF
  984. if grep -q "ulimit" /etc/profile
  985. then
  986.     :
  987. else
  988. sed -i '/ulimit -SHn/d' /etc/profile
  989. sed -i '/ulimit -SHn/d' /etc/profile
  990. echo "ulimit -SHn 51200" >> /etc/profile
  991. echo "ulimit -SHu 51200" >> /etc/profile
  992. fi
  993. if grep -q "pam_limits.so" /etc/pam.d/common-session
  994. then
  995.     :
  996. else
  997. sed -i '/required pam_limits.so/d' /etc/pam.d/common-session
  998. echo "session required pam_limits.so" >> /etc/pam.d/common-session
  999. fi
  1000. systemctl daemon-reload
  1001. }
  1002.  
  1003. #更新脚本
  1004. Update_Shell(){
  1005.     echo -e "当前版本为 [ ${sh_ver} ],开始检测最新版本..."
  1006.     sh_new_ver=$(wget -qO- "https://${github}/tcp.sh"|grep 'sh_ver="'|awk -F "=" '{print $NF}'|sed 's/\"//g'|head -1)
  1007.     [[ -z ${sh_new_ver} ]] && echo -e "${Error} 检测最新版本失败 !" && start_menu
  1008.     if [[ ${sh_new_ver} != ${sh_ver} ]]; then
  1009.         echo -e "发现新版本[ ${sh_new_ver} ],是否更新?[Y/n]"
  1010.         read -p "(默认: y):" yn
  1011.         [[ -z "${yn}" ]] && yn="y"
  1012.         if [[ ${yn} == [Yy] ]]; then
  1013.             wget -N "https://${github}/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
  1014.             echo -e "脚本已更新为最新版本[ ${sh_new_ver} ] !"
  1015.         else
  1016.             echo && echo "  已取消..." && echo
  1017.         fi
  1018.     else
  1019.         echo -e "当前已是最新版本[ ${sh_new_ver} ] !"
  1020.         sleep 2s && ./tcp.sh
  1021.     fi
  1022. }
  1023.  
  1024. #切换到不卸载内核版本
  1025. gototcpx(){
  1026.     clear
  1027.     wget -N "https://github.000060000.xyz/tcpx.sh" && chmod +x tcpx.sh && ./tcpx.sh
  1028. }
  1029.  
  1030. #切换到秋水逸冰BBR安装脚本
  1031. gototeddysun_bbr(){
  1032.     clear
  1033.     wget https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
  1034. }
  1035.  
  1036. #切换到一键DD安装系统脚本 新手勿入
  1037. gotodd(){
  1038.     clear
  1039.     wget -qO ~/Network-Reinstall-System-Modify.sh 'https://github.com/ylx2016/reinstall/raw/master/Network-Reinstall-System-Modify.sh' && chmod a+x ~/Network-Reinstall-System-Modify.sh && bash ~/Network-Reinstall-System-Modify.sh -UI_Options
  1040. }
  1041.  
  1042. #开始菜单
  1043. start_menu(){
  1044. clear
  1045. echo && echo -e " TCP加速 一键安装管理脚本 ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix}
  1046. 更新内容及反馈:  https://blog.ylx.me/archives/783.html 运行./tcp.sh再次调用本脚本 母鸡慎用
  1047.  
  1048. ${Green_font_prefix}0.${Font_color_suffix} 升级脚本
  1049. ${Green_font_prefix}9.${Font_color_suffix} 切换到不卸载内核版本
  1050. ${Green_font_prefix}88.${Font_color_suffix} 切换到秋水逸冰BBR安装脚本
  1051. ${Green_font_prefix}100.${Font_color_suffix} 切换到一键DD安装系统脚本 自负其责 新手勿入
  1052. ————————————内核管理————————————
  1053. ${Green_font_prefix}1.${Font_color_suffix} 安装 BBR原版内核 - 5.6.15/5.10.2
  1054. ${Green_font_prefix}2.${Font_color_suffix} 安装 BBRplus版内核 - 4.14.129
  1055. ${Green_font_prefix}3.${Font_color_suffix} 安装 Lotserver(锐速)内核 - 多种
  1056. ${Green_font_prefix}4.${Font_color_suffix} 安装 xanmod版内核 - 5.5.1/5.10.2
  1057. ${Green_font_prefix}5.${Font_color_suffix} 安装 BBR2测试版内核 - 5.4.0
  1058. ${Green_font_prefix}7.${Font_color_suffix} 安装 BBRplus新版内核 - 4.14.182
  1059. ————————————加速管理————————————
  1060. ${Green_font_prefix}11.${Font_color_suffix} 使用BBR+FQ加速
  1061. ${Green_font_prefix}19.${Font_color_suffix} 使用BBR+FQ_PIE加速
  1062. ${Green_font_prefix}12.${Font_color_suffix} 使用BBR+CAKE加速
  1063. ${Green_font_prefix}13.${Font_color_suffix} 使用BBRplus+FQ版加速
  1064. ${Green_font_prefix}14.${Font_color_suffix} 使用Lotserver(锐速)加速
  1065. ${Green_font_prefix}15.${Font_color_suffix} 使用BBR2+FQ加速
  1066. ${Green_font_prefix}16.${Font_color_suffix} 使用BBR2+CAKE加速
  1067. ${Green_font_prefix}17.${Font_color_suffix} 使用BBR2+FQ+ECN加速
  1068. ${Green_font_prefix}18.${Font_color_suffix} 使用BBR2+CAKE+ECN加速
  1069. ————————————杂项管理————————————
  1070. ${Green_font_prefix}21.${Font_color_suffix} 卸载全部加速
  1071. ${Green_font_prefix}22.${Font_color_suffix} 系统配置优化
  1072. ${Green_font_prefix}24.${Font_color_suffix} 应用johnrosen1的优化方案
  1073. ${Green_font_prefix}23.${Font_color_suffix} 退出脚本
  1074. ————————————————————————————————" && echo
  1075.  
  1076.     check_status
  1077.     echo -e " 当前内核为:${Font_color_suffix}${kernel_version_r}${Font_color_suffix}"
  1078.     if [[ ${kernel_status} == "noinstall" ]]; then
  1079.         echo -e " 当前状态: ${Green_font_prefix}未安装${Font_color_suffix} 加速内核 ${Red_font_prefix}请先安装内核${Font_color_suffix}"
  1080.     else
  1081.         echo -e " 当前状态: ${Green_font_prefix}已安装${Font_color_suffix} ${_font_prefix}${kernel_status}${Font_color_suffix} 加速内核 , ${Green_font_prefix}${run_status}${Font_color_suffix}"
  1082.        
  1083.     fi
  1084.     echo -e " 当前拥塞控制算法为: ${Green_font_prefix}${net_congestion_control}${Font_color_suffix} 当前队列算法为: ${Green_font_prefix}${net_qdisc}${Font_color_suffix} "
  1085.    
  1086. echo
  1087. read -p " 请输入数字 :" num
  1088. case "$num" in
  1089.     0)
  1090.     Update_Shell
  1091.     ;;
  1092.     1)
  1093.     check_sys_bbr
  1094.     ;;
  1095.     2)
  1096.     check_sys_bbrplus
  1097.     ;;
  1098.     3)
  1099.     check_sys_Lotsever
  1100.     ;;
  1101.     4)
  1102.     check_sys_xanmod
  1103.     ;;
  1104.     5)
  1105.     check_sys_bbr2
  1106.     ;;
  1107.     6)
  1108.     check_sys_zen
  1109.     ;;
  1110.     7)
  1111.     check_sys_bbrplusnew   
  1112.     ;;
  1113.     88)
  1114.     gototeddysun_bbr
  1115.     ;;
  1116.     9)
  1117.     gototcpx
  1118.     ;;
  1119.     100)
  1120.     gotodd
  1121.     ;;
  1122.     11)
  1123.     startbbrfq
  1124.     ;;
  1125.     19)
  1126.     startbbrfqpie  
  1127.     ;;
  1128.     12)
  1129.     startbbrcake
  1130.     ;;
  1131.     13)
  1132.     startbbrplus
  1133.     ;;
  1134.     14)
  1135.     startlotserver
  1136.     ;;
  1137.     15)
  1138.     startbbr2fq
  1139.     ;;
  1140.     16)
  1141.     startbbr2cake
  1142.     ;;
  1143.     17)
  1144.     startbbr2fqecn
  1145.     ;;
  1146.     18)
  1147.     startbbr2cakeecn
  1148.     ;;
  1149.     21)
  1150.     remove_all
  1151.     ;;
  1152.     22)
  1153.     optimizing_system
  1154.     ;;
  1155.     24)
  1156.     optimizing_system_johnrosen1
  1157.     ;;
  1158.     23)
  1159.     exit 1
  1160.     ;;
  1161.     *)
  1162.     clear
  1163.     echo -e "${Error}:请输入正确数字 [0-23]"
  1164.     sleep 5s
  1165.     start_menu
  1166.     ;;
  1167. esac
  1168. }
  1169. #############内核管理组件#############
  1170.  
  1171. #删除多余内核
  1172. detele_kernel(){
  1173.     if [[ "${release}" == "centos" ]]; then
  1174.         rpm_total=`rpm -qa | grep kernel | grep -v "${kernel_version}" | grep -v "noarch" | wc -l`
  1175.         if [ "${rpm_total}" > "1" ]; then
  1176.             echo -e "检测到 ${rpm_total} 个其余内核,开始卸载..."
  1177.             for((integer = 1; integer <= ${rpm_total}; integer++)); do
  1178.                 rpm_del=`rpm -qa | grep kernel | grep -v "${kernel_version}" | grep -v "noarch" | head -${integer}`
  1179.                 echo -e "开始卸载 ${rpm_del} 内核..."
  1180.                 rpm --nodeps -e ${rpm_del}
  1181.                 echo -e "卸载 ${rpm_del} 内核卸载完成,继续..."
  1182.             done
  1183.             echo --nodeps -e "内核卸载完毕,继续..."
  1184.         else
  1185.             echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1
  1186.         fi
  1187.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1188.         deb_total=`dpkg -l | grep linux-image | awk '{print $2}' | grep -v "${kernel_version}" | wc -l`
  1189.         if [ "${deb_total}" > "1" ]; then
  1190.             echo -e "检测到 ${deb_total} 个其余内核,开始卸载..."
  1191.             for((integer = 1; integer <= ${deb_total}; integer++)); do
  1192.                 deb_del=`dpkg -l|grep linux-image | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer}`
  1193.                 echo -e "开始卸载 ${deb_del} 内核..."
  1194.                 apt-get purge -y ${deb_del}
  1195.                 echo -e "卸载 ${deb_del} 内核卸载完成,继续..."
  1196.             done
  1197.             echo -e "内核卸载完毕,继续..."
  1198.         else
  1199.             echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1
  1200.         fi
  1201.     fi
  1202. }
  1203.  
  1204. detele_kernel_head(){
  1205.     if [[ "${release}" == "centos" ]]; then
  1206.         rpm_total=`rpm -qa | grep kernel-headers | grep -v "${kernel_version}" | grep -v "noarch" | wc -l`
  1207.         if [ "${rpm_total}" > "1" ]; then
  1208.             echo -e "检测到 ${rpm_total} 个其余head内核,开始卸载..."
  1209.             for((integer = 1; integer <= ${rpm_total}; integer++)); do
  1210.                 rpm_del=`rpm -qa | grep kernel-headers | grep -v "${kernel_version}" | grep -v "noarch" | head -${integer}`
  1211.                 echo -e "开始卸载 ${rpm_del} headers内核..."
  1212.                 rpm --nodeps -e ${rpm_del}
  1213.                 echo -e "卸载 ${rpm_del} 内核卸载完成,继续..."
  1214.             done
  1215.             echo --nodeps -e "内核卸载完毕,继续..."
  1216.         else
  1217.             echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1
  1218.         fi
  1219.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1220.         deb_total=`dpkg -l | grep linux-headers | awk '{print $2}' | grep -v "${kernel_version}" | wc -l`
  1221.         if [ "${deb_total}" > "1" ]; then
  1222.             echo -e "检测到 ${deb_total} 个其余head内核,开始卸载..."
  1223.             for((integer = 1; integer <= ${deb_total}; integer++)); do
  1224.                 deb_del=`dpkg -l|grep linux-headers | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer}`
  1225.                 echo -e "开始卸载 ${deb_del} headers内核..."
  1226.                 apt-get purge -y ${deb_del}
  1227.                 echo -e "卸载 ${deb_del} 内核卸载完成,继续..."
  1228.             done
  1229.             echo -e "内核卸载完毕,继续..."
  1230.         else
  1231.             echo -e " 检测到 内核 数量不正确,请检查 !" && exit 1
  1232.         fi
  1233.     fi
  1234. }
  1235.  
  1236.  
  1237.  
  1238.  
  1239. #更新引导
  1240. BBR_grub(){
  1241.     if [[ "${release}" == "centos" ]]; then
  1242.         if [[ ${version} = "6" ]]; then
  1243.             if [ ! -f "/boot/grub/grub.conf" ]; then
  1244.                 echo -e "${Error} /boot/grub/grub.conf 找不到,请检查."
  1245.                 exit 1
  1246.             fi
  1247.             sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
  1248.         elif [[ ${version} = "7" ]]; then
  1249.             if [ -f "/boot/grub2/grub.cfg" ]; then
  1250.                 grub2-mkconfig  -o   /boot/grub2/grub.cfg
  1251.                 grub2-set-default 0
  1252.                 exit 1
  1253.             elif [ -f "/boot/efi/EFI/centos/grub.cfg" ]; then
  1254.                 grub2-mkconfig  -o   /boot/efi/EFI/centos/grub.cfg
  1255.                 grub2-set-default 0
  1256.                 exit 1
  1257.             else
  1258.                 echo -e "${Error} grub.cfg 找不到,请检查."
  1259.             fi
  1260.             #grub2-mkconfig  -o   /boot/grub2/grub.cfg
  1261.             #grub2-set-default 0
  1262.        
  1263.         elif [[ ${version} = "8" ]]; then
  1264.             grub2-mkconfig  -o   /boot/grub2/grub.cfg
  1265.             grubby --info=ALL|awk -F= '$1=="kernel" {print i++ " : " $2}'
  1266.         fi
  1267.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1268.         /usr/sbin/update-grub
  1269.         #exit 1
  1270.     fi
  1271. }
  1272.  
  1273. #############内核管理组件#############
  1274.  
  1275.  
  1276.  
  1277. #############系统检测组件#############
  1278.  
  1279. #检查系统
  1280. check_sys(){
  1281.     if [[ -f /etc/redhat-release ]]; then
  1282.         release="centos"
  1283.     elif cat /etc/issue | grep -q -E -i "debian"; then
  1284.         release="debian"
  1285.     elif cat /etc/issue | grep -q -E -i "ubuntu"; then
  1286.         release="ubuntu"
  1287.     elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
  1288.         release="centos"
  1289.     elif cat /proc/version | grep -q -E -i "debian"; then
  1290.         release="debian"
  1291.     elif cat /proc/version | grep -q -E -i "ubuntu"; then
  1292.         release="ubuntu"
  1293.     elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
  1294.         release="centos"
  1295.     fi
  1296.    
  1297. #处理ca证书
  1298.     if [[ "${release}" == "centos" ]]; then
  1299.         yum install ca-certificates -y
  1300.         update-ca-trust force-enable
  1301.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1302.         apt-get install ca-certificates -y
  1303.         update-ca-certificates
  1304.     fi 
  1305. }
  1306.  
  1307. #检查Linux版本
  1308. check_version(){
  1309.     if [[ -s /etc/redhat-release ]]; then
  1310.         version=`grep -oE  "[0-9.]+" /etc/redhat-release | cut -d . -f 1`
  1311.     else
  1312.         version=`grep -oE  "[0-9.]+" /etc/issue | cut -d . -f 1`
  1313.     fi
  1314.     bit=`uname -m`
  1315.     if [[ ${bit} = "x86_64" ]]; then
  1316.         bit="x64"
  1317.     else
  1318.         bit="x32"
  1319.     fi
  1320. }
  1321.  
  1322. #检查安装bbr的系统要求
  1323. check_sys_bbr(){
  1324.     check_version
  1325.     if [[ "${release}" == "centos" ]]; then
  1326.         # if [[ ${version} = "6" || ${version} = "7" || ${version} = "8" ]]; then
  1327.         if [[ ${version} = "7" || ${version} = "8" ]]; then
  1328.             installbbr
  1329.         else
  1330.             echo -e "${Error} BBR内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1331.         fi
  1332.     # elif [[ "${release}" == "debian" ]]; then
  1333.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" ]]; then
  1334.         # if [[ ${version} = "9" || ${version} = "10" ]]; then
  1335.             # installbbr
  1336.         # else
  1337.             # echo -e "${Error} BBR内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1338.         # fi
  1339.     # elif [[ "${release}" == "ubuntu" ]]; then
  1340.         # if [[ ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1341.         # if [[ ${version} = "16" || ${version} = "18" || ${version} = "20" ]]; then
  1342.             # installbbr
  1343.         # else
  1344.             # echo -e "${Error} BBR内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1345.         # fi
  1346.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1347.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1348.             installbbr
  1349.         # fi
  1350.     else
  1351.         echo -e "${Error} BBR内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1352.     fi
  1353. }
  1354.  
  1355. check_sys_bbrplus(){
  1356.     check_version
  1357.     if [[ "${release}" == "centos" ]]; then
  1358.         if [[ ${version} = "7" ]]; then
  1359.             installbbrplus
  1360.         else
  1361.             echo -e "${Error} BBRplus内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1362.         fi
  1363.     # elif [[ "${release}" == "debian" ]]; then
  1364.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" ]]; then
  1365.         # if [[ ${version} = "9" || ${version} = "10" ]]; then
  1366.             # installbbrplus
  1367.         # else
  1368.             # echo -e "${Error} BBRplus内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1369.         # fi
  1370.     # elif [[ "${release}" == "ubuntu" ]]; then
  1371.         # if [[ ${version} = "16" || ${version} = "18" || ${version} = "19" ]]; then
  1372.         # if [[ ${version} = "16" || ${version} = "18" ]]; then
  1373.             # installbbrplus
  1374.         # else
  1375.             # echo -e "${Error} BBRplus内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1376.         # fi
  1377.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1378.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1379.             installbbrplus
  1380.         # fi   
  1381.     else
  1382.         echo -e "${Error} BBRplus内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1383.     fi
  1384. }
  1385.  
  1386. check_sys_bbrplusnew(){
  1387.     check_version
  1388.     if [[ "${release}" == "centos" ]]; then
  1389.         if [[ ${version} = "7" ]]; then
  1390.             installbbrplusnew
  1391.         else
  1392.             echo -e "${Error} BBRplusNew内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1393.         fi
  1394.     # elif [[ "${release}" == "debian" ]]; then
  1395.         # if [[ ${version} = "10" ]]; then
  1396.             # installbbrplusnew
  1397.         # else
  1398.             # echo -e "${Error} BBRplusNew内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1399.         # fi
  1400.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1401.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1402.             installbbrplusnew
  1403.     else
  1404.         echo -e "${Error} BBRplusNew内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1405.     fi
  1406. }
  1407.  
  1408. check_sys_xanmod(){
  1409.     check_version
  1410.     if [[ "${release}" == "centos" ]]; then
  1411.         if [[ ${version} = "7" || ${version} = "8" ]]; then
  1412.             installxanmod
  1413.         else
  1414.             echo -e "${Error} xanmod内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1415.         fi
  1416.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1417.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1418.             installxanmod
  1419.         # fi
  1420.     # elif [[ "${release}" == "ubuntu" ]]; then
  1421.             # echo -e "${Error} xanmod内核不支持当前系统 ${release} ${version} ${bit} ,去xanmod.org 官网安装吧!" && exit 1
  1422.     else
  1423.         echo -e "${Error} xanmod内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1424.     fi
  1425. }
  1426.  
  1427. check_sys_bbr2(){
  1428.     check_version
  1429.     if [[ "${release}" == "centos" ]]; then
  1430.         if [[ ${version} = "7" || ${version} = "8" ]]; then
  1431.             installbbr2
  1432.         else
  1433.             echo -e "${Error} bbr2内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1434.         fi
  1435.     # elif [[ "${release}" == "debian" ]]; then
  1436.         # if [[ ${version} = "9" || ${version} = "10" ]]; then
  1437.             # installbbr2
  1438.         # else
  1439.             # echo -e "${Error} bbr2内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1440.         # fi
  1441.     # elif [[ "${release}" == "ubuntu" ]]; then
  1442.             # echo -e "${Error} bbr2内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1443.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1444.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1445.             installbbr2    
  1446.     else
  1447.         echo -e "${Error} bbr2内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1448.     fi
  1449. }
  1450.  
  1451.  
  1452. check_sys_zen(){
  1453.     check_version
  1454.     if [[ "${release}" == "centos" ]]; then
  1455.         if [[ ${version} = "7" || ${version} = "8" ]]; then
  1456.             installzen
  1457.         else
  1458.             echo -e "${Error} zen内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1459.         fi
  1460.     # elif [[ "${release}" == "debian" ]]; then
  1461.         # if [[ ${version} = "9" || ${version} = "10" ]]; then
  1462.             # installzen
  1463.         # else
  1464.             # echo -e "${Error} zen内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1465.         # fi
  1466.     # elif [[ "${release}" == "ubuntu" ]]; then
  1467.             # echo -e "${Error} zen内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1468.     elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1469.         # if [[ ${version} = "8" || ${version} = "9" || ${version} = "10" || ${version} = "16" || ${version} = "18" || ${version} = "19" || ${version} = "20" ]]; then
  1470.             installzen             
  1471.     else
  1472.         echo -e "${Error} zen内核不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1473.     fi
  1474. }
  1475.  
  1476. #检查安装Lotsever的系统要求
  1477. check_sys_Lotsever(){
  1478.     check_version
  1479.     if [[ "${release}" == "centos" ]]; then
  1480.         if [[ ${version} == "6" ]]; then
  1481.             kernel_version="2.6.32-504"
  1482.             installlot
  1483.         elif [[ ${version} == "7" ]]; then
  1484.             yum -y install net-tools
  1485.             kernel_version="4.11.2-1"
  1486.             installlot
  1487.         else
  1488.             echo -e "${Error} Lotsever不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1489.         fi
  1490.     elif [[ "${release}" == "debian" ]]; then
  1491.         if [[ ${version} = "7" || ${version} = "8" ]]; then
  1492.             if [[ ${bit} == "x64" ]]; then
  1493.                 kernel_version="3.16.0-4"
  1494.                 installlot
  1495.             elif [[ ${bit} == "x32" ]]; then
  1496.                 kernel_version="3.2.0-4"
  1497.                 installlot
  1498.             fi
  1499.         elif [[ ${version} = "9" ]]; then
  1500.             if [[ ${bit} == "x64" ]]; then
  1501.                 kernel_version="4.9.0-4"
  1502.                 installlot
  1503.             fi
  1504.         else
  1505.             echo -e "${Error} Lotsever不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1506.         fi
  1507.     elif [[ "${release}" == "ubuntu" ]]; then
  1508.         if [[ ${version} -ge "12" ]]; then
  1509.             if [[ ${bit} == "x64" ]]; then
  1510.                 kernel_version="4.4.0-47"
  1511.                 installlot
  1512.             elif [[ ${bit} == "x32" ]]; then
  1513.                 kernel_version="3.13.0-29"
  1514.                 installlot
  1515.             fi
  1516.         else
  1517.             echo -e "${Error} Lotsever不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1518.         fi
  1519.     else
  1520.         echo -e "${Error} Lotsever不支持当前系统 ${release} ${version} ${bit} !" && exit 1
  1521.     fi
  1522. }
  1523.  
  1524. check_status(){
  1525.     kernel_version=`uname -r | awk -F "-" '{print $1}'`
  1526.     kernel_version_full=`uname -r`
  1527.     net_congestion_control=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1528.     net_qdisc=`cat /proc/sys/net/core/default_qdisc | awk '{print $1}'`
  1529.     kernel_version_r=`uname -r | awk '{print $1}'`
  1530.     if [[ ${kernel_version_full} = "4.14.182-bbrplus" || ${kernel_version_full} = "4.14.168-bbrplus" || ${kernel_version_full} = "4.14.98-bbrplus" || ${kernel_version_full} = "4.14.129-bbrplus" || ${kernel_version_full} = "4.14.160-bbrplus" || ${kernel_version_full} = "4.14.166-bbrplus" || ${kernel_version_full} = "4.14.161-bbrplus" ]]; then
  1531.         kernel_status="BBRplus"
  1532.     elif [[ ${kernel_version} = "3.10.0" || ${kernel_version} = "3.16.0" || ${kernel_version} = "3.2.0" || ${kernel_version} = "4.4.0" || ${kernel_version} = "3.13.0"  || ${kernel_version} = "2.6.32" || ${kernel_version} = "4.9.0" || ${kernel_version} = "4.11.2" ]]; then
  1533.         kernel_status="Lotserver"
  1534.     elif [[ `echo ${kernel_version} | awk -F'.' '{print $1}'` == "4" ]] && [[ `echo ${kernel_version} | awk -F'.' '{print $2}'` -ge 9 ]] || [[ `echo ${kernel_version} | awk -F'.' '{print $1}'` == "5" ]]; then
  1535.         kernel_status="BBR"
  1536.     else
  1537.         kernel_status="noinstall"
  1538.     fi
  1539.    
  1540.  
  1541.     if [[ ${kernel_status} == "BBR" ]]; then
  1542.         run_status=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1543.         if [[ ${run_status} == "bbr" ]]; then
  1544.             run_status=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1545.             if [[ ${run_status} == "bbr" ]]; then
  1546.                 run_status="BBR启动成功"
  1547.             else
  1548.                 run_status="BBR启动失败"
  1549.             fi
  1550.         elif [[ ${run_status} == "bbr2" ]]; then
  1551.             run_status=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1552.             if [[ ${run_status} == "bbr2" ]]; then
  1553.                 run_status="BBR2启动成功"
  1554.             else
  1555.                 run_status="BBR2启动失败"
  1556.             fi 
  1557.         elif [[ ${run_status} == "tsunami" ]]; then
  1558.             run_status=`lsmod | grep "tsunami" | awk '{print $1}'`
  1559.             if [[ ${run_status} == "tcp_tsunami" ]]; then
  1560.                 run_status="BBR魔改版启动成功"
  1561.             else
  1562.                 run_status="BBR魔改版启动失败"
  1563.             fi
  1564.         elif [[ ${run_status} == "nanqinlang" ]]; then
  1565.             run_status=`lsmod | grep "nanqinlang" | awk '{print $1}'`
  1566.             if [[ ${run_status} == "tcp_nanqinlang" ]]; then
  1567.                 run_status="暴力BBR魔改版启动成功"
  1568.             else
  1569.                 run_status="暴力BBR魔改版启动失败"
  1570.             fi
  1571.         else
  1572.             run_status="未安装加速模块"
  1573.         fi
  1574.        
  1575.     elif [[ ${kernel_status} == "Lotserver" ]]; then
  1576.         if [[ -e /appex/bin/lotServer.sh ]]; then
  1577.             run_status=`bash /appex/bin/lotServer.sh status | grep "LotServer" | awk  '{print $3}'`
  1578.             if [[ ${run_status} = "running!" ]]; then
  1579.                 run_status="启动成功"
  1580.             else
  1581.                 run_status="启动失败"
  1582.             fi
  1583.         else
  1584.             run_status="未安装加速模块"
  1585.         fi 
  1586.     elif [[ ${kernel_status} == "BBRplus" ]]; then
  1587.         run_status=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1588.         if [[ ${run_status} == "bbrplus" ]]; then
  1589.             run_status=`cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}'`
  1590.             if [[ ${run_status} == "bbrplus" ]]; then
  1591.                 run_status="BBRplus启动成功"
  1592.             else
  1593.                 run_status="BBRplus启动失败"
  1594.             fi
  1595.         else
  1596.             run_status="未安装加速模块"
  1597.         fi
  1598.     fi
  1599. }
  1600.  
  1601. #############系统检测组件#############
  1602. check_sys
  1603. check_version
  1604. [[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} 本脚本不支持当前系统 ${release} !" && exit 1
  1605. start_menu
  1606.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement