1
0

tcp.sh 3.4 KB

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