tcpbbr.sh 77 KB

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