tcpbbr.sh 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  1. #!/bin/bash
  2. if [[ "$EUID" -ne 0 ]]; then
  3. echo -e "\033[1;31m Anda tiada kebenaran untuk menjalankan skrip ini! \033[0m"; exit 1
  4. fi
  5. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  6. export PATH
  7. sh_ver="1.3.2.93"
  8. github="raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master"
  9. imgurl=""
  10. headurl=""
  11. Green_font_prefix="\033[32m"
  12. Red_font_prefix="\033[31m"
  13. Font_color_suffix="\033[0m"
  14. Info="${Green_font_prefix}[INFO]${Font_color_suffix}"
  15. Error="${Red_font_prefix}[ERROR]${Font_color_suffix}"
  16. Tip="${Green_font_prefix}[NOTE]${Font_color_suffix}"
  17. if [ -f "/etc/sysctl.d/bbr.conf" ]; then
  18. rm -rf /etc/sysctl.d/bbr.conf
  19. fi
  20. checkurl() {
  21. url=$(curl --max-time 5 --retry 3 --retry-delay 2 --connect-timeout 2 -s --head $1 | head -n 1)
  22. if [[ ${url} == *200* || ${url} == *302* || ${url} == *308* ]]; then
  23. echo "Download address check OK, continue!"
  24. else
  25. echo "Download address check error, exit!" && exit 1
  26. fi
  27. }
  28. installbbr() {
  29. kernel_version="5.9.6"
  30. bit=$(uname -m)
  31. rm -rf bbr
  32. mkdir bbr && cd bbr || exit
  33. if [[ "${release}" == "centos" ]]; then
  34. if [[ ${version} == "7" ]]; then
  35. if [[ ${bit} == "x86_64" ]]; then
  36. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  37. #github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}' | awk -F '[_]' '{print $3}')
  38. github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  39. github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
  40. echo -e "The version number obtained is:${github_ver}"
  41. kernel_version=$github_ver
  42. detele_kernel_head
  43. headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
  44. imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
  45. #headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/kernel-headers-${github_ver}-1.x86_64.rpm
  46. #imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/kernel-${github_ver}-1.x86_64.rpm
  47. echo -e "Checking header download connection...."
  48. checkurl $headurl
  49. echo -e "Checking kernel download connection...."
  50. checkurl $imgurl
  51. wget -N -O kernel-headers-c7.rpm $headurl
  52. wget -N -O kernel-c7.rpm $imgurl
  53. yum install -y kernel-c7.rpm
  54. yum install -y kernel-headers-c7.rpm
  55. else
  56. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  57. fi
  58. fi
  59. elif [[ "${release}" == "ubuntu" || "${release}" == "debian" ]]; then
  60. if [[ ${bit} == "x86_64" ]]; then
  61. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  62. github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_latest_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  63. github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  64. echo -e "The version number obtained is:${github_ver}"
  65. kernel_version=$github_ver
  66. detele_kernel_head
  67. headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}')
  68. imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
  69. #headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-headers-${github_ver}_${github_ver}-1_amd64.deb
  70. #imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-image-${github_ver}_${github_ver}-1_amd64.deb
  71. echo -e "Checking header download connection...."
  72. checkurl $headurl
  73. echo -e "Checking kernel download connection...."
  74. checkurl $imgurl
  75. wget -N -O linux-headers-d10.deb $headurl
  76. wget -N -O linux-image-d10.deb $imgurl
  77. dpkg -i linux-image-d10.deb
  78. dpkg -i linux-headers-d10.deb
  79. elif [[ ${bit} == "aarch64" ]]; then
  80. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  81. github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_arm64_' | grep '_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  82. github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  83. echo -e "The version number obtained is:${github_ver}"
  84. kernel_version=$github_ver
  85. detele_kernel_head
  86. headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}')
  87. imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
  88. #headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-headers-${github_ver}_${github_ver}-1_amd64.deb
  89. #imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-image-${github_ver}_${github_ver}-1_amd64.deb
  90. echo -e "Checking header download connection...."
  91. checkurl $headurl
  92. echo -e "Checking kernel download connection...."
  93. checkurl $imgurl
  94. wget -N -O linux-headers-d10.deb $headurl
  95. wget -N -O linux-image-d10.deb $imgurl
  96. dpkg -i linux-image-d10.deb
  97. dpkg -i linux-headers-d10.deb
  98. else
  99. echo -e "${Error} Systems other than x86_64 and arm64/aarch64 are not supported!" && exit 1
  100. fi
  101. fi
  102. cd .. && rm -rf bbr
  103. detele_kernel
  104. BBR_grub
  105. echo -e "${Tip} ${Red_font_prefix}Please check if there is kernel information on it, don’t restart without kernel${Font_color_suffix}"
  106. echo -e "${Tip} ${Red_font_prefix}rescue is not a normal kernel, we need to exclude this${Font_color_suffix}"
  107. echo -e "${Tip} After restarting the VPS, please re-run the script to start${Red_font_prefix}BBR${Font_color_suffix}"
  108. stty erase '^H' && read -p "You need to restart the VPS before BBR can be turned on. Do you want to restart it now? [Y/n]: " yn
  109. [ -z "${yn}" ] && yn="y"
  110. if [[ $yn == [Yy] ]]; then
  111. echo -e "${Info} VPS restarting..."
  112. reboot
  113. fi
  114. #echo -e "${Tip} After the kernel is installed, please refer to the above information to check whether the installation is successful and manually adjust the kernel boot sequence"
  115. }
  116. installbbrplus() {
  117. kernel_version="4.14.160-bbrplus"
  118. bit=$(uname -m)
  119. rm -rf bbrplus
  120. mkdir bbrplus && cd bbrplus || exit
  121. if [[ "${release}" == "centos" ]]; then
  122. if [[ ${version} == "7" ]]; then
  123. if [[ ${bit} == "x86_64" ]]; then
  124. kernel_version="4.14.129_bbrplus"
  125. detele_kernel_head
  126. headurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-headers-4.14.129-bbrplus.rpm
  127. imgurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-4.14.129-bbrplus.rpm
  128. echo -e "Checking header download connection...."
  129. checkurl $headurl
  130. echo -e "Checking kernel download connection...."
  131. checkurl $imgurl
  132. wget -N -O kernel-headers-c7.rpm $headurl
  133. wget -N -O kernel-c7.rpm $imgurl
  134. yum install -y kernel-c7.rpm
  135. yum install -y kernel-headers-c7.rpm
  136. else
  137. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  138. fi
  139. fi
  140. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  141. if [[ ${bit} == "x86_64" ]]; then
  142. kernel_version="4.14.129-bbrplus"
  143. detele_kernel_head
  144. headurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-headers-4.14.129-bbrplus.deb
  145. imgurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-image-4.14.129-bbrplus.deb
  146. echo -e "Checking header download connection...."
  147. checkurl $headurl
  148. echo -e "Checking kernel download connection...."
  149. checkurl $imgurl
  150. wget -N -O linux-headers.deb $headurl
  151. wget -N -O linux-image.deb $imgurl
  152. dpkg -i linux-image.deb
  153. dpkg -i linux-headers.deb
  154. else
  155. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  156. fi
  157. fi
  158. cd .. && rm -rf bbrplus
  159. detele_kernel
  160. BBR_grub
  161. echo -e "${Tip} ${Red_font_prefix}Please check if there is kernel information on it, don’t restart without kernel${Font_color_suffix}"
  162. echo -e "${Tip} ${Red_font_prefix}rescue is not a normal kernel, we need to exclude this${Font_color_suffix}"
  163. echo -e "${Tip} After restarting the VPS, please re-run the script to start${Red_font_prefix}BBRplus${Font_color_suffix}"
  164. stty erase '^H' && read -p "You need to restart the VPS before you can start BBRplus. Do you want to restart it now? [Y/n]: " yn
  165. [ -z "${yn}" ] && yn="y"
  166. if [[ $yn == [Yy] ]]; then
  167. echo -e "${Info} VPS 重启中..."
  168. reboot
  169. fi
  170. #echo -e "${Tip} After the kernel is installed, please refer to the above information to check whether the installation is successful and manually adjust the kernel boot sequence"
  171. }
  172. installlot() {
  173. bit=$(uname -m)
  174. if [[ ${bit} != "x86_64" ]]; then
  175. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  176. fi
  177. if [[ ${bit} == "x86_64" ]]; then
  178. bit='x64'
  179. fi
  180. if [[ ${bit} == "i386" ]]; then
  181. bit='x32'
  182. fi
  183. if [[ "${release}" == "centos" ]]; then
  184. rpm --import http://${github}/lotserver/${release}/RPM-GPG-KEY-elrepo.org
  185. yum remove -y kernel-firmware
  186. yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-firmware-${kernel_version}.rpm
  187. yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-${kernel_version}.rpm
  188. yum remove -y kernel-headers
  189. yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-headers-${kernel_version}.rpm
  190. yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-devel-${kernel_version}.rpm
  191. fi
  192. if [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  193. deb_issue="$(cat /etc/issue)"
  194. deb_relese="$(echo $deb_issue | grep -io 'Ubuntu\|Debian' | sed -r 's/(.*)/\L\1/')"
  195. os_ver="$(dpkg --print-architecture)"
  196. [ -n "$os_ver" ] || exit 1
  197. if [ "$deb_relese" == 'ubuntu' ]; then
  198. deb_ver="$(echo $deb_issue | grep -o '[0-9]*\.[0-9]*' | head -n1)"
  199. if [ "$deb_ver" == "14.04" ]; then
  200. kernel_version="3.16.0-77-generic" && item="3.16.0-77-generic" && ver='trusty'
  201. elif [ "$deb_ver" == "16.04" ]; then
  202. kernel_version="4.8.0-36-generic" && item="4.8.0-36-generic" && ver='xenial'
  203. elif [ "$deb_ver" == "18.04" ]; then
  204. kernel_version="4.15.0-30-generic" && item="4.15.0-30-generic" && ver='bionic'
  205. else
  206. exit 1
  207. fi
  208. url='archive.ubuntu.com'
  209. urls='security.ubuntu.com'
  210. elif [ "$deb_relese" == 'debian' ]; then
  211. deb_ver="$(echo $deb_issue | grep -o '[0-9]*' | head -n1)"
  212. if [ "$deb_ver" == "7" ]; then
  213. kernel_version="3.2.0-4-${os_ver}" && item="3.2.0-4-${os_ver}" && ver='wheezy' && url='archive.debian.org' && urls='archive.debian.org'
  214. elif [ "$deb_ver" == "8" ]; then
  215. kernel_version="3.16.0-4-${os_ver}" && item="3.16.0-4-${os_ver}" && ver='jessie' && url='archive.debian.org' && urls='deb.debian.org'
  216. elif [ "$deb_ver" == "9" ]; then
  217. kernel_version="4.9.0-4-${os_ver}" && item="4.9.0-4-${os_ver}" && ver='stretch' && url='deb.debian.org' && urls='deb.debian.org'
  218. else
  219. exit 1
  220. fi
  221. fi
  222. [ -n "$item" ] && [ -n "$urls" ] && [ -n "$url" ] && [ -n "$ver" ] || exit 1
  223. if [ "$deb_relese" == 'ubuntu' ]; then
  224. echo "deb http://${url}/${deb_relese} ${ver} main restricted universe multiverse" >/etc/apt/sources.list
  225. echo "deb http://${url}/${deb_relese} ${ver}-updates main restricted universe multiverse" >>/etc/apt/sources.list
  226. echo "deb http://${url}/${deb_relese} ${ver}-backports main restricted universe multiverse" >>/etc/apt/sources.list
  227. echo "deb http://${urls}/${deb_relese} ${ver}-security main restricted universe multiverse" >>/etc/apt/sources.list
  228. apt-get update
  229. apt-get install --no-install-recommends -y linux-image-${item}
  230. elif [ "$deb_relese" == 'debian' ]; then
  231. echo "deb http://${url}/${deb_relese} ${ver} main" >/etc/apt/sources.list
  232. echo "deb-src http://${url}/${deb_relese} ${ver} main" >>/etc/apt/sources.list
  233. echo "deb http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list
  234. echo "deb-src http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list
  235. if [ "$deb_ver" == "8" ]; then
  236. dpkg -l | grep -q 'linux-base' || {
  237. wget --no-check-certificate -qO '/tmp/linux-base_3.5_all.deb' 'http://snapshot.debian.org/archive/debian/20120304T220938Z/pool/main/l/linux-base/linux-base_3.5_all.deb'
  238. dpkg -i '/tmp/linux-base_3.5_all.deb'
  239. }
  240. wget --no-check-certificate -qO '/tmp/linux-image-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb' 'http://snapshot.debian.org/archive/debian/20171008T163152Z/pool/main/l/linux/linux-image-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb'
  241. dpkg -i '/tmp/linux-image-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb'
  242. if [ $? -ne 0 ]; then
  243. exit 1
  244. fi
  245. elif [ "$deb_ver" == "9" ]; then
  246. dpkg -l | grep -q 'linux-base' || {
  247. wget --no-check-certificate -qO '/tmp/linux-base_4.5_all.deb' 'http://snapshot.debian.org/archive/debian/20160917T042239Z/pool/main/l/linux-base/linux-base_4.5_all.deb'
  248. dpkg -i '/tmp/linux-base_4.5_all.deb'
  249. }
  250. wget --no-check-certificate -qO '/tmp/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb' 'http://snapshot.debian.org/archive/debian/20171224T175424Z/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb'
  251. dpkg -i '/tmp/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb'
  252. ##备选
  253. #https://sys.if.ci/download/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  254. #http://mirror.cs.uchicago.edu/debian-security/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  255. #https://debian.sipwise.com/debian-security/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  256. #http://srv24.dsidata.sk/security.debian.org/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  257. #https://pubmirror.plutex.de/debian-security/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  258. #https://packages.mendix.com/debian/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3_amd64.deb
  259. #http://snapshot.debian.org/archive/debian/20171224T175424Z/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
  260. #http://snapshot.debian.org/archive/debian/20171231T180144Z/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3_amd64.deb
  261. if [ $? -ne 0 ]; then
  262. exit 1
  263. fi
  264. else
  265. exit 1
  266. fi
  267. fi
  268. apt-get autoremove -y
  269. [ -d '/var/lib/apt/lists' ] && find /var/lib/apt/lists -type f -delete
  270. fi
  271. detele_kernel
  272. BBR_grub
  273. echo -e "${Tip} ${Red_font_prefix}请检查上面是否有内核信息,无内核千万别重启${Font_color_suffix}"
  274. echo -e "${Tip} ${Red_font_prefix}rescue不是正常内核,要排除这个${Font_color_suffix}"
  275. echo -e "${Tip} 重启VPS后,请重新运行脚本开启${Red_font_prefix}Lotserver${Font_color_suffix}"
  276. stty erase '^H' && read -p "需要重启VPS后,才能开启Lotserver,是否现在重启 ? [Y/n] :" yn
  277. [ -z "${yn}" ] && yn="y"
  278. if [[ $yn == [Yy] ]]; then
  279. echo -e "${Info} VPS 重启中..."
  280. reboot
  281. fi
  282. #echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功及手动调整内核启动顺序"
  283. }
  284. installxanmod() {
  285. kernel_version="5.5.1-xanmod1"
  286. bit=$(uname -m)
  287. if [[ ${bit} != "x86_64" ]]; then
  288. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  289. fi
  290. rm -rf xanmod
  291. mkdir xanmod && cd xanmod || exit
  292. if [[ "${release}" == "centos" ]]; then
  293. if [[ ${version} == "7" ]]; then
  294. if [[ ${bit} == "x86_64" ]]; then
  295. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  296. github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_lts_latest_' | grep 'xanmod' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  297. github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
  298. echo -e "The version number obtained is:${github_ver}"
  299. kernel_version=$github_ver
  300. detele_kernel_head
  301. headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
  302. imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
  303. echo -e "Checking header download connection...."
  304. checkurl $headurl
  305. echo -e "Checking kernel download connection...."
  306. checkurl $imgurl
  307. wget -N -O kernel-headers-c7.rpm $headurl
  308. wget -N -O kernel-c7.rpm $imgurl
  309. yum install -y kernel-c7.rpm
  310. yum install -y kernel-headers-c7.rpm
  311. else
  312. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  313. fi
  314. elif [[ ${version} == "8" ]]; then
  315. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  316. github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_lts_C8_latest_' | grep 'xanmod' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  317. github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
  318. echo -e "The version number obtained is:${github_ver}"
  319. kernel_version=$github_ver
  320. detele_kernel_head
  321. headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
  322. imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
  323. echo -e "Checking header download connection...."
  324. checkurl $headurl
  325. echo -e "Checking kernel download connection...."
  326. checkurl $imgurl
  327. wget -N -O kernel-headers-c8.rpm $headurl
  328. wget -N -O kernel-c8.rpm $imgurl
  329. yum install -y kernel-c8.rpm
  330. yum install -y kernel-headers-c8.rpm
  331. fi
  332. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  333. if [[ ${bit} == "x86_64" ]]; then
  334. # kernel_version="5.11.4-xanmod"
  335. # xanmod_ver_b=$(rm -rf /tmp/url.tmp && curl -o /tmp/url.tmp 'https://dl.xanmod.org/dl/changelog/?C=N;O=D' && grep folder.gif /tmp/url.tmp | head -n 1 | awk -F "[/]" '{print $5}' | awk -F "[>]" '{print $2}')
  336. # xanmod_ver_s=$(rm -rf /tmp/url.tmp && curl -o /tmp/url.tmp 'https://dl.xanmod.org/changelog/${xanmod_ver_b}/?C=M;O=D' && grep $xanmod_ver_b /tmp/url.tmp | head -n 3 | awk -F "[-]" '{print $2}')
  337. sourceforge_xanmod_lts_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
  338. sourceforge_xanmod_lts_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
  339. sourceforge_xanmod_lts_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
  340. # sourceforge_xanmod_stable_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
  341. # sourceforge_xanmod_stable_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
  342. # sourceforge_xanmod_stable_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
  343. # sourceforge_xanmod_cacule_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
  344. # sourceforge_xanmod_cacule_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
  345. # sourceforge_xanmod_cacule_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
  346. echo -e "The obtained xanmod lts version number is:${sourceforge_xanmod_lts_ver}"
  347. # kernel_version=$sourceforge_xanmod_stable_ver
  348. # detele_kernel_head
  349. # headurl=https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/${sourceforge_xanmod_stable_file_head}/download
  350. # imgurl=https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/${sourceforge_xanmod_stable_file_img}/download
  351. kernel_version=$sourceforge_xanmod_lts_ver
  352. detele_kernel_head
  353. #headurl=https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/${sourceforge_xanmod_cacule_file_head}/download
  354. #imgurl=https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/${sourceforge_xanmod_cacule_file_img}/download
  355. headurl=https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/${sourceforge_xanmod_lts_file_head}/download
  356. imgurl=https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/${sourceforge_xanmod_lts_file_img}/download
  357. echo -e "Checking header download connection...."
  358. checkurl $headurl
  359. echo -e "Checking kernel download connection...."
  360. checkurl $imgurl
  361. wget -N -O linux-headers-d10.deb $headurl
  362. wget -N -O linux-image-d10.deb $imgurl
  363. dpkg -i linux-image-d10.deb
  364. dpkg -i linux-headers-d10.deb
  365. else
  366. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  367. fi
  368. fi
  369. cd .. && rm -rf xanmod
  370. detele_kernel
  371. BBR_grub
  372. echo -e "${Tip} ${Red_font_prefix}Please check if there is kernel information on it, don’t restart without kernel${Font_color_suffix}"
  373. echo -e "${Tip} ${Red_font_prefix}rescue is not a normal kernel, we need to exclude this${Font_color_suffix}"
  374. echo -e "${Tip} After restarting the VPS, please re-run the script to start${Red_font_prefix}BBR${Font_color_suffix}"
  375. stty erase '^H' && read -p "You need to restart the VPS before BBR can be turned on. Do you want to restart it now? [Y/n]: " yn
  376. [ -z "${yn}" ] && yn="y"
  377. if [[ $yn == [Yy] ]]; then
  378. echo -e "${Info} VPS restarting..."
  379. reboot
  380. fi
  381. #echo -e "${Tip} After the kernel is installed, please refer to the above information to check whether the installation is successful and manually adjust the kernel boot sequence"
  382. }
  383. installbbrplusnew() {
  384. github_ver_plus=$(curl -s https://api.github.com/repos/UJX6N/bbrplus-5.10/releases | grep /bbrplus-5.10/releases/tag/ | head -1 | awk -F "[/]" '{print $8}' | awk -F "[\"]" '{print $1}')
  385. github_ver_plus_num=$(curl -s https://api.github.com/repos/UJX6N/bbrplus-5.10/releases | grep /bbrplus-5.10/releases/tag/ | head -1 | awk -F "[/]" '{print $8}' | awk -F "[\"]" '{print $1}' | awk -F "[-]" '{print $1}')
  386. echo -e "The bbrplus-5.10 version number of UJX6N obtained is:${github_ver_plus}"
  387. echo -e "If there is an error in the download address, it may be currently being updated. If there is still an error after more than half a day, please feedback"
  388. echo -e "Feedback on installation failure, and feedback on kernel issues to UJX6N"
  389. # kernel_version=$github_ver_plus
  390. bit=$(uname -m)
  391. #if [[ ${bit} != "x86_64" ]]; then
  392. # echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  393. #fi
  394. rm -rf bbrplusnew
  395. mkdir bbrplusnew && cd bbrplusnew || exit
  396. if [[ "${release}" == "centos" ]]; then
  397. if [[ ${version} == "7" ]]; then
  398. if [[ ${bit} == "x86_64" ]]; then
  399. #github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  400. #github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  401. #echo -e "The version number obtained is:${github_ver}"
  402. kernel_version=${github_ver_plus_num}_bbrplus
  403. detele_kernel_head
  404. headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'rpm' | grep 'headers' | grep 'el7' | awk -F '"' '{print $4}')
  405. imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'rpm' | grep -v 'devel' | grep -v 'headers' | grep -v 'Source' | grep 'el7' | awk -F '"' '{print $4}')
  406. echo -e "Checking header download connection...."
  407. checkurl $headurl
  408. echo -e "Checking kernel download connection...."
  409. checkurl $imgurl
  410. wget -N -O kernel-c7.rpm $headurl
  411. wget -N -O kernel-headers-c7.rpm $imgurl
  412. yum install -y kernel-c7.rpm
  413. yum install -y kernel-headers-c7.rpm
  414. else
  415. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  416. fi
  417. fi
  418. if [[ ${version} == "8" ]]; then
  419. if [[ ${bit} == "x86_64" ]]; then
  420. #github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  421. #github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  422. #echo -e "The version number obtained is:${github_ver}"
  423. kernel_version=${github_ver_plus_num}_bbrplus
  424. detele_kernel_head
  425. headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'rpm' | grep 'headers' | grep 'el8' | awk -F '"' '{print $4}')
  426. imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'rpm' | grep -v 'devel' | grep -v 'headers' | grep -v 'Source' | grep 'el8' | awk -F '"' '{print $4}')
  427. echo -e "Checking header download connection...."
  428. checkurl $headurl
  429. echo -e "Checking kernel download connection...."
  430. checkurl $imgurl
  431. wget -N -O kernel-c8.rpm $headurl
  432. wget -N -O kernel-headers-c8.rpm $imgurl
  433. yum install -y kernel-c8.rpm
  434. yum install -y kernel-headers-c8.rpm
  435. else
  436. echo -e "${Error} Does not support systems other than x86_64!" && exit 1
  437. fi
  438. fi
  439. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  440. if [[ ${bit} == "x86_64" ]]; then
  441. #github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  442. #github_ver=$(curl -s 'http s://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  443. #echo -e "The version number obtained is:${github_ver}"
  444. kernel_version=${github_ver_plus_num}-bbrplus
  445. detele_kernel_head
  446. headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'https' | grep 'amd64.deb' | grep 'headers' | awk -F '"' '{print $4}')
  447. imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'https' | grep 'amd64.deb' | grep 'image' | awk -F '"' '{print $4}')
  448. echo -e "Checking header download connection...."
  449. checkurl $headurl
  450. echo -e "Checking kernel download connection...."
  451. checkurl $imgurl
  452. wget -N -O linux-headers-d10.deb $headurl
  453. wget -N -O linux-image-d10.deb $imgurl
  454. dpkg -i linux-image-d10.deb
  455. dpkg -i linux-headers-d10.deb
  456. elif [[ ${bit} == "aarch64" ]]; then
  457. #github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
  458. #github_ver=$(curl -s 'http s://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
  459. #echo -e "The version number obtained is:${github_ver}"
  460. kernel_version=${github_ver_plus_num}-bbrplus
  461. detele_kernel_head
  462. headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'https' | grep 'arm64.deb' | grep 'headers' | awk -F '"' '{print $4}')
  463. imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-5.10/releases' | grep ${github_ver_plus} | grep 'https' | grep 'arm64.deb' | grep 'image' | awk -F '"' '{print $4}')
  464. echo -e "Checking header download connection...."
  465. checkurl $headurl
  466. echo -e "Checking kernel download connection...."
  467. checkurl $imgurl
  468. wget -N -O linux-headers-d10.deb $headurl
  469. wget -N -O linux-image-d10.deb $imgurl
  470. dpkg -i linux-image-d10.deb
  471. dpkg -i linux-headers-d10.deb
  472. else
  473. echo -e "${Error} Systems other than x86_64 and arm64/aarch64 are not supported!" && exit 1
  474. fi
  475. fi
  476. cd .. && rm -rf bbrplusnew
  477. detele_kernel
  478. BBR_grub
  479. echo -e "${Tip} ${Red_font_prefix}Please check if there is kernel information on it, don’t restart without kernel${Font_color_suffix}"
  480. echo -e "${Tip} ${Red_font_prefix}rescue is not a normal kernel, we need to exclude this${Font_color_suffix}"
  481. echo -e "${Tip} After restarting the VPS, please re-run the script to start${Red_font_prefix}BBRplus${Font_color_suffix}"
  482. stty erase '^H' && read -p "You need to restart the VPS before you can start BBRplus. Do you want to restart it now? [Y/n] :" yn
  483. [ -z "${yn}" ] && yn="y"
  484. if [[ $yn == [Yy] ]]; then
  485. echo -e "${Info} VPS restarting..."
  486. reboot
  487. fi
  488. #echo -e "${Tip} After the kernel is installed, please refer to the above information to check whether the installation is successful and manually adjust the kernel boot sequence"
  489. }
  490. startbbrfq() {
  491. remove_bbr_lotserver
  492. echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
  493. echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
  494. sysctl --system
  495. echo -e "${Info}BBR+FQ is modified successfully, restart to take effect!"
  496. }
  497. startbbrfqpie() {
  498. remove_bbr_lotserver
  499. echo "net.core.default_qdisc=fq_pie" >>/etc/sysctl.d/99-sysctl.conf
  500. echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
  501. sysctl --system
  502. echo -e "${Info}BBR+FQ_PIE is modified successfully, restart to take effect!"
  503. }
  504. startbbrcake() {
  505. remove_bbr_lotserver
  506. echo "net.core.default_qdisc=cake" >>/etc/sysctl.d/99-sysctl.conf
  507. echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
  508. sysctl --system
  509. echo -e "${Info}BBR+cake is modified successfully, restart to take effect!"
  510. }
  511. startbbrplus() {
  512. remove_bbr_lotserver
  513. echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
  514. echo "net.ipv4.tcp_congestion_control=bbrplus" >>/etc/sysctl.d/99-sysctl.conf
  515. sysctl --system
  516. echo -e "${Info}BBRplus is modified successfully and it will take effect after restart!"
  517. }
  518. startlotserver() {
  519. remove_bbr_lotserver
  520. if [[ "${release}" == "centos" ]]; then
  521. yum install ethtool -y
  522. else
  523. apt-get update
  524. apt-get install ethtool -y
  525. fi
  526. #bash <(wget -qO- https://git.io/lotServerInstall.sh) install
  527. echo | bash <(wget --no-check-certificate -qO- https://github.com/xidcn/LotServer_Vicer/raw/master/Install.sh) install
  528. sed -i '/advinacc/d' /appex/etc/config
  529. sed -i '/maxmode/d' /appex/etc/config
  530. echo -e "advinacc=\"1\"
  531. maxmode=\"1\"" >>/appex/etc/config
  532. /appex/bin/lotServer.sh restart
  533. start_menu
  534. }
  535. startbbr2fq() {
  536. remove_bbr_lotserver
  537. echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
  538. echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
  539. sysctl --system
  540. echo -e "${Info}BBR2 is modified successfully, restart to take effect!"
  541. }
  542. startbbr2fqpie() {
  543. remove_bbr_lotserver
  544. echo "net.core.default_qdisc=fq_pie" >>/etc/sysctl.d/99-sysctl.conf
  545. echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
  546. sysctl --system
  547. echo -e "${Info}BBR2 is modified successfully, restart to take effect!"
  548. }
  549. startbbr2cake() {
  550. remove_bbr_lotserver
  551. echo "net.core.default_qdisc=cake" >>/etc/sysctl.d/99-sysctl.conf
  552. echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
  553. sysctl --system
  554. echo -e "${Info}BBR2 is modified successfully, restart to take effect!"
  555. }
  556. startecn() {
  557. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  558. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  559. echo "net.ipv4.tcp_ecn=1" >>/etc/sysctl.d/99-sysctl.conf
  560. sysctl --system
  561. echo -e "${Info}Turning on ecn is over!"
  562. }
  563. closeecn() {
  564. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  565. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  566. echo "net.ipv4.tcp_ecn=0" >>/etc/sysctl.d/99-sysctl.conf
  567. sysctl --system
  568. echo -e "${Info}Close ecn is over!"
  569. }
  570. remove_bbr_lotserver() {
  571. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  572. sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
  573. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
  574. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  575. sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  576. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  577. sysctl --system
  578. rm -rf bbrmod
  579. if [[ -e /appex/bin/lotServer.sh ]]; then
  580. echo | bash <(wget -qO- https://git.io/lotServerInstall.sh) uninstall
  581. fi
  582. clear
  583. # echo -e "${Info}:清除bbr/lotserver加速完成。"
  584. # sleep 1s
  585. }
  586. remove_all() {
  587. rm -rf /etc/sysctl.d/*.conf
  588. #rm -rf /etc/sysctl.conf
  589. #touch /etc/sysctl.conf
  590. if [ ! -f "/etc/sysctl.conf" ]; then
  591. touch /etc/sysctl.conf
  592. else
  593. cat /dev/null >/etc/sysctl.conf
  594. fi
  595. sysctl --system
  596. sed -i '/DefaultTimeoutStartSec/d' /etc/systemd/system.conf
  597. sed -i '/DefaultTimeoutStopSec/d' /etc/systemd/system.conf
  598. sed -i '/DefaultRestartSec/d' /etc/systemd/system.conf
  599. sed -i '/DefaultLimitCORE/d' /etc/systemd/system.conf
  600. sed -i '/DefaultLimitNOFILE/d' /etc/systemd/system.conf
  601. sed -i '/DefaultLimitNPROC/d' /etc/systemd/system.conf
  602. sed -i '/soft nofile/d' /etc/security/limits.conf
  603. sed -i '/hard nofile/d' /etc/security/limits.conf
  604. sed -i '/soft nproc/d' /etc/security/limits.conf
  605. sed -i '/hard nproc/d' /etc/security/limits.conf
  606. sed -i '/ulimit -SHn/d' /etc/profile
  607. sed -i '/ulimit -SHn/d' /etc/profile
  608. sed -i '/required pam_limits.so/d' /etc/pam.d/common-session
  609. systemctl daemon-reload
  610. rm -rf bbrmod
  611. sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
  612. sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
  613. sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
  614. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
  615. sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  616. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  617. sed -i '/fs.file-max/d' /etc/sysctl.conf
  618. sed -i '/net.core.rmem_max/d' /etc/sysctl.conf
  619. sed -i '/net.core.wmem_max/d' /etc/sysctl.conf
  620. sed -i '/net.core.rmem_default/d' /etc/sysctl.conf
  621. sed -i '/net.core.wmem_default/d' /etc/sysctl.conf
  622. sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  623. sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  624. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  625. sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  626. sed -i '/net.ipv4.tcp_tw_recycle/d' /etc/sysctl.conf
  627. sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  628. sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.conf
  629. sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  630. sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  631. sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  632. sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.conf
  633. sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.conf
  634. sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.conf
  635. sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  636. sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
  637. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  638. sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  639. sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  640. sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  641. sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  642. sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  643. sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
  644. sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
  645. sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
  646. sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  647. sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  648. sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
  649. sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
  650. if [[ -e /appex/bin/lotServer.sh ]]; then
  651. bash <(wget -qO- https://git.io/lotServerInstall.sh) uninstall
  652. fi
  653. clear
  654. echo -e "${Info}:Clear acceleration is complete."
  655. sleep 1s
  656. }
  657. optimizing_system() {
  658. if [ ! -f "/etc/sysctl.conf" ]; then
  659. touch /etc/sysctl.conf
  660. fi
  661. sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
  662. sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
  663. sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
  664. sed -i '/fs.file-max/d' /etc/sysctl.conf
  665. sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
  666. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
  667. sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
  668. sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
  669. sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
  670. sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
  671. sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
  672. sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
  673. sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
  674. sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
  675. sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
  676. sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
  677. sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
  678. sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
  679. sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
  680. echo "net.ipv4.tcp_retries2 = 8
  681. net.ipv4.tcp_slow_start_after_idle = 0
  682. fs.file-max = 1000000
  683. fs.inotify.max_user_instances = 8192
  684. net.ipv4.tcp_syncookies = 1
  685. net.ipv4.tcp_fin_timeout = 30
  686. net.ipv4.tcp_tw_reuse = 1
  687. net.ipv4.ip_local_port_range = 1024 65000
  688. net.ipv4.tcp_max_syn_backlog = 16384
  689. net.ipv4.tcp_max_tw_buckets = 6000
  690. net.ipv4.route.gc_timeout = 100
  691. net.ipv4.tcp_syn_retries = 1
  692. net.ipv4.tcp_synack_retries = 1
  693. net.core.somaxconn = 32768
  694. net.core.netdev_max_backlog = 32768
  695. net.ipv4.tcp_timestamps = 0
  696. net.ipv4.tcp_max_orphans = 32768
  697. # forward ipv4
  698. #net.ipv4.ip_forward = 1" >>/etc/sysctl.conf
  699. sysctl -p
  700. echo "* soft nofile 1000000
  701. * hard nofile 1000000" >/etc/security/limits.conf
  702. echo "ulimit -SHn 1000000" >>/etc/profile
  703. read -p "The VPS needs to be restarted for the system optimization configuration to take effect. Do you want to restart now? [Y/n] :" yn
  704. [ -z "${yn}" ] && yn="y"
  705. if [[ $yn == [Yy] ]]; then
  706. echo -e "${Info} VPS restarting..."
  707. reboot
  708. fi
  709. }
  710. optimizing_system_johnrosen1() {
  711. if [ ! -f "/etc/sysctl.d/99-sysctl.conf" ]; then
  712. touch /etc/sysctl.d/99-sysctl.conf
  713. fi
  714. sed -i '/kernel.pid_max/d' /etc/sysctl.d/99-sysctl.conf
  715. sed -i '/vm.nr_hugepages/d' /etc/sysctl.d/99-sysctl.conf
  716. sed -i '/net.core.optmem_max/d' /etc/sysctl.d/99-sysctl.conf
  717. sed -i '/net.ipv4.conf.all.route_localnet/d' /etc/sysctl.d/99-sysctl.conf
  718. sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.d/99-sysctl.conf
  719. sed -i '/net.ipv4.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  720. sed -i '/net.ipv4.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  721. sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  722. sed -i '/net.ipv6.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  723. sed -i '/net.ipv6.conf.lo.forwarding/d' /etc/sysctl.d/99-sysctl.conf
  724. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  725. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  726. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  727. sed -i '/net.ipv6.conf.all.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  728. sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  729. sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
  730. sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.d/99-sysctl.conf
  731. sed -i '/net.core.netdev_budget/d' /etc/sysctl.d/99-sysctl.conf
  732. sed -i '/net.core.netdev_budget_usecs/d' /etc/sysctl.d/99-sysctl.conf
  733. sed -i '/fs.file-max /d' /etc/sysctl.d/99-sysctl.conf
  734. sed -i '/net.core.rmem_max/d' /etc/sysctl.d/99-sysctl.conf
  735. sed -i '/net.core.wmem_max/d' /etc/sysctl.d/99-sysctl.conf
  736. sed -i '/net.core.rmem_default/d' /etc/sysctl.d/99-sysctl.conf
  737. sed -i '/net.core.wmem_default/d' /etc/sysctl.d/99-sysctl.conf
  738. sed -i '/net.core.somaxconn/d' /etc/sysctl.d/99-sysctl.conf
  739. sed -i '/net.ipv4.icmp_echo_ignore_all/d' /etc/sysctl.d/99-sysctl.conf
  740. sed -i '/net.ipv4.icmp_echo_ignore_broadcasts/d' /etc/sysctl.d/99-sysctl.conf
  741. sed -i '/net.ipv4.icmp_ignore_bogus_error_responses/d' /etc/sysctl.d/99-sysctl.conf
  742. sed -i '/net.ipv4.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  743. sed -i '/net.ipv4.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  744. sed -i '/net.ipv4.conf.all.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  745. sed -i '/net.ipv4.conf.default.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
  746. sed -i '/net.ipv4.conf.all.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  747. sed -i '/net.ipv4.conf.default.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
  748. sed -i '/net.ipv4.conf.default.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  749. sed -i '/net.ipv4.conf.all.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
  750. sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.d/99-sysctl.conf
  751. sed -i '/net.ipv4.tcp_keepalive_intvl/d' /etc/sysctl.d/99-sysctl.conf
  752. sed -i '/net.ipv4.tcp_keepalive_probes/d' /etc/sysctl.d/99-sysctl.conf
  753. sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.d/99-sysctl.conf
  754. sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.d/99-sysctl.conf
  755. sed -i '/net.ipv4.tcp_rfc1337/d' /etc/sysctl.d/99-sysctl.conf
  756. sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.d/99-sysctl.conf
  757. sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.d/99-sysctl.conf
  758. sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.d/99-sysctl.conf
  759. sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.d/99-sysctl.conf
  760. sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.d/99-sysctl.conf
  761. sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.d/99-sysctl.conf
  762. sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.d/99-sysctl.conf
  763. sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.d/99-sysctl.conf
  764. sed -i '/net.ipv4.udp_rmem_min/d' /etc/sysctl.d/99-sysctl.conf
  765. sed -i '/net.ipv4.udp_wmem_min/d' /etc/sysctl.d/99-sysctl.conf
  766. sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.d/99-sysctl.conf
  767. sed -i '/net.ipv4.conf.all.arp_ignore /d' /etc/sysctl.d/99-sysctl.conf
  768. sed -i '/net.ipv4.conf.default.arp_ignore/d' /etc/sysctl.d/99-sysctl.conf
  769. sed -i '/net.ipv4.conf.all.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  770. sed -i '/net.ipv4.conf.default.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
  771. sed -i '/net.ipv4.tcp_autocorking/d' /etc/sysctl.d/99-sysctl.conf
  772. sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.d/99-sysctl.conf
  773. sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.d/99-sysctl.conf
  774. sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
  775. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
  776. sed -i '/net.ipv4.tcp_notsent_lowat/d' /etc/sysctl.d/99-sysctl.conf
  777. sed -i '/net.ipv4.tcp_no_metrics_save/d' /etc/sysctl.d/99-sysctl.conf
  778. sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
  779. sed -i '/net.ipv4.tcp_ecn_fallback/d' /etc/sysctl.d/99-sysctl.conf
  780. sed -i '/net.ipv4.tcp_frto/d' /etc/sysctl.d/99-sysctl.conf
  781. sed -i '/net.ipv6.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  782. sed -i '/net.ipv6.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
  783. sed -i '/vm.swappiness/d' /etc/sysctl.d/99-sysctl.conf
  784. sed -i '/net.ipv4.ip_unprivileged_port_start/d' /etc/sysctl.d/99-sysctl.conf
  785. sed -i '/vm.overcommit_memory/d' /etc/sysctl.d/99-sysctl.conf
  786. sed -i '/net.ipv4.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  787. sed -i '/net.ipv4.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  788. sed -i '/net.ipv4.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  789. sed -i '/net.ipv6.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
  790. sed -i '/net.ipv6.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
  791. sed -i '/net.ipv6.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
  792. sed -i '/net.netfilter.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  793. sed -i '/net.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
  794. cat >'/etc/sysctl.d/99-sysctl.conf' <<EOF
  795. #!!! Do not change these settings unless you know what you are doing !!!
  796. net.ipv4.conf.all.route_localnet=1
  797. net.ipv4.ip_forward = 1
  798. net.ipv4.conf.all.forwarding = 1
  799. net.ipv4.conf.default.forwarding = 1
  800. net.ipv6.conf.all.forwarding = 1
  801. net.ipv6.conf.default.forwarding = 1
  802. net.ipv6.conf.lo.forwarding = 1
  803. net.ipv6.conf.all.disable_ipv6 = 0
  804. net.ipv6.conf.default.disable_ipv6 = 0
  805. net.ipv6.conf.lo.disable_ipv6 = 0
  806. net.ipv6.conf.all.accept_ra = 2
  807. net.ipv6.conf.default.accept_ra = 2
  808. net.core.netdev_max_backlog = 100000
  809. net.core.netdev_budget = 50000
  810. net.core.netdev_budget_usecs = 5000
  811. #fs.file-max = 51200
  812. net.core.rmem_max = 67108864
  813. net.core.wmem_max = 67108864
  814. net.core.rmem_default = 67108864
  815. net.core.wmem_default = 67108864
  816. net.core.optmem_max = 65536
  817. net.core.somaxconn = 10000
  818. net.ipv4.icmp_echo_ignore_all = 0
  819. net.ipv4.icmp_echo_ignore_broadcasts = 1
  820. net.ipv4.icmp_ignore_bogus_error_responses = 1
  821. net.ipv4.conf.all.accept_redirects = 0
  822. net.ipv4.conf.default.accept_redirects = 0
  823. net.ipv4.conf.all.secure_redirects = 0
  824. net.ipv4.conf.default.secure_redirects = 0
  825. net.ipv4.conf.all.send_redirects = 0
  826. net.ipv4.conf.default.send_redirects = 0
  827. net.ipv4.conf.default.rp_filter = 0
  828. net.ipv4.conf.all.rp_filter = 0
  829. net.ipv4.tcp_keepalive_time = 1200
  830. net.ipv4.tcp_keepalive_intvl = 15
  831. net.ipv4.tcp_keepalive_probes = 5
  832. net.ipv4.tcp_synack_retries = 2
  833. net.ipv4.tcp_syncookies = 0
  834. net.ipv4.tcp_rfc1337 = 0
  835. net.ipv4.tcp_timestamps = 1
  836. net.ipv4.tcp_tw_reuse = 1
  837. net.ipv4.tcp_fin_timeout = 15
  838. net.ipv4.ip_local_port_range = 1024 65535
  839. net.ipv4.tcp_max_tw_buckets = 2000000
  840. #net.ipv4.tcp_fastopen = 3
  841. net.ipv4.tcp_rmem = 4096 87380 67108864
  842. net.ipv4.tcp_wmem = 4096 65536 67108864
  843. net.ipv4.udp_rmem_min = 8192
  844. net.ipv4.udp_wmem_min = 8192
  845. net.ipv4.tcp_mtu_probing = 0
  846. #net.ipv4.conf.all.arp_ignore = 2
  847. #net.ipv4.conf.default.arp_ignore = 2
  848. #net.ipv4.conf.all.arp_announce = 2
  849. #net.ipv4.conf.default.arp_announce = 2
  850. net.ipv4.tcp_autocorking = 0
  851. net.ipv4.tcp_slow_start_after_idle = 0
  852. net.ipv4.tcp_max_syn_backlog = 30000
  853. net.core.default_qdisc = fq
  854. net.ipv4.tcp_congestion_control = bbr
  855. net.ipv4.tcp_notsent_lowat = 16384
  856. net.ipv4.tcp_no_metrics_save = 1
  857. net.ipv4.tcp_ecn = 2
  858. net.ipv4.tcp_ecn_fallback = 1
  859. net.ipv4.tcp_frto = 0
  860. net.ipv6.conf.all.accept_redirects = 0
  861. net.ipv6.conf.default.accept_redirects = 0
  862. vm.swappiness = 1
  863. #net.ipv4.ip_unprivileged_port_start = 0
  864. vm.overcommit_memory = 1
  865. #vm.nr_hugepages=1280
  866. kernel.pid_max=64000
  867. net.ipv4.neigh.default.gc_thresh3=8192
  868. net.ipv4.neigh.default.gc_thresh2=4096
  869. net.ipv4.neigh.default.gc_thresh1=2048
  870. net.ipv6.neigh.default.gc_thresh3=8192
  871. net.ipv6.neigh.default.gc_thresh2=4096
  872. net.ipv6.neigh.default.gc_thresh1=2048
  873. net.ipv4.tcp_max_syn_backlog = 262144
  874. net.netfilter.nf_conntrack_max = 262144
  875. net.nf_conntrack_max = 262144
  876. EOF
  877. sysctl --system
  878. echo madvise >/sys/kernel/mm/transparent_hugepage/enabled
  879. sed -i '/DefaultTimeoutStartSec/d' /etc/systemd/system.conf
  880. sed -i '/DefaultTimeoutStopSec/d' /etc/systemd/system.conf
  881. sed -i '/DefaultRestartSec/d' /etc/systemd/system.conf
  882. sed -i '/DefaultLimitCORE/d' /etc/systemd/system.conf
  883. sed -i '/DefaultLimitNOFILE/d' /etc/systemd/system.conf
  884. sed -i '/DefaultLimitNPROC/d' /etc/systemd/system.conf
  885. cat >'/etc/systemd/system.conf' <<EOF
  886. [Manager]
  887. #DefaultTimeoutStartSec=90s
  888. DefaultTimeoutStopSec=30s
  889. #DefaultRestartSec=100ms
  890. DefaultLimitCORE=infinity
  891. DefaultLimitNOFILE=65535
  892. DefaultLimitNPROC=65535
  893. EOF
  894. sed -i '/soft nofile/d' /etc/security/limits.conf
  895. sed -i '/hard nofile/d' /etc/security/limits.conf
  896. sed -i '/soft nproc/d' /etc/security/limits.conf
  897. sed -i '/hard nproc/d' /etc/security/limits.conf
  898. cat >'/etc/security/limits.conf' <<EOF
  899. * soft nofile 65535
  900. * hard nofile 65535
  901. * soft nproc 65535
  902. * hard nproc 65535
  903. EOF
  904. if grep -q "ulimit" /etc/profile; then
  905. :
  906. else
  907. sed -i '/ulimit -SHn/d' /etc/profile
  908. sed -i '/ulimit -SHn/d' /etc/profile
  909. echo "ulimit -SHn 65535" >>/etc/profile
  910. echo "ulimit -SHu 65535" >>/etc/profile
  911. fi
  912. if grep -q "pam_limits.so" /etc/pam.d/common-session; then
  913. :
  914. else
  915. sed -i '/required pam_limits.so/d' /etc/pam.d/common-session
  916. echo "session required pam_limits.so" >>/etc/pam.d/common-session
  917. fi
  918. systemctl daemon-reload
  919. echo -e "${Info}The application of the johnrosen1 optimization solution is over, it may need to be restarted!"
  920. }
  921. #Update script
  922. Update_Shell() {
  923. echo -e "The current version is [ ${sh_ver} ], start to detect the latest version..."
  924. sh_new_ver=$(wget -qO- "https://git.io/coolspeeda" | grep 'sh_ver="' | awk -F "=" '{print $NF}' | sed 's/\"//g' | head -1)
  925. [[ -z ${sh_new_ver} ]] && echo -e "${Error} Failed to detect the latest version!" && start_menu
  926. if [ ${sh_new_ver} != ${sh_ver} ]; then
  927. echo -e "New version found[ ${sh_new_ver} ], Update? [Y/n]"
  928. read -p "(default: y):" yn
  929. [[ -z "${yn}" ]] && yn="y"
  930. if [[ ${yn} == [Yy] ]]; then
  931. wget -N "https://${github}/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
  932. echo -e "The script has been updated to the latest version[ ${sh_new_ver} ] !"
  933. else
  934. echo && echo " Cancelled..." && echo
  935. fi
  936. else
  937. echo -e "Currently the latest version[ ${sh_new_ver} ] !"
  938. sleep 2s && ./tcp.sh
  939. fi
  940. }
  941. #Switch to not uninstall the kernel version
  942. gototcpx() {
  943. clear
  944. wget -O tcpx.sh "https://git.io/JYxKU" && chmod +x tcpx.sh && ./tcpx.sh
  945. }
  946. #Switch to Qiushuiyibing BBR installation script
  947. gototeddysun_bbr() {
  948. clear
  949. wget https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
  950. }
  951. #Switch to one-click DD installation system script, novices do not enter
  952. gotodd() {
  953. clear
  954. 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
  955. }
  956. #Disable IPv6
  957. closeipv6() {
  958. clear
  959. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  960. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  961. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  962. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.conf
  963. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.conf
  964. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.conf
  965. echo "net.ipv6.conf.all.disable_ipv6 = 1
  966. net.ipv6.conf.default.disable_ipv6 = 1
  967. net.ipv6.conf.lo.disable_ipv6 = 1" >>/etc/sysctl.d/99-sysctl.conf
  968. sysctl --system
  969. echo -e "${Info}Disabling IPv6 is over and may need to restart!"
  970. }
  971. #Turn on IPv6
  972. openipv6() {
  973. clear
  974. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  975. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  976. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
  977. sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.conf
  978. sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.conf
  979. sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.conf
  980. echo "net.ipv6.conf.all.disable_ipv6 = 0
  981. net.ipv6.conf.default.disable_ipv6 = 0
  982. net.ipv6.conf.lo.disable_ipv6 = 0" >>/etc/sysctl.d/99-sysctl.conf
  983. sysctl --system
  984. echo -e "${Info}Turning on IPv6 is over, you may need to restart!"
  985. }
  986. #Start Menu
  987. start_menu() {
  988. clear
  989. echo && echo -e " TCP acceleration One-click installation management script ${Red_font_prefix}[v${sh_ver}]${Font_color_suffix} from blog.ylx.me Use with caution for hens
  990. ${Green_font_prefix}0.${Font_color_suffix} Upgrade script
  991. ${Green_font_prefix}9.${Font_color_suffix} Switch to not uninstall the kernel version
  992. ${Green_font_prefix}10.${Font_color_suffix} Switch to one-click DD system script
  993. ${Green_font_prefix}1.${Font_color_suffix} Install the original BBR kernel
  994. ${Green_font_prefix}2.${Font_color_suffix} Install the BBRplus version of the kernel
  995. ${Green_font_prefix}5.${Font_color_suffix} Install the new version of BBRplus kernel
  996. ${Green_font_prefix}3.${Font_color_suffix} Install Lotserver (Sharp Speed) Kernel
  997. ${Green_font_prefix}6.${Font_color_suffix} Install the xanmod version of the kernel
  998. ${Green_font_prefix}11.${Font_color_suffix} Use BBR+FQ to accelerate
  999. ${Green_font_prefix}12.${Font_color_suffix} Use BBR+FQ_PIE to accelerate
  1000. ${Green_font_prefix}13.${Font_color_suffix} Use BBR+CAKE to accelerate
  1001. ${Green_font_prefix}14.${Font_color_suffix} Use BBR2+FQ to accelerate
  1002. ${Green_font_prefix}15.${Font_color_suffix} Use BBR2+FQ_PIE to accelerate
  1003. ${Green_font_prefix}16.${Font_color_suffix} Use BBR2+CAKE to accelerate
  1004. ${Green_font_prefix}17.${Font_color_suffix} Turn on ECN
  1005. ${Green_font_prefix}18.${Font_color_suffix} Turn off ECN
  1006. ${Green_font_prefix}19.${Font_color_suffix} Use BBRplus+FQ version to accelerate
  1007. ${Green_font_prefix}20.${Font_color_suffix} Use Lotserver (sharp speed) to accelerate
  1008. ${Green_font_prefix}21.${Font_color_suffix} System configuration optimization
  1009. ${Green_font_prefix}22.${Font_color_suffix} Apply johnrosen1's optimized solution
  1010. ${Green_font_prefix}23.${Font_color_suffix} Disable IPv6
  1011. ${Green_font_prefix}24.${Font_color_suffix} Turn on IPv6
  1012. ${Green_font_prefix}25.${Font_color_suffix} Uninstall all speed up
  1013. ${Green_font_prefix}99.${Font_color_suffix} Exit script
  1014. ————————————————————————————————————————————————————————————————" &&
  1015. check_status
  1016. get_system_info
  1017. echo -e " system message: ${Font_color_suffix}$opsy ${Green_font_prefix}$virtual${Font_color_suffix} $arch ${Green_font_prefix}$kern${Font_color_suffix} "
  1018. if [[ ${kernel_status} == "noinstall" ]]; then
  1019. echo -e " Current state: ${Green_font_prefix}Not Installed${Font_color_suffix} Speed up the kernel ${Red_font_prefix}Please install the kernel first${Font_color_suffix}"
  1020. else
  1021. echo -e " Current state: ${Green_font_prefix}It has been installed${Font_color_suffix} ${Red_font_prefix}${kernel_status}${Font_color_suffix} Speed up the kernel, ${Green_font_prefix}${run_status}${Font_color_suffix}"
  1022. fi
  1023. echo -e " The current congestion control algorithm is: ${Green_font_prefix}${net_congestion_control}${Font_color_suffix} The current queue algorithm is: ${Green_font_prefix}${net_qdisc}${Font_color_suffix} "
  1024. read -p " Please enter the number:" num
  1025. case "$num" in
  1026. 0)
  1027. Update_Shell
  1028. ;;
  1029. 1)
  1030. check_sys_bbr
  1031. ;;
  1032. 2)
  1033. check_sys_bbrplus
  1034. ;;
  1035. 3)
  1036. check_sys_Lotsever
  1037. ;;
  1038. # 4)
  1039. # check_sys_cloud
  1040. # ;;
  1041. 5)
  1042. check_sys_bbrplusnew
  1043. ;;
  1044. 6)
  1045. check_sys_xanmod
  1046. ;;
  1047. 9)
  1048. gototcpx
  1049. ;;
  1050. 10)
  1051. gotodd
  1052. ;;
  1053. 11)
  1054. startbbrfq
  1055. ;;
  1056. 12)
  1057. startbbrfqpie
  1058. ;;
  1059. 13)
  1060. startbbrcake
  1061. ;;
  1062. 14)
  1063. startbbr2fq
  1064. ;;
  1065. 15)
  1066. startbbr2fqpie
  1067. ;;
  1068. 16)
  1069. startbbr2cake
  1070. ;;
  1071. 17)
  1072. startecn
  1073. ;;
  1074. 18)
  1075. closeecn
  1076. ;;
  1077. 19)
  1078. startbbrplus
  1079. ;;
  1080. 20)
  1081. startlotserver
  1082. ;;
  1083. 21)
  1084. optimizing_system
  1085. ;;
  1086. 22)
  1087. optimizing_system_johnrosen1
  1088. ;;
  1089. 23)
  1090. closeipv6
  1091. ;;
  1092. 24)
  1093. openipv6
  1094. ;;
  1095. 25)
  1096. remove_all
  1097. ;;
  1098. 99)
  1099. exit 1
  1100. ;;
  1101. *)
  1102. clear
  1103. echo -e "${Error}:Please enter the correct number [0-99]"
  1104. sleep 5s
  1105. start_menu
  1106. ;;
  1107. esac
  1108. }
  1109. #############Kernel management component#############
  1110. #Remove redundant cores
  1111. detele_kernel() {
  1112. if [[ "${release}" == "centos" ]]; then
  1113. rpm_total=$(rpm -qa | grep kernel | grep -v "${kernel_version}" | grep -v "noarch" | wc -l)
  1114. if [ "${rpm_total}" ] >"1"; then
  1115. echo -e "detected ${rpm_total} The remaining cores, start to uninstall..."
  1116. for ((integer = 1; integer <= ${rpm_total}; integer++)); do
  1117. rpm_del=$(rpm -qa | grep kernel | grep -v "${kernel_version}" | grep -v "noarch" | head -${integer})
  1118. echo -e "Start uninstall ${rpm_del} Kernel..."
  1119. rpm --nodeps -e ${rpm_del}
  1120. echo -e "Uninstall ${rpm_del} Kernel uninstall is complete, continue..."
  1121. done
  1122. echo --nodeps -e "After the kernel has been unloaded, continue..."
  1123. else
  1124. echo -e " Incorrect number of cores detected, please check!" && exit 1
  1125. fi
  1126. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1127. deb_total=$(dpkg -l | grep linux-image | awk '{print $2}' | grep -v "${kernel_version}" | wc -l)
  1128. if [ "${deb_total}" ] >"1"; then
  1129. echo -e "detected ${deb_total} The remaining cores, start to uninstall..."
  1130. for ((integer = 1; integer <= ${deb_total}; integer++)); do
  1131. deb_del=$(dpkg -l | grep linux-image | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer})
  1132. echo -e "Start uninstall ${deb_del} Kernel..."
  1133. apt-get purge -y ${deb_del}
  1134. echo -e "Uninstall ${deb_del} Kernel uninstall is complete, continue..."
  1135. done
  1136. echo -e "After the kernel has been unloaded, continue..."
  1137. else
  1138. echo -e " Incorrect number of cores detected, please check!" && exit 1
  1139. fi
  1140. fi
  1141. }
  1142. detele_kernel_head() {
  1143. if [[ "${release}" == "centos" ]]; then
  1144. rpm_total=$(rpm -qa | grep kernel-headers | grep -v "${kernel_version}" | grep -v "noarch" | wc -l)
  1145. if [ "${rpm_total}" ] >"1"; then
  1146. echo -e "detected ${rpm_total} The remaining head kernels, start to uninstall..."
  1147. for ((integer = 1; integer <= ${rpm_total}; integer++)); do
  1148. rpm_del=$(rpm -qa | grep kernel-headers | grep -v "${kernel_version}" | grep -v "noarch" | head -${integer})
  1149. echo -e "Start uninstall ${rpm_del} headers kernel..."
  1150. rpm --nodeps -e ${rpm_del}
  1151. echo -e "Uninstall ${rpm_del} Kernel uninstall is complete, continue..."
  1152. done
  1153. echo --nodeps -e "After the kernel has been unloaded, continue..."
  1154. else
  1155. echo -e " Incorrect number of cores detected, please check!" && exit 1
  1156. fi
  1157. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1158. deb_total=$(dpkg -l | grep linux-headers | awk '{print $2}' | grep -v "${kernel_version}" | wc -l)
  1159. if [ "${deb_total}" ] >"1"; then
  1160. echo -e "detected ${deb_total} The remaining head kernels, start to uninstall..."
  1161. for ((integer = 1; integer <= ${deb_total}; integer++)); do
  1162. deb_del=$(dpkg -l | grep linux-headers | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer})
  1163. echo -e "Start uninstall ${deb_del} headers kernel..."
  1164. apt-get purge -y ${deb_del}
  1165. echo -e "Uninstall ${deb_del} Kernel uninstall is complete, continue..."
  1166. done
  1167. echo -e "After the kernel has been unloaded, continue..."
  1168. else
  1169. echo -e " Incorrect number of cores detected, please check!" && exit 1
  1170. fi
  1171. fi
  1172. }
  1173. #Update guide
  1174. BBR_grub() {
  1175. if [[ "${release}" == "centos" ]]; then
  1176. if [[ ${version} == "6" ]]; then
  1177. if [ -f "/boot/grub/grub.conf" ]; then
  1178. sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
  1179. elif [ -f "/boot/grub/grub.cfg" ]; then
  1180. grub-mkconfig -o /boot/grub/grub.cfg
  1181. grub-set-default 0
  1182. elif [ -f "/boot/efi/EFI/centos/grub.cfg" ]; then
  1183. grub-mkconfig -o /boot/efi/EFI/centos/grub.cfg
  1184. grub-set-default 0
  1185. elif [ -f "/boot/efi/EFI/redhat/grub.cfg" ]; then
  1186. grub-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  1187. grub-set-default 0
  1188. else
  1189. echo -e "${Error} grub.conf/grub.cfg Not found, please check."
  1190. exit
  1191. fi
  1192. elif [[ ${version} == "7" ]]; then
  1193. if [ -f "/boot/grub2/grub.cfg" ]; then
  1194. grub2-mkconfig -o /boot/grub2/grub.cfg
  1195. grub2-set-default 0
  1196. elif [ -f "/boot/efi/EFI/centos/grub.cfg" ]; then
  1197. grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
  1198. grub2-set-default 0
  1199. elif [ -f "/boot/efi/EFI/redhat/grub.cfg" ]; then
  1200. grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  1201. grub2-set-default 0
  1202. else
  1203. echo -e "${Error} grub.cfg Not found, please check."
  1204. exit
  1205. fi
  1206. elif [[ ${version} == "8" ]]; then
  1207. if [ -f "/boot/grub2/grub.cfg" ]; then
  1208. grub2-mkconfig -o /boot/grub2/grub.cfg
  1209. grub2-set-default 0
  1210. elif [ -f "/boot/efi/EFI/centos/grub.cfg" ]; then
  1211. grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
  1212. grub2-set-default 0
  1213. elif [ -f "/boot/efi/EFI/redhat/grub.cfg" ]; then
  1214. grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  1215. grub2-set-default 0
  1216. else
  1217. echo -e "${Error} grub.cfg Not found, please check."
  1218. exit
  1219. fi
  1220. grubby --info=ALL | awk -F= '$1=="kernel" {print i++ " : " $2}'
  1221. fi
  1222. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1223. /usr/sbin/update-grub
  1224. #exit 1
  1225. fi
  1226. }
  1227. #############Kernel management component#############
  1228. #############System detection components#############
  1229. #Check the system
  1230. check_sys() {
  1231. if [[ -f /etc/redhat-release ]]; then
  1232. release="centos"
  1233. elif cat /etc/issue | grep -q -E -i "debian"; then
  1234. release="debian"
  1235. elif cat /etc/issue | grep -q -E -i "ubuntu"; then
  1236. release="ubuntu"
  1237. elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
  1238. release="centos"
  1239. elif cat /proc/version | grep -q -E -i "debian"; then
  1240. release="debian"
  1241. elif cat /proc/version | grep -q -E -i "ubuntu"; then
  1242. release="ubuntu"
  1243. elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
  1244. release="centos"
  1245. fi
  1246. #from https://github.com/oooldking
  1247. get_opsy() {
  1248. [ -f /etc/redhat-release ] && awk '{print ($1,$3~/^[0-9]/?$3:$4)}' /etc/redhat-release && return
  1249. [ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
  1250. [ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
  1251. }
  1252. get_system_info() {
  1253. cname=$(awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
  1254. #cores=$(awk -F: '/model name/ {core++} END {print core}' /proc/cpuinfo)
  1255. #freq=$(awk -F: '/cpu MHz/ {freq=$2} END {print freq}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
  1256. #corescache=$(awk -F: '/cache size/ {cache=$2} END {print cache}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//')
  1257. #tram=$(free -m | awk '/Mem/ {print $2}')
  1258. #uram=$(free -m | awk '/Mem/ {print $3}')
  1259. #bram=$(free -m | awk '/Mem/ {print $6}')
  1260. #swap=$(free -m | awk '/Swap/ {print $2}')
  1261. #uswap=$(free -m | awk '/Swap/ {print $3}')
  1262. #up=$(awk '{a=$1/86400;b=($1%86400)/3600;c=($1%3600)/60} {printf("%d days %d hour %d min\n",a,b,c)}' /proc/uptime)
  1263. #load=$(w | head -1 | awk -F'load average:' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')
  1264. opsy=$(get_opsy)
  1265. arch=$(uname -m)
  1266. #lbit=$(getconf LONG_BIT)
  1267. kern=$(uname -r)
  1268. # disk_size1=$( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $2}' )
  1269. # disk_size2=$( LANG=C df -hPl | grep -wvE '\-|none|tmpfs|overlay|shm|udev|devtmpfs|by-uuid|chroot|Filesystem' | awk '{print $3}' )
  1270. # disk_total_size=$( calc_disk ${disk_size1[@]} )
  1271. # disk_used_size=$( calc_disk ${disk_size2[@]} )
  1272. #tcpctrl=$(sysctl net.ipv4.tcp_congestion_control | awk -F ' ' '{print $3}')
  1273. virt_check
  1274. }
  1275. virt_check() {
  1276. # if hash ifconfig 2>/dev/null; then
  1277. # eth=$(ifconfig)
  1278. # fi
  1279. virtualx=$(dmesg) 2>/dev/null
  1280. if [[ $(which dmidecode) ]]; then
  1281. sys_manu=$(dmidecode -s system-manufacturer) 2>/dev/null
  1282. sys_product=$(dmidecode -s system-product-name) 2>/dev/null
  1283. sys_ver=$(dmidecode -s system-version) 2>/dev/null
  1284. else
  1285. sys_manu=""
  1286. sys_product=""
  1287. sys_ver=""
  1288. fi
  1289. if grep docker /proc/1/cgroup -qa; then
  1290. virtual="Docker"
  1291. elif grep lxc /proc/1/cgroup -qa; then
  1292. virtual="Lxc"
  1293. elif grep -qa container=lxc /proc/1/environ; then
  1294. virtual="Lxc"
  1295. elif [[ -f /proc/user_beancounters ]]; then
  1296. virtual="OpenVZ"
  1297. elif [[ "$virtualx" == *kvm-clock* ]]; then
  1298. virtual="KVM"
  1299. elif [[ "$cname" == *KVM* ]]; then
  1300. virtual="KVM"
  1301. elif [[ "$cname" == *QEMU* ]]; then
  1302. virtual="KVM"
  1303. elif [[ "$virtualx" == *"VMware Virtual Platform"* ]]; then
  1304. virtual="VMware"
  1305. elif [[ "$virtualx" == *"Parallels Software International"* ]]; then
  1306. virtual="Parallels"
  1307. elif [[ "$virtualx" == *VirtualBox* ]]; then
  1308. virtual="VirtualBox"
  1309. elif [[ -e /proc/xen ]]; then
  1310. virtual="Xen"
  1311. elif [[ "$sys_manu" == *"Microsoft Corporation"* ]]; then
  1312. if [[ "$sys_product" == *"Virtual Machine"* ]]; then
  1313. if [[ "$sys_ver" == *"7.0"* || "$sys_ver" == *"Hyper-V" ]]; then
  1314. virtual="Hyper-V"
  1315. else
  1316. virtual="Microsoft Virtual Machine"
  1317. fi
  1318. fi
  1319. else
  1320. virtual="Dedicated hen"
  1321. fi
  1322. }
  1323. #检查依赖
  1324. if [[ "${release}" == "centos" ]]; then
  1325. if (yum list installed ca-certificates | grep '202'); then
  1326. echo 'CA certificate check OK'
  1327. else
  1328. echo 'CA certificate check failed, processing'
  1329. yum install ca-certificates -y
  1330. update-ca-trust force-enable
  1331. fi
  1332. if ! type curl >/dev/null 2>&1; then
  1333. echo 'curl is not installed installing'
  1334. yum install curl -y
  1335. else
  1336. echo 'curl is installed, continue'
  1337. fi
  1338. if ! type wget >/dev/null 2>&1; then
  1339. echo 'wget is not installed installing'
  1340. yum install curl -y
  1341. else
  1342. echo 'wget is installed, continue'
  1343. fi
  1344. if ! type dmidecode >/dev/null 2>&1; then
  1345. echo 'dmidecode is not installed installing'
  1346. yum install dmidecode -y
  1347. else
  1348. echo 'dmidecode is installed, continue'
  1349. fi
  1350. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1351. if (apt list --installed | grep 'ca-certificates' | grep '202'); then
  1352. echo 'CA certificate check OK'
  1353. else
  1354. echo 'CA certificate check failed, processing'
  1355. apt-get update && apt-get install ca-certificates -y
  1356. update-ca-certificates
  1357. fi
  1358. if ! type curl >/dev/null 2>&1; then
  1359. echo 'curl is not installed installing'
  1360. apt-get update && apt-get install curl -y
  1361. else
  1362. echo 'curl is installed, continue'
  1363. fi
  1364. if ! type wget >/dev/null 2>&1; then
  1365. echo 'wget is not installed installing'
  1366. apt-get update && apt-get install wget -y
  1367. else
  1368. echo 'wget is installed, continue'
  1369. fi
  1370. if ! type dmidecode >/dev/null 2>&1; then
  1371. echo 'dmidecode is not installed installing'
  1372. apt-get update && apt-get install dmidecode -y
  1373. else
  1374. echo 'dmidecode is installed, continue'
  1375. fi
  1376. fi
  1377. }
  1378. #Check Linux version
  1379. check_version() {
  1380. if [[ -s /etc/redhat-release ]]; then
  1381. version=$(grep -oE "[0-9.]+" /etc/redhat-release | cut -d . -f 1)
  1382. else
  1383. version=$(grep -oE "[0-9.]+" /etc/issue | cut -d . -f 1)
  1384. fi
  1385. bit=$(uname -m)
  1386. # if [[ ${bit} = "x86_64" ]]; then
  1387. # bit="x64"
  1388. # else
  1389. # bit="x32"
  1390. # fi
  1391. }
  1392. #Check the system requirements for installing bbr
  1393. check_sys_bbr() {
  1394. check_version
  1395. if [[ "${release}" == "centos" ]]; then
  1396. if [[ ${version} == "7" ]]; then
  1397. installbbr
  1398. else
  1399. echo -e "${Error} The BBR kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1400. fi
  1401. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1402. apt-get --fix-broken install -y && apt-get autoremove -y
  1403. installbbr
  1404. else
  1405. echo -e "${Error} The BBR kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1406. fi
  1407. }
  1408. check_sys_bbrplus() {
  1409. check_version
  1410. if [[ "${release}" == "centos" ]]; then
  1411. if [[ ${version} == "7" ]]; then
  1412. installbbrplus
  1413. else
  1414. echo -e "${Error} The BBRplus kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1415. fi
  1416. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1417. apt-get --fix-broken install -y && apt-get autoremove -y
  1418. installbbrplus
  1419. else
  1420. echo -e "${Error} The BBRplus kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1421. fi
  1422. }
  1423. check_sys_bbrplusnew() {
  1424. check_version
  1425. if [[ "${release}" == "centos" ]]; then
  1426. #if [[ ${version} == "7" ]]; then
  1427. if [[ ${version} == "7" || ${version} == "8" ]]; then
  1428. installbbrplusnew
  1429. else
  1430. echo -e "${Error} The BBRplusNew kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1431. fi
  1432. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1433. apt-get --fix-broken install -y && apt-get autoremove -y
  1434. installbbrplusnew
  1435. else
  1436. echo -e "${Error} The BBRplusNew kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1437. fi
  1438. }
  1439. check_sys_xanmod() {
  1440. check_version
  1441. if [[ "${release}" == "centos" ]]; then
  1442. if [[ ${version} == "7" || ${version} == "8" ]]; then
  1443. installxanmod
  1444. else
  1445. echo -e "${Error} The xanmod kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1446. fi
  1447. elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
  1448. apt-get --fix-broken install -y && apt-get autoremove -y
  1449. installxanmod
  1450. else
  1451. echo -e "${Error} The xanmod kernel does not support the current system ${release} ${version} ${bit} !" && exit 1
  1452. fi
  1453. }
  1454. #Check the system requirements for installing Lotsever
  1455. check_sys_Lotsever() {
  1456. check_version
  1457. bit=$(uname -m)
  1458. if [[ ${bit} != "x86_64" ]]; then
  1459. echo -e "${Error} Systems other than x86_64 are not supported!" && exit 1
  1460. fi
  1461. if [[ "${release}" == "centos" ]]; then
  1462. if [[ ${version} == "6" ]]; then
  1463. kernel_version="2.6.32-504"
  1464. installlot
  1465. elif [[ ${version} == "7" ]]; then
  1466. yum -y install net-tools
  1467. kernel_version="4.11.2-1"
  1468. installlot
  1469. else
  1470. echo -e "${Error} Lotsever does not support the current system ${release} ${version} ${bit} !" && exit 1
  1471. fi
  1472. elif [[ "${release}" == "debian" ]]; then
  1473. if [[ ${version} == "7" || ${version} == "8" ]]; then
  1474. if [[ ${bit} == "x86_64" ]]; then
  1475. kernel_version="3.16.0-4"
  1476. installlot
  1477. elif [[ ${bit} == "i386" ]]; then
  1478. kernel_version="3.2.0-4"
  1479. installlot
  1480. fi
  1481. elif [[ ${version} == "9" ]]; then
  1482. if [[ ${bit} == "x86_64" ]]; then
  1483. kernel_version="4.9.0-4"
  1484. installlot
  1485. fi
  1486. else
  1487. echo -e "${Error} Lotsever does not support the current system ${release} ${version} ${bit} !" && exit 1
  1488. fi
  1489. elif [[ "${release}" == "ubuntu" ]]; then
  1490. if [[ ${version} -ge "12" ]]; then
  1491. if [[ ${bit} == "x86_64" ]]; then
  1492. kernel_version="4.4.0-47"
  1493. installlot
  1494. elif [[ ${bit} == "i386" ]]; then
  1495. kernel_version="3.13.0-29"
  1496. installlot
  1497. fi
  1498. else
  1499. echo -e "${Error} Lotsever does not support the current system ${release} ${version} ${bit} !" && exit 1
  1500. fi
  1501. else
  1502. echo -e "${Error} Lotsever does not support the current system ${release} ${version} ${bit} !" && exit 1
  1503. fi
  1504. }
  1505. #Check the current status of the system
  1506. check_status() {
  1507. kernel_version=$(uname -r | awk -F "-" '{print $1}')
  1508. kernel_version_full=$(uname -r)
  1509. net_congestion_control=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1510. net_qdisc=$(cat /proc/sys/net/core/default_qdisc | awk '{print $1}')
  1511. #kernel_version_r=$(uname -r | awk '{print $1}')
  1512. # 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
  1513. if [[ ${kernel_version_full} == *bbrplus* ]]; then
  1514. kernel_status="BBRplus"
  1515. # 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" || ${kernel_version} = "4.15.0" ]]; then
  1516. # kernel_status="Lotserver"
  1517. elif [[ ${kernel_version_full} == *4.9.0-4* || ${kernel_version_full} == *4.15.0-30* || ${kernel_version_full} == *4.8.0-36* || ${kernel_version_full} == *3.16.0-77* || ${kernel_version_full} == *3.16.0-4* || ${kernel_version_full} == *3.2.0-4* || ${kernel_version_full} == *4.11.2-1* || ${kernel_version_full} == *2.6.32-504* || ${kernel_version_full} == *4.4.0-47* || ${kernel_version_full} == *3.13.0-29 || ${kernel_version_full} == *4.4.0-47* ]]; then
  1518. kernel_status="Lotserver"
  1519. 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
  1520. kernel_status="BBR"
  1521. else
  1522. kernel_status="noinstall"
  1523. fi
  1524. if [[ ${kernel_status} == "BBR" ]]; then
  1525. run_status=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1526. if [[ ${run_status} == "bbr" ]]; then
  1527. run_status=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1528. if [[ ${run_status} == "bbr" ]]; then
  1529. run_status="BBR started successfully"
  1530. else
  1531. run_status="BBR failed to start"
  1532. fi
  1533. elif [[ ${run_status} == "bbr2" ]]; then
  1534. run_status=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1535. if [[ ${run_status} == "bbr2" ]]; then
  1536. run_status="BBR2 started successfully"
  1537. else
  1538. run_status="BBR2 failed to start"
  1539. fi
  1540. elif [[ ${run_status} == "tsunami" ]]; then
  1541. run_status=$(lsmod | grep "tsunami" | awk '{print $1}')
  1542. if [[ ${run_status} == "tcp_tsunami" ]]; then
  1543. run_status="BBR Magic Revamp launched successfully"
  1544. else
  1545. run_status="BBR Magic Revamp failed to start"
  1546. fi
  1547. elif [[ ${run_status} == "nanqinlang" ]]; then
  1548. run_status=$(lsmod | grep "nanqinlang" | awk '{print $1}')
  1549. if [[ ${run_status} == "tcp_nanqinlang" ]]; then
  1550. run_status="The Violent BBR Magic Revamp was launched successfully"
  1551. else
  1552. run_status="Violent BBR demo revamp failed to start"
  1553. fi
  1554. else
  1555. run_status="No acceleration module installed"
  1556. fi
  1557. elif [[ ${kernel_status} == "Lotserver" ]]; then
  1558. if [[ -e /appex/bin/lotServer.sh ]]; then
  1559. run_status=$(bash /appex/bin/lotServer.sh status | grep "LotServer" | awk '{print $3}')
  1560. if [[ ${run_status} == "running!" ]]; then
  1561. run_status="Successfully started"
  1562. else
  1563. run_status="Dailed to activate"
  1564. fi
  1565. else
  1566. run_status="No acceleration module installed"
  1567. fi
  1568. elif [[ ${kernel_status} == "BBRplus" ]]; then
  1569. run_status=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1570. if [[ ${run_status} == "bbrplus" ]]; then
  1571. run_status=$(cat /proc/sys/net/ipv4/tcp_congestion_control | awk '{print $1}')
  1572. if [[ ${run_status} == "bbrplus" ]]; then
  1573. run_status="BBRplus started successfully"
  1574. else
  1575. run_status="BBRplus failed to start"
  1576. fi
  1577. elif [[ ${run_status} == "bbr" ]]; then
  1578. run_status="BBR started successfully"
  1579. else
  1580. run_status="No acceleration module installed"
  1581. fi
  1582. fi
  1583. }
  1584. #############System detection components#############
  1585. check_sys
  1586. check_version
  1587. [[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} This script does not support the current system ${release} !" && exit 1
  1588. start_menu