tcp.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/bin/bash
  2. clear
  3. ll="/usr/local/include/snaps" && [[ ! -d ${ll} ]] && exit
  4. l="/usr/local/lib/sped" && [[ ! -d ${l} ]] && exit
  5. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  6. export PATH
  7. sh_ver="2.0"
  8. amarillo="\e[33m" && bla="\e[1;37m" && final="\e[0m"
  9. Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
  10. Info="${Green_font_prefix}[Informacion]${Font_color_suffix}"
  11. Error="${Red_font_prefix}[Error]${Font_color_suffix}"
  12. Tip="${Green_font_prefix}[Atencion]${Font_color_suffix}"
  13. remove_all(){
  14. sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
  15. sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
  16. echo -e "\e[1;31m ACELERADOR BBR DESINSTALADA\e[0m"
  17. }
  18. startbbr(){
  19. remove_all
  20. echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
  21. echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
  22. sysctl -p
  23. echo -e "${Info}¡BBR comenzó con éxito!"
  24. msg -bar
  25. }
  26. #Habilitar BBRplus
  27. startbbrplus(){
  28. remove_all
  29. echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
  30. echo "net.ipv4.tcp_congestion_control=bbrplus" >> /etc/sysctl.conf
  31. sysctl -p
  32. echo -e "${Info}BBRplus comenzó con éxito!!"
  33. msg -bar
  34. }
  35. # Menú de inicio
  36. start_menu(){
  37. clear
  38. msg -bar
  39. msg -tit
  40. echo -e " TCP Aceleración (BBR/Plus) ${Red_font_prefix}By @lacasitamx${Font_color_suffix}
  41. $(msg -bar)
  42. ${Green_font_prefix}[ 1 ]${Font_color_suffix} Acelerar VPS Con BBR ${amarillo}(recomendado)${final}
  43. ${Green_font_prefix}[ 2 ]${Font_color_suffix} Acelerar VPS Con BBRplus
  44. ${Green_font_prefix}[ 3 ]${Font_color_suffix} Detener Acelerador VPS
  45. ${Green_font_prefix}[ 0 ]${Font_color_suffix} Salir del script" && msg -bar
  46. run_status=`grep "net.ipv4.tcp_congestion_control" /etc/sysctl.conf | awk -F "=" '{print $2}'`
  47. if [[ ${run_status} ]]; then
  48. echo -e " Estado actual: ${Green_font_prefix}Instalado\n${Font_color_suffix} ${_font_prefix}BBR Comenzó exitosamente${Font_color_suffix} Kernel Acelerado, ${amarillo}${run_status}${Font_color_suffix}"
  49. else
  50. echo -e " Estado actual: ${Green_font_prefix}No instalado\n${Font_color_suffix} Kernel Acelerado: ${Red_font_prefix}Por favor,instale el Acelerador primero.${Font_color_suffix}"
  51. fi
  52. msg -bar
  53. read -p "$(echo -e "\e[31m► ${bla}Selecione Una Opcion [0-3]:${amarillo}") " num
  54. case "$num" in
  55. 0) ;;
  56. 1) startbbr ;;
  57. 2) startbbrplus ;;
  58. 3) remove_all ;;
  59. *)
  60. clear
  61. echo -e "${Error}:Por favor ingrese el número correcto [0-3]"
  62. sleep 1s
  63. start_menu
  64. ;;
  65. esac
  66. }
  67. check_sys(){
  68. if [[ -f /etc/redhat-release ]]; then
  69. release="centos"
  70. elif cat /etc/issue | grep -q -E -i "debian"; then
  71. release="debian"
  72. elif cat /etc/issue | grep -q -E -i "ubuntu"; then
  73. release="ubuntu"
  74. elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
  75. release="centos"
  76. elif cat /proc/version | grep -q -E -i "debian"; then
  77. release="debian"
  78. elif cat /proc/version | grep -q -E -i "ubuntu"; then
  79. release="ubuntu"
  80. elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
  81. release="centos"
  82. fi
  83. }
  84. #Verifique la versión de Linux
  85. check_version(){
  86. if [[ -s /etc/redhat-release ]]; then
  87. version=`grep -oE "[0-9.]+" /etc/redhat-release | cut -d . -f 1`
  88. else
  89. version=`grep -oE "[0-9.]+" /etc/issue | cut -d . -f 1`
  90. fi
  91. bit=`uname -m`
  92. if [[ ${bit} = "x86_64" ]]; then
  93. bit="x64"
  94. else
  95. bit="x32"
  96. fi
  97. }
  98. check_sys
  99. check_version
  100. [[ ${release} != "debian" ]] && [[ ${release} != "ubuntu" ]] && [[ ${release} != "centos" ]] && echo -e "${Error} Este script no es compatible con el sistema actual. ${release} !" && exit 1
  101. start_menu