├── A ├── Images ├── 01.png ├── 02.png ├── 03.png ├── 04.png ├── 05.png ├── Error01.png ├── Error02.png └── OLD.01.png ├── README.md └── compile_tcp_cc.sh /A: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Author: Aniverse 4 | # https://github.com/Aniverse/TrCtrlProToc0l 5 | # 6 | ################################################################################# 7 | # 8 | # Thanks to 9 | # https://github.com/KozakaiAya/TCP_BBR 10 | # 11 | # https://github.com/FunctionClub/YankeeBBR 12 | # https://sometimesnaive.org/article/linux/bash/tcp_nanqinlang 13 | # https://moeclub.org/2017/06/06/249/ 14 | # https://moeclub.org/2017/03/09/14/ 15 | # https://www.94ish.me/1635.html 16 | # http://xiaofd.win/onekey-ruisu.html 17 | # https://teddysun.com/489.html 18 | # 19 | ################################################################################# 20 | ScriptVersion=3.4.9 21 | ScriptDate=2020.08.17 22 | 23 | usage_guide() { 24 | bash <(wget -qO- https://git.io/AccTCP) 25 | bash <(wget -qO- https://github.com/Aniverse/TrCtrlProToc0l/raw/master/A) 26 | bash <(curl -s https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/A) 27 | s=tcpcc;rm -f $s;nano $s ;echo 5| bash tcpcc 28 | } 29 | ################################################################################# 30 | 31 | # 颜色 ----------------------------------------------------------------------------------- 32 | 33 | black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold) 34 | blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0) 35 | on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3) 36 | on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7) 37 | shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold} 38 | underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim) 39 | standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout} 40 | baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green} 41 | baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta} 42 | heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black} 43 | 44 | function exit_1() { rm -rf /etc/TrCtrlProToc0l /tmp/system_kernel_list /log/kernel_tobe_del_list $HOME/1 ; exit 1 ; } 45 | 46 | # ----------------------------------------------------------------------------------- 47 | 48 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$PATH 49 | 50 | mkdir -p /etc/TrCtrlProToc0l /log/tcp ; cd /etc/TrCtrlProToc0l 51 | 52 | cancel() { echo -e "${normal}" 53 | rm -rf /tmp/system_kernel_list /log/kernel_tobe_del_list /etc/TrCtrlProToc0l $HOME/1 54 | exit ; } 55 | trap cancel SIGINT 56 | 57 | # OutputLOG="/dev/null" 58 | export DEBIAN_FRONTEND=noninteractive 59 | SETUPDATE=$(date "+%Y.%m.%d.%H:%M:%S") 60 | export OutputLOG="/log/tcp/$SETUPDATE.log" 61 | SysSupport=0 ; DeBUG=0 62 | [[ $1 == -d ]] && DeBUG=1 63 | 64 | KernelBit=$(getconf LONG_BIT) 65 | [[ $KernelBit == 32 ]] && KernelBitVer=i386 ; [[ $KernelBit == 64 ]] && KernelBitVer=amd64 66 | DISTRO=` awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release | tr 'A-Z' 'a-z' ` 67 | DISTROU=` awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release ` 68 | CODENAME=` cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}' ` 69 | [[ $DISTRO == ubuntu ]] && osversion=` grep Ubuntu /etc/issue | head -1 | grep -oE "[0-9.]+" ` 70 | [[ $DISTRO == debian ]] && osversion=` cat /etc/debian_version ` 71 | [[ $CODENAME =~ (xenial|bionic|jessie|stretch|buster|focal) ]] && SysSupport=1 72 | function version_ge(){ test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1" ; } 73 | 74 | # ----------------------------------------------------------------------------------- 75 | 76 | [[ $EUID -ne 0 ]] && echo -e "\n${red}错误${jiacu} 请使用 root 运行本脚本!${normal}" && exit_1 77 | 78 | [[ ! $DeBUG == 1 ]] && { 79 | [[ -d /proc/vz ]] && echo -e "\n${red}错误${jiacu} 不支持 OpenVZ!${normal}" && exit_1 80 | # Xen-PV 也不支持,不过就不作检测了…… 81 | [[ ! $KernelBit == 64 ]] && echo -e "\n${red}错误${jiacu} 不支持非 64 位系统!${normal}" && exit_1 82 | [[ -z "$(dpkg -l |grep 'grub-')" ]] && echo -e "\n${red}错误${jiacu} 未发现 grub!${normal}" && exit_1 83 | [[ ! $SysSupport == 1 ]] && echo -e "\n${red}错误${jiacu} 不支持 Debian 8/9/10、Ubuntu 16.04/18.04 以外的系统!${normal}" && exit_1 84 | } 85 | 86 | 87 | 88 | 89 | # 菜单 90 | function script_menu() { clear ; echo 91 | 92 | for ddd in debconf-set-selections debconf-get-selections ; do 93 | if [[ ! `command -v $ddd` ]]; then 94 | wget --no-check-certificate -qO /usr/bin/$ddd https://github.com/Aniverse/inexistence/raw/master/00.Installation/script/$ddd 95 | chmod +x /usr/bin/$ddd 96 | fi 97 | done 98 | 99 | [ -f /etc/redhat-release ] && KNA=$(awk '{print $1}' /etc/redhat-release) 100 | [ -f /etc/os-release ] && KNA=$(awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release) 101 | [ -f /etc/lsb-release ] && KNA=$(awk -F'[="]+' '/DISTRIB_ID/{print $2}' /etc/lsb-release) 102 | tcp_control=` cat /proc/sys/net/ipv4/tcp_congestion_control ` 103 | tcp_control_all=` cat /proc/sys/net/ipv4/tcp_available_congestion_control ` 104 | running_kernel=` uname -r ` 105 | arch=$( uname -m ) 106 | lbit=$( getconf LONG_BIT ) 107 | 108 | tcp_c_name=$tcp_control 109 | [[ $tcp_control == cubic ]] && tcp_c_name="cubic (系统默认算法)" 110 | [[ $tcp_control == bbr ]] && tcp_c_name="bbr (原版 BBR)" 111 | [[ $tcp_control == bbr_powered ]] && tcp_c_name="bbr_powered (用 Vicer 脚本安装的 Yankee 版魔改 BBR)" 112 | [[ $tcp_control == tsunami ]] && tcp_c_name="tsunami (Yankee 版魔改 BBR)" 113 | [[ $tcp_control == nanqinlang ]] && tcp_c_name="nanqinlang (南琴浪版魔改 BBR)" 114 | 115 | # 以后准备增加检查当前系统是否有可用内核但是没启用的情况(比如装了4.11.12,但是当前锐速使用了3.16.0-43,这样要切换到BBR的话其实不需要删掉内核或者重新安装4.11.12的) 116 | # 不过想不删掉其他内核只用那个内核的话还是有点麻烦的,估计还是会写成把其他内核删掉的方法 117 | # digit_ver_image=`dpkg -l | grep linux-image | awk '{print $2}' | awk -F '-' '{print $3}'` 118 | # digit_ver_headers=`dpkg -l | grep linux-headers | awk '{print $2}' | awk -F '-' '{print $3}'` 119 | 120 | # 检查理论上内核是否支持锐速 121 | LSKernel="${red}否${jiacu}" 122 | SSKernel="${red}否${jiacu}" 123 | LS_Kernel_url='https://raw.githubusercontent.com/Aniverse/lotServer/master/lotServer.log' 124 | AcceVer=$(wget --no-check-certificate -qO- "$LS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |awk -F'/' '{print $NF}' |sort -n -k 2 -t '_' |tail -n 1) 125 | MyKernel=$(wget --no-check-certificate -qO- "$LS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |grep "$AcceVer" |tail -n 1) 126 | [[ -n $MyKernel ]] && LSKernel="${green}是${jiacu}" 127 | unset MyKernel 128 | SS_Kernel_url='https://github.com/Aniverse/ServerSpeeder/raw/master/serverSpeeder.txt' 129 | AcceVer=$(wget --no-check-certificate -qO- "$SS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |awk -F'/' '{print $NF}' |sort -n -k 2 -t '_' |tail -n 1) 130 | MyKernel=$(wget --no-check-certificate -qO- "$SS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |grep "$AcceVer" |tail -n 1) 131 | [[ -n $MyKernel ]] && SSKernel="${green}是${jiacu}" 132 | [[ $LSKernel == "${green}是${jiacu}" || $SSKernel == "${green}是${jiacu}" ]] && tcp_c_name_suffix=" (是否开启锐速与此项无关)" 133 | 134 | # 检查理论上内核是否支持原版 BBR(内核高于 4.9 也不一定就有 bbr) 135 | # 2018.10.23 这个以后再拿去判断,现在懒得动了 136 | # 2019.04.25 也有的内核里这里没有 bbr 137 | ls /lib/modules/$(uname -r)/kernel/net/ipv4 2>/dev/null | grep -q bbr && bbr_exist=yes || bbr_exist=no 138 | 139 | kernel_vvv=$(uname -r | cut -d- -f1) 140 | if version_ge $kernel_vvv 4.9 ; then BBRKernel="${green}是${jiacu}" ; else BBRKernel="${red}否${jiacu}" ; fi 141 | if version_ge $kernel_vvv 4.9.3 && ! version_ge $kernel_vvv 5.8 ; then YKKernel="${green}是${jiacu}" ; else YKKernel="${red}否${jiacu}" ; fi 142 | if version_ge $kernel_vvv 4.9.3 && ! version_ge $kernel_vvv 5.8 ; then NQLKernel="${green}是${jiacu}" ; else NQLKernel="${red}否${jiacu}" ; fi 143 | # if version_ge $kernel_vvv 4.14 && ! version_ge $kernel_vvv 5.1 ; then BBRPKernel="${green}是${jiacu}" 144 | # elif version_ge $kernel_vvv 5.1 ; then BBRPKernel="${green}无需 bbrplus${jiacu}" ; else BBRPKernel="${red}否${jiacu}" ; fi 145 | if uname -r | grep -q bbrplus ; then BBRPKernel="${green}是${jiacu}" ; else BBRPKernel="${red}否${jiacu}" ; fi 146 | 147 | # 检查 锐速 与 BBR 是否已启用 148 | [[ ` ps aux | grep appex | grep -v grep ` ]] && SSrunning="${green}是${jiacu}" || SSrunning="${red}否${jiacu}" 149 | 150 | if [[ $tcp_control =~ ("nanqinlang"|"tsunami") ]]; then bbrinuse="${green}是${jiacu}" 151 | elif [[ `echo $tcp_control | grep bbr` ]]; then bbrinuse="${green}是${jiacu}" 152 | else bbrinuse="${red}否${jiacu}" ; fi 153 | 154 | dpkg -l | grep linux-image | awk '{print $2}' >> /tmp/system_kernel_list 155 | dpkg -l | grep ovhkernel | awk '{print $2}' >> /tmp/system_kernel_list 156 | dpkg -l | grep pve-kernel | awk '{print $2}' >> /tmp/system_kernel_list 157 | dpkg -l | grep linux-headers | awk '{print $2}' >> /tmp/system_kernel_list 158 | dpkg -l | grep linux-modules | awk '{print $2}' >> /tmp/system_kernel_list 159 | dpkg -l | grep generic-hwe | awk '{print $2}' >> /tmp/system_kernel_list 160 | 161 | echo -e " ${baizise}${bold} El Psy Congroo! ${normal} " 162 | echo -e " ${bold}" 163 | echo -e " 当前操作系统 ${green}$DISTROU $osversion $CODENAME (x$lbit)${jiacu}" 164 | echo -e " 当前正在使用的 TCP 拥塞控制算法 ${green}$tcp_c_name$tcp_c_name_suffix${jiacu}" 165 | [[ $DeBUG == 1 ]] && 166 | echo -e " 当前可以使用的 TCP 拥塞控制算法 ${green}$tcp_control_all${jiacu}" 167 | echo -e " 当前正在使用的系统内核 ${green}$running_kernel${jiacu}" 168 | echo -e " 当前内核是否支持 bbr $BBRKernel" 169 | echo -e " 当前内核是否支持 bbrplus $BBRPKernel" 170 | echo -e " 当前内核是否支持 Yankee 版魔改 bbr $YKKernel" 171 | echo -e " 当前内核是否支持 南琴浪 版魔改 bbr $NQLKernel" 172 | echo -e " 当前内核是否支持 ServerSpeeder $SSKernel" 173 | echo -e " 当前内核是否支持 LotServer $LSKernel" 174 | echo -e " 当前 BBR 是否已启用 $bbrinuse" 175 | echo -e " 当前 锐速 是否已启用 $SSrunning" 176 | 177 | echo -e "\n 当前系统内所有已安装的 kernel/headers/modules 列表\n" 178 | cat -n /tmp/system_kernel_list | sed 's/\t/ /g' | sed "s/ linux-/) ${green}linux-/g" | sed "s/ pve-/) ${green}pve-/g" | sed "s/ ovhkernel-/) ${green}ovhkernel-/g" | sed "s/ / ${magenta}(0/g" | sed "s/ / ${magenta}(/g" 179 | echo -e "\n ${jiacu}当前脚本版本:$ScriptVersion 脚本更新时间:$ScriptDate" 180 | [[ $DeBUG == 1 ]] && echo -e "\n 当前脚本已处于调试模式" 181 | echo -e "\n ${yellow}${bold}使用本脚本前请先阅读本脚本 GitHub 上的 README;作者水平菜,不保证脚本不会翻车${jiacu}\n" 182 | echo -e " 如果脚本出了问题,可以输入这条命令查看日志:${red}cat $OutputLOG${jiacu}" 183 | echo -e "\n 如需报错请务必附上日志${jiacu}\n" 184 | 185 | [[ ! $( dpkg -l | grep $(uname -r) ) ]] && echo -e "\n ${bold}${red}注意${jiacu} 系统中似乎检测不到你当前的内核,你可能正在使用来自 netboot 的内核。\n 这种情况下本脚本的功能不一定能正常工作!\n" 186 | 187 | # 下次考虑把 exit_1 也加上报错信息提示 188 | 189 | echo -e " ${green}(01) ${jiacu}安装 原版 BBR " 190 | echo -e " ${green}(02) ${jiacu}安装 魔改 BBR / tsunami " 191 | echo -e " ${green}(03) ${jiacu}安装 魔改 BBR / nanqinlang " 192 | echo -e " ${green}(04) ${jiacu}安装 bbrplus " 193 | echo -e " ${green}(05) ${jiacu}安装 锐速 / LotServer " 194 | echo -e " ${green}(06) ${jiacu}安装 锐速 / ServerSpeeder " 195 | [[ $DeBUG == 1 ]] && { 196 | echo -e " ${green}(11) ${jiacu}安装 指定内核" 197 | echo -e " ${green}(12) ${jiacu}安装 4.19.102 内核" 198 | echo -e " ${green}(13) ${jiacu}安装 ServerSpeeder 内核(4.4.0-47 或 3.12.1)" 199 | echo -e " ${green}(14) ${jiacu}安装 ServerSpeeder 内核(3.16.0-43 或 3.16.0-4)" 200 | echo -e " ${green}(15) ${jiacu}安装 LotServer 内核(4.15.0-30 或 4.9.0-4)" 201 | echo -e " ${green}(16) ${jiacu}安装 LotServer 内核(MoeClub 脚本)" 202 | echo -e " ${green}(17) ${jiacu}安装 4.14.129-bbrplus 内核" 203 | } 204 | echo -e " ${green}(21) ${jiacu}卸载 BBR " 205 | echo -e " ${green}(22) ${jiacu}卸载 锐速 " 206 | echo -e " ${green}(23) ${jiacu}卸载 多余内核 " 207 | echo -e " ${green}(24) ${jiacu}卸载 指定内核 " 208 | [[ $DeBUG == 1 ]] && { 209 | echo -e " ${green}(25) ${jiacu}卸载 所有内核(作死) " 210 | echo -e " ${green}(31) ${jiacu}安装 Xanmod " 211 | echo -e " ${green}(32) ${jiacu}安装 Xanmod,并删除其他内核 " 212 | echo -e " ${green}(33) ${jiacu}安装 liquorix " 213 | echo -e " ${green}(39) ${jiacu}安装 HWE 内核(Ubuntu 专用)" 214 | } 215 | echo -e " ${green}(41) ${jiacu}安装 锐速 / LotServer (MoeClub 脚本)" 216 | echo -e " ${green}(90) ${jiacu}重启 " 217 | [[ $DeBUG == 1 ]] && { 218 | echo -e " ${green}(96) ${jiacu}切换拥塞控制算法 " 219 | echo -e " ${green}(98) ${jiacu}调试 " 220 | } 221 | echo -e " ${green}(99) ${jiacu}返回 \n" 222 | rm -f /tmp/system_kernel_list 223 | } 224 | 225 | 226 | 227 | 228 | 229 | 230 | # action 231 | function read_response() { 232 | read -ep " ${yellow}你想做什么?(默认返回) ${normal}" response ; echo -n "${normal}" 233 | 234 | case $response in 235 | 1 | 01) # 安装 原版 BBR 236 | bbr_install ;; 237 | 2 | 02) # 安装 魔改 BBR (Yankee) 238 | ykbbr_install ;; 239 | 3 | 03) # 安装 魔改 BBR (nanqinlang) 240 | nqlbbr_install ;; 241 | 4 | 04) # 安装 bbrplus 242 | bbr_plus_install ;; 243 | 5 | 05) # 安装 LotServer 244 | ls_install ;; 245 | 6 | 06) # 安装 ServerSpeeder 246 | ss_install ;; 247 | 11) # 安装 最新内核 248 | selected_kernel_install ;; 249 | 12) # 安装 4.19.102 内核 250 | # online_ubuntu_bbr_firmware 251 | bbr_kernel_4_19_102 ;; 252 | 13) # 安装 特定的 ServerSpeeder 内核(4.4.0-47/3.12.1) 253 | ss_kernel_install ;; 254 | 14) # 安装 ServerSpeeder 内核(3.16.0-43/3.16.0-4) 255 | [[ $DISTRO == debian ]] && debian_ssr_kernel_3.16.0-4_apt 256 | [[ $CODENAME == xenial ]] && kernelver=3.16.0-43-generic && ubuntu_serverspeeder_kernel_repo ;; 257 | 15) # 安装 LotServer 支持的内核(只支持新系统)(4.15.0-30/4.9.0-4) 258 | ss_kernel_install_v2 ;; 259 | 16) # 安装 LotServer 支持的内核(支持 Ubuntu 14.04/16.04/18.04,Debian 7/8/9) 260 | Debian_Kernel.sh ;; 261 | 17) # 安装 bbrplus 内核 262 | bbr_plus_kernel_4_14 ;; 263 | 21) # 卸载 BBR 264 | bbr_uninstall ;; 265 | 22) # 卸载 锐速 266 | ss_uninstall ;; 267 | 23) # 卸载 多余内核 268 | while [[ -z $kernel_version ]]; do 269 | echo -ne "\n ${bold}请输入你要 ${baihongse}保留${jiacu} 的内核版本,其他版本的内核将会被卸载:${normal} " ; read -e kernel_version 270 | [[ ! ` dpkg -l | grep linux-image | grep "$kernel_version" ` ]] && { echo -e "\n ${bold}${red}错误${jiacu} 大佬,你压根就没装这个内核吧!${normal}" ; unset kernel_version ; } 271 | done 272 | delete_other_kernel ; delete_other_kernel ;; 273 | 24) # 卸载 多余内核 274 | while [[ -z $kernel_version ]]; do 275 | echo -ne "\n ${bold}请输入你要 ${baihongse}卸载${jiacu} 的内核版本,其他版本的内核将会被保留:${normal} " ; read -e kernel_version 276 | [[ ! ` dpkg -l | grep linux-image | grep "$kernel_version" ` ]] && { echo -e "\n ${bold}${red}错误${jiacu} 大佬,你压根就没装这个内核吧!${normal}" ; unset kernel_version ; } 277 | done 278 | delete_kernel ;; 279 | 25) # 卸载 所有内核 280 | echo -ne "\n ${bold}想清楚了?${normal} " ; read 281 | kernel_version=10086 282 | delete_other_kernel ; delete_other_kernel ;; 283 | 31) # 安装 xanmod 284 | xanmod_install ;; 285 | 32) # 安装 xanmod,删除其他内核 286 | xanmod_install ; delete_other_kernel ; delete_other_kernel ;; 287 | 33) # 安装 liquorix 288 | liquorix_install ;; 289 | 39) # 安装 HWE 内核 290 | [[ $CODENAME == xenial ]] && apt-get install -y linux-generic-hwe-16.04 291 | [[ $CODENAME == bionic ]] && apt-get install -y linux-generic-hwe-18.04 ;; 292 | 41) # MoeClub 脚本安装锐速 293 | echo | bash <(wget -qO- https://github.com/MoeClub/lotServer/raw/master/Install.sh) install ;; 294 | 90) # 重启 295 | reboot ;; 296 | 96) # 切换 TCP 拥塞控制算法 297 | switch_cc ;; 298 | 98) # 启用调试模式 299 | DeBUG=1 ; script_menu ; read_response ;; 300 | ""| 99) # 返回 301 | echo ; exit 0 ;; 302 | *) echo ; exit 0 ;; 303 | esac 304 | } 305 | 306 | 307 | 308 | 309 | 310 | 311 | ################################################################################################################################################################### 312 | # [[ `grep "Advanced options for Ubuntu" /etc/default/grub` ]] && sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=""/' /etc/default/grub 313 | 314 | 315 | 316 | 317 | 318 | #S1# 安装 原版 BBR 319 | function bbr_install() { 320 | if [[ $BBRKernel == "${green}是${jiacu}" ]]; then 321 | echo -ne "\n ${bold}理论上当前内核已支持 ${green}原版 BBR,尝试直接启用 BBR ...${normal} " 322 | enable_bbr ; echo 323 | [[ $(cat /proc/sys/net/ipv4/tcp_congestion_control) == bbr ]] && echo -e "\n ${bold}BBR 已启用 ...\n${normal}" || echo -e "\n ${bold}${red}警告 BBR 可能开启失败!考虑换个内核?${normal}\n" 324 | else 325 | ask_continue2 326 | # echo -e " ${bold}当前内核不支持 BBR,先安装 ${green}4.11.12${jiacu} 内核以启用 BBR ...${normal} " 327 | # online_ubuntu_bbr_firmware 328 | bbr_kernel_4_19_102 329 | enable_bbr 330 | [[ ! $DeBUG == 1 ]] && echo -ne "\n ${bold}即将重启系统,重启后 ${green}BBR${jiacu} 将会启动 ... ${normal}\n" && reboot 331 | fi 332 | } 333 | 334 | 335 | 336 | #S2# 安装 Yankee版魔改 BBR 337 | function ykbbr_install() { 338 | if [[ $YKKernel == "${green}是${jiacu}" ]]; then 339 | echo -e "\n ${bold}理论上当前内核已支持 ${green}Yankee${jiacu} 版魔改 BBR,安装并启用魔改 BBR ...${normal} " 340 | check_headers 341 | check_essential 342 | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) tsunami >> $OutputLOG 2>&1 343 | enable_bbr tsunami 344 | if [[ ` lsmod | grep tsunami ` ]]; then echo -e "\n ${bold}已开启 ${green}Yankee 版魔改 BBR${jiacu} ...${normal}\n" 345 | else echo -e "\n ${bold}${red}错误 ${green}Yankee 版魔改 BBR${jiacu} 开启失败!考虑换个内核?${normal}\n" ; exit_1 ; fi 346 | else 347 | ask_continue2 348 | # echo -e " ${bold}当前内核不支持 ${green}Yankee${jiacu} 版魔改 BBR,先安装 ${green}4.11.12${jiacu} 内核 ...${normal} " 349 | # online_ubuntu_bbr_firmware 350 | check_essential 351 | bbr_kernel_4_19_102 352 | delete_other_kernel 353 | bbr_tsunami_autoinstall 354 | enable_bbr tsunami 355 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}Yankee${jiacu} 版魔改 BBR ... ${normal}\n" && reboot 356 | fi 357 | } 358 | 359 | 360 | 361 | #S3# 安装 南琴浪版魔改 BBR 362 | function nqlbbr_install() { 363 | if [[ $NQLKernel == "${green}是${jiacu}" ]]; then 364 | echo -e "\n ${bold}理论上当前内核已支持 ${green}南琴浪${jiacu} 版魔改 BBR,安装并启用魔改 BBR ...${normal} " 365 | check_headers 366 | check_essential 367 | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) nanqinlang >> $OutputLOG 2>&1 368 | enable_bbr nanqinlang 369 | if [[ ` lsmod | grep nanqinlang ` ]]; then echo -e "\n ${bold}已开启 ${green}南琴浪${jiacu} 版魔改 BBR ...${normal}\n\n" 370 | else echo -e "\n ${bold}${red}错误 ${green}南琴浪 版魔改 BBR${jiacu} 开启失败!考虑换个内核?${normal}\n" ; exit_1 ; fi 371 | else 372 | ask_continue2 373 | # echo -e " ${bold}当前内核不支持 ${green}南琴浪${jiacu} 版魔改 BBR,先安装 ${green}4.11.12${jiacu} 内核 ...${normal} " 374 | # online_ubuntu_bbr_firmware 375 | check_essential 376 | bbr_kernel_4_19_102 377 | delete_other_kernel 378 | bbr_nanqinlang_autoinstall 379 | enable_bbr nanqinlang 380 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}南琴浪${jiacu} 版魔改 BBR ... ${normal}\n" && reboot 381 | fi 382 | } 383 | 384 | 385 | 386 | 387 | 388 | #S4# 安装 BBR Plus 389 | function bbr_plus_install() { 390 | if [[ $running_kernel == "4.14.129-bbrplus" ]]; then 391 | enable_bbr bbrplus 392 | if [[ ` lsmod | grep bbrplus ` ]]; then echo -e "\n ${bold}已开启 ${green}bbrplus${jiacu} ...${normal}\n" 393 | else echo -e "\n ${bold}${red}错误 ${green}bbrplus${jiacu} 开启失败!考虑装 4.14.129 内核试试?${normal}\n" ; exit_1 ; fi 394 | elif [[ $BBRPKernel == "${green}是${jiacu}" ]]; then 395 | echo -e "\n ${bold}或许当前内核已支持 ${green}bbrplus${jiacu},实际上能不能装上我也不知道 ...${normal} " 396 | check_headers 397 | check_essential 398 | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) bbrplus >> $OutputLOG 2>&1 399 | enable_bbr bbrplus 400 | if [[ ` lsmod | grep bbrplus ` ]]; then echo -e "\n ${bold}已开启 ${green}bbrplus${jiacu} ...${normal}\n" 401 | else echo -e "\n ${bold}${red}错误 ${green}bbrplus${jiacu} 开启失败!考虑装 4.14.129 内核试试?${normal}\n" ; exit_1 ; fi 402 | else 403 | ask_continue2 404 | # online_ubuntu_bbr_firmware 405 | check_essential 406 | kernel_version=4.14.129 407 | bbr_plus_kernel_4_14 408 | delete_other_kernel 409 | # bbr_plus_autoinstall # 其实那个内核里已经带了编译好的…… 410 | enable_bbr bbrplus 411 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}bbrplus ... ${normal}\n" && reboot 412 | fi 413 | } 414 | 415 | 416 | 417 | 418 | 419 | #S5# 安装 LotServer 420 | function ls_install() { 421 | if [[ $LSKernel == "${green}是${jiacu}" ]]; then 422 | echo -e "\n ${bold}理论上当前内核已支持 ${green}LotServer${jiacu},直接安装 ... ${normal} \n" 423 | lotserver_install 424 | elif [[ $LSKernel == "${red}否${jiacu}" ]]; then 425 | ask_continue2 426 | ss_kernel_install_v2 427 | delete_other_kernel 428 | delete_other_kernel 429 | lotserver_autoinstall 430 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}LotServer${jiacu} ... ${normal}\n" && reboot 431 | fi 432 | } 433 | 434 | 435 | 436 | 437 | 438 | #S6# 安装 ServerSpeeder 439 | function ss_install() { 440 | if [[ $SSKernel == "${green}是${jiacu}" ]]; then 441 | echo -e "\n ${bold}理论上当前内核已支持 ${green}锐速${jiacu},直接安装 ... ${normal} " 442 | serverspeeder_install 443 | elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == ubuntu ]] && [[ ! $CODENAME == bionic ]]; then 444 | ask_continue2 445 | echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}3.16.0-43${jiacu} 内核 ... ${normal} \n" 446 | export kernelver=3.16.0-43-generic 447 | ubuntu_serverspeeder_kernel_repo 448 | export kernel_version=3.16.0-43-generic 449 | delete_other_kernel 450 | delete_other_kernel 451 | serverspeeder_autoinstall 452 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot 453 | elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $CODENAME == bionic ]]; then 454 | ask_continue2 455 | echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}4.4.0-47${jiacu} 内核 ... ${normal} \n" 456 | kernel_version=4.4.0-47 457 | ubuntu_ss_kernel_4.4.0-47_apt 458 | delete_other_kernel 459 | delete_other_kernel # 可能上一次卸载的时候又给你强行安装一个 4.4.0 最新的内核,所以再删一次 460 | serverspeeder_autoinstall 461 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot 462 | elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == debian ]]; then 463 | ask_continue2 464 | echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}3.16.0-4${jiacu} 内核 ... ${normal} \n" 465 | kernel_version=3.16.0-4 466 | debian_ssr_kernel_3.16.0-4_apt 467 | delete_other_kernel 468 | delete_other_kernel # 可能上一次卸载的时候又给你强行安装一个 3.16.0 最新的内核(目前是 3.16.0-7),所以再删一次 469 | serverspeeder_autoinstall 470 | [[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot 471 | fi 472 | } 473 | 474 | 475 | 476 | 477 | 478 | # 卸载 锐速 479 | function ss_uninstall() { 480 | echo -ne "\n ${bold}${red}警告 ${jiacu}即将开始卸载 ${green}锐速${jiacu},敲 回车 继续,否则退出${normal} " ; read input 481 | case $input in 482 | "" ) echo ;; 483 | * ) echo ; read_response ;; 484 | esac 485 | [[ `grep "Advanced options for Ubuntu" /etc/default/grub` ]] && sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=""/' /etc/default/grub && update-grub >> $OutputLOG 2>&1 486 | wget --no-check-certificate -qO /tmp/appex.sh "https://github.com/Aniverse/ServerSpeeder/raw/master/install.sh" && echo | bash /tmp/appex.sh 'uninstall' 487 | echo -e " ${bold}${red}已卸载 锐速,但安装的内核仍保留${normal}\n" 488 | } 489 | 490 | 491 | 492 | 493 | 494 | # 卸载 BBR 495 | function bbr_uninstall() { 496 | echo -ne "\n ${bold}${red}警告 ${jiacu}即将开始卸载 ${green}BBR${jiacu},敲 回车 继续,否则退出${normal} " ; read input 497 | case $input in 498 | "" ) echo ;; 499 | * ) echo ; read_response ;; 500 | esac 501 | if [[ $tcp_control =~ (nanqinlang|tsunami|bbr|bbr_powered|bbrplus) ]]; then 502 | bbrname=$tcp_control ; disable_bbr ; echo -e " ${bold}${red}已卸载 BBR,但安装的内核仍保留${normal}\n" 503 | else 504 | echo -e " ${bold}${red}错误 ${jiacu}我看你好像没装 bbr 吧? ...${normal}\n" 505 | read_response 506 | fi 507 | } 508 | 509 | 510 | 511 | 512 | # 安装 指定内核(BBR) 513 | function selected_kernel_install() { 514 | get_version 515 | install_required 516 | echo 517 | } 518 | 519 | 520 | 521 | #S13# 安装 特定锐速内核(OLD) 522 | function ss_kernel_install() { 523 | if [[ $CODENAME =~ (xenial|bionic) ]]; then 524 | echo -e "\n ${bold}安装 ${green}4.4.0-47${jiacu} 内核 ...${normal} \n" 525 | kernel_version=4.4.0-47 526 | ubuntu_ss_kernel_4.4.0-47_apt 527 | elif [[ $CODENAME == jessie ]]; then 528 | echo -e "\n ${bold}安装 ${green}3.12-1${jiacu} 内核 ...${normal} \n" 529 | kernel_version=3.12-1 530 | debian_serverspeeder_kernel_3.12.1 531 | else 532 | echo -e "\n ${red}注意${jiacu} 本功能只支持 Debian 8 和 Ubuntu 16.04/18.04 !${normal}" 533 | fi 534 | echo 535 | } 536 | 537 | 538 | 539 | function ss_kernel_install_stretch_add_repo() { 540 | echo 'Acquire::Check-Valid-Until 0;' > /etc/apt/apt.conf.d/10-no-check-valid-until 541 | cat << EOF > /etc/apt/sources.list.d/stretch.old.list 542 | deb http://snapshot.debian.org/archive/debian/20171224T175424Z/ stretch main non-free contrib 543 | deb http://snapshot.debian.org/archive/debian-security/20171224T175424Z/ stretch/updates main non-free contrib 544 | deb-src http://snapshot.debian.org/archive/debian/20171224T175424Z/ stretch main non-free contrib 545 | deb-src http://snapshot.debian.org/archive/debian-security/20171224T175424Z/ stretch/updates main non-free contrib 546 | EOF 547 | } 548 | 549 | 550 | 551 | #S14# 安装 特定锐速内核(New) 552 | function ss_kernel_install_v2() { 553 | if [[ $CODENAME == bionic ]]; then 554 | echo -e "\n ${bold}安装 ${green}4.15.0-30${jiacu} 内核 ...${normal} \n" 555 | kernel_version=4.15.0-30-generic 556 | apt-get update >> $OutputLOG 2>&1 557 | apt-get -y install linux-image-$kernel_version linux-headers-$kernel_version linux-modules-$kernel_version linux-modules-extra-$kernel_version 558 | kernel_version=4.15.0-30 559 | dpkg -l | grep linux-image-$kernel_version -q || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 560 | elif [[ $CODENAME =~ (stretch|buster) ]]; then 561 | echo -e "\n ${bold}安装 ${green}4.9.0-4${jiacu} 内核 ...${normal} \n" 562 | kernel_version=4.9.0-4-amd64 563 | ss_kernel_install_stretch_add_repo 564 | apt-get update >> $OutputLOG 2>&1 565 | apt-get update --fix-missing >> $OutputLOG 2>&1 566 | apt-get -y install linux-image-$kernel_version linux-headers-$kernel_version >> $OutputLOG 2>&1 567 | kernel_version=4.9.0-4 568 | dpkg -l | grep linux-image-$kernel_version -q || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 569 | [[ $CODENAME == buster ]] && rm -f /etc/apt/sources.list.d/stretch.old.list && apt-get update >> $OutputLOG 2>&1 570 | else 571 | echo -e "\n ${red}注意${jiacu} 本功能只支持 Debian 9/10/Ubuntu 18.04 !${normal}" 572 | exit_1 573 | fi 574 | echo 575 | } 576 | 577 | 578 | 579 | #S16# 换 LotServer 内核脚本(MoeClub 版) 580 | # bash <( wget -qO- https://moeclub.org/attachment/LinuxShell/Debian_Kernel.sh ) 581 | function Debian_Kernel.sh() { 582 | deb_issue="$(cat /etc/issue)" 583 | deb_relese="$(echo $deb_issue |grep -io 'Ubuntu\|Debian' |sed -r 's/(.*)/\L\1/')" 584 | os_ver="$(dpkg --print-architecture)" 585 | [ -n "$os_ver" ] || exit 1 586 | 587 | if [ "$deb_relese" == 'ubuntu' ]; then 588 | deb_ver="$(echo $deb_issue |grep -o '[0-9]*\.[0-9]*' |head -n1)" 589 | if [ "$deb_ver" == "14.04" ]; then 590 | item="3.16.0-77-generic" && ver='trusty' 591 | elif [ "$deb_ver" == "16.04" ]; then 592 | item="4.8.0-36-generic" && ver='xenial' 593 | elif [ "$deb_ver" == "18.04" ]; then 594 | item="4.15.0-30-generic" && ver='bionic' 595 | else 596 | exit 1 597 | fi 598 | url='archive.ubuntu.com' 599 | urls='security.ubuntu.com' 600 | elif [ "$deb_relese" == 'debian' ]; then 601 | deb_ver="$(echo $deb_issue |grep -o '[0-9]*' |head -n1)" 602 | if [ "$deb_ver" == "7" ]; then 603 | item="3.2.0-4-${os_ver}" && ver='wheezy' && url='archive.debian.org' && urls='archive.debian.org' 604 | elif [ "$deb_ver" == "8" ]; then 605 | item="3.16.0-4-${os_ver}" && ver='jessie' && url='archive.debian.org' && urls='deb.debian.org' 606 | elif [ "$deb_ver" == "9" ]; then 607 | item="4.9.0-4-${os_ver}" && ver='stretch' && url='deb.debian.org' && urls='deb.debian.org' 608 | else 609 | exit 1 610 | fi 611 | else 612 | exit 1 613 | fi 614 | 615 | [ -n "$item" ] && [ -n "$urls" ] && [ -n "$url" ] && [ -n "$ver" ] || exit 1 616 | 617 | if [ "$deb_relese" == 'ubuntu' ]; then 618 | echo "deb http://${url}/${deb_relese} ${ver} main restricted universe multiverse" >/etc/apt/sources.list 619 | echo "deb http://${url}/${deb_relese} ${ver}-updates main restricted universe multiverse" >>/etc/apt/sources.list 620 | echo "deb http://${url}/${deb_relese} ${ver}-backports main restricted universe multiverse" >>/etc/apt/sources.list 621 | echo "deb http://${urls}/${deb_relese} ${ver}-security main restricted universe multiverse" >>/etc/apt/sources.list 622 | elif [ "$deb_relese" == 'debian' ]; then 623 | echo "deb http://${url}/${deb_relese} ${ver} main" >/etc/apt/sources.list 624 | echo "deb-src http://${url}/${deb_relese} ${ver} main" >>/etc/apt/sources.list 625 | echo "deb http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list 626 | echo "deb-src http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list 627 | fi 628 | 629 | apt-get update 630 | apt-get install --no-install-recommends -y linux-image-${item} linux-headers-${item} # 这里加个 headers 631 | 632 | if [ $? -ne 0 ]; then 633 | if [ "$deb_ver" == "8" ]; then 634 | dpkg -l |grep -q 'linux-base' || { 635 | 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' 636 | dpkg -i '/tmp/linux-base_3.5_all.deb' 637 | } 638 | 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' 639 | dpkg -i '/tmp/linux-image-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb' 640 | if [ $? -ne 0 ]; then 641 | exit 1 642 | fi 643 | elif [ "$deb_ver" == "9" ]; then 644 | dpkg -l |grep -q 'linux-base' || { 645 | 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' 646 | dpkg -i '/tmp/linux-base_4.5_all.deb' 647 | } 648 | 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' 649 | dpkg -i '/tmp/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb' 650 | if [ $? -ne 0 ]; then 651 | exit 1 652 | fi 653 | else 654 | exit 1 655 | fi 656 | else 657 | exit 1 658 | fi 659 | 660 | item_num=$(echo "$item" | grep -oE "[0-9]+.[0-9]+.[0-9]+-[0-9]+") 661 | while true; do 662 | List_Kernel="$(dpkg -l |grep 'linux-image\|linux-modules\|linux-generic\|linux-headers' |grep -v "$item_num")" 663 | Num_Kernel="$(echo "$List_Kernel" |sed '/^$/d' |wc -l)" 664 | [ "$Num_Kernel" -eq "0" ] && break 665 | for kernel in `echo "$List_Kernel" |awk '{print $2}'` 666 | do 667 | if [ -f "/var/lib/dpkg/info/${kernel}.prerm" ]; then 668 | sed -i 's/linux-check-removal/#linux-check-removal/' "/var/lib/dpkg/info/${kernel}.prerm" 669 | sed -i 's/uname -r/echo purge/' "/var/lib/dpkg/info/${kernel}.prerm" 670 | fi 671 | dpkg --force-depends --purge "$kernel" 672 | done 673 | done 674 | apt-get autoremove -y 675 | [ -d '/var/lib/apt/lists' ] && find /var/lib/apt/lists -type f -delete 676 | } 677 | 678 | 679 | 680 | # 安装 xanmod,apt 681 | function xanmod_apt_install_preparation() { 682 | echo 'deb http://deb.xanmod.org releases main' | tee /etc/apt/sources.list.d/xanmod-kernel.list 683 | wget -4 -qO - https://dl.xanmod.org/gpg.key | apt-key add - 684 | apt-get update 685 | apt-get install -y --allow-unauthenticated linux-firmware intel-microcode iucode-tool 686 | } 687 | 688 | 689 | 690 | function xanmod_dpkg_install() { 691 | wget https://github.com/Aniverse/XanMod-DL/raw/master/linux-headers-$kernel_version.deb 692 | wget https://github.com/Aniverse/XanMod-DL/raw/master/linux-image-$kernel_version.deb 693 | dpkg -i linux-image-$kernel_version.deb 694 | dpkg -i linux-headers-$kernel_version.deb 695 | rm -rf linux-image-$kernel_version.deb linux-headers-$kernel_version.deb 696 | } 697 | 698 | 699 | #S31# 安装 xanmod 700 | function xanmod_install() { 701 | echo ; read -ep " ${bold}输入你要安装的 Xanmod 版本: ${normal}" XanmodVer ; echo 702 | 703 | # online_ubuntu_bbr_firmware 704 | # https://sourceforge.net/projects/xanmod/files/releases/ 705 | # https://xanmod.org/ 706 | 707 | if [[ $XanmodVer == 4.9 ]]; then # 2018-03-25 708 | kernel_version=4.9.90-xanmod88 709 | xanmod_dpkg_install 710 | elif [[ $XanmodVer == 4.10 ]]; then # 2017-05-22 711 | kernel_version=4.10.17-xanmod19 712 | xanmod_dpkg_install 713 | elif [[ $XanmodVer == 4.11 ]]; then # 2017-07-21 714 | kernel_version=4.11.12-xanmod16 715 | xanmod_dpkg_install 716 | elif [[ $XanmodVer == 4.12 ]]; then # 2017-09-20 717 | kernel_version=4.12.14-xanmod15 718 | xanmod_dpkg_install 719 | elif [[ $XanmodVer == 4.13 ]]; then # 2017-11-24 720 | kernel_version=4.13.16-xanmod23 721 | xanmod_dpkg_install 722 | elif [[ $XanmodVer == 4.14 ]]; then # 2018-12-22 723 | kernel_version=4.14.90-xanmod54 724 | xanmod_dpkg_install 725 | elif [[ $XanmodVer == 4.15 ]]; then # 2018-03-25 726 | kernel_version=4.15.13-xanmod12 727 | xanmod_dpkg_install 728 | elif [[ $XanmodVer == 4.16 ]]; then # 2018-05-28 729 | kernel_version=4.16.12-xanmod11 730 | xanmod_dpkg_install 731 | elif [[ $XanmodVer == 4.17 ]]; then # 2018-08-10 732 | kernel_version=4.17.14-xanmod9 733 | xanmod_dpkg_install 734 | elif [[ $XanmodVer == 4.18 ]]; then # 2018-10-20 735 | kernel_version=4.18.16-xanmod9 736 | xanmod_dpkg_install 737 | elif [[ $XanmodVer == 4.19 ]]; then # 2018-12-24 738 | kernel_version=4.19.102-xanmod49 739 | xanmod_dpkg_install 740 | elif [[ $XanmodVer == 4.20 ]]; then # 2019-02-03 741 | kernel_version=4.20.12-xanmod7 742 | xanmod_dpkg_install 743 | elif [[ $XanmodVer == 5.0 ]]; then # 2019-05-05 744 | kernel_version=5.0.13-xanmod8 745 | xanmod_dpkg_install 746 | elif [[ $XanmodVer == 5.1 ]]; then # 2019-07-03 747 | kernel_version=5.1.16-xanmod10 748 | xanmod_dpkg_install 749 | elif [[ $XanmodVer == 5.2 ]]; then # 2019-09-16 750 | kernel_version=5.2.15-xanmod11 751 | xanmod_dpkg_install 752 | elif [[ $XanmodVer == 5.3 ]]; then # 2019-11-25 753 | kernel_version=5.3.13-xanmod9 754 | xanmod_dpkg_install 755 | elif [[ $XanmodVer == 5.3 ]]; then # 2019-11-25 756 | kernel_version=5.3.13-xanmod9 757 | xanmod_dpkg_install 758 | elif [[ $XanmodVer == 5.4 ]]; then # 2020-08-11 # Current LTS 759 | kernel_version=5.4.58-xanmod1 760 | xanmod_dpkg_install 761 | elif [[ $XanmodVer == 5.5 ]]; then # 2020-04-13 762 | kernel_version=5.4.58-xanmod1 763 | xanmod_dpkg_install 764 | elif [[ $XanmodVer == 5.6 ]]; then # 2020-06-17 765 | kernel_version=5.6.19-xanmod1 766 | xanmod_dpkg_install 767 | elif [[ $XanmodVer == 5.7 ]]; then # 2020-08-11 768 | kernel_version=5.7.15-xanmod1 769 | xanmod_dpkg_install 770 | elif [[ $XanmodVer == 5.8 ]]; then # Current Edge 771 | echo -e "Use edge" && exit 1 772 | elif [[ $XanmodVer == apt ]]; then # Current 5.7 773 | xanmod_apt_install_preparation 774 | kernel_version=5.7 775 | apt-get install -y --allow-unauthenticated linux-xanmod 776 | elif [[ $XanmodVer == lts ]]; then # Current 5.4 777 | xanmod_apt_install_preparation 778 | kernel_version=5.4 779 | apt-get install -y --allow-unauthenticated linux-xanmod-lts 780 | elif [[ $XanmodVer == edge ]]; then # Current 5.8 781 | xanmod_apt_install_preparation 782 | kernel_version=5.8 783 | apt-get install -y --allow-unauthenticated linux-xanmod-edge 784 | fi 785 | } 786 | 787 | 788 | 789 | 790 | 791 | #S33# 安装 liquorix 792 | # https://liquorix.net/#install 793 | function liquorix_install() { 794 | if [[ $DISTRO == ubuntu ]]; then 795 | [[ ! `command -v add-apt-repository` ]] && apt-get install -y software-properties-common 796 | add-apt-repository -y ppa:damentz/liquorix 797 | elif [[ $DISTRO == debian ]]; then 798 | [[ ! $(command -v curl) ]] && apt-get install -y curl 799 | [ $(dpkg-query -W -f='${Status}' apt-transport-https 2>/dev/null | grep -c "ok installed") -eq 0 ] && apt-get install -y apt-transport-https 800 | echo " 801 | deb http://liquorix.net/debian $CODENAME main 802 | deb-src http://liquorix.net/debian $CODENAME main 803 | # deb http://mirror.unit193.net/liquorix $CODENAME main 804 | # deb-src http://mirror.unit193.net/liquorix $CODENAME main 805 | # deb http://liquorix.net/debian sid main 806 | # deb-src http://liquorix.net/debian sid main" > /etc/apt/sources.list.d/liquorix.list 807 | curl https://liquorix.net/linux-liquorix.pub | apt-key add - 808 | fi 809 | apt-get update 810 | apt-get install -y --allow-unauthenticated linux-image-liquorix-amd64 linux-headers-liquorix-amd64 811 | } 812 | 813 | 814 | 815 | 816 | ################################################################################################################################################################### 817 | 818 | 819 | 820 | 821 | # 重启后自动安装 BBR Plus 822 | function bbr_plus_autoinstall() { 823 | mkdir -p /root/TrCtrlProToc0l 824 | cat > /root/TrCtrlProToc0l/TCP-auto-install.sh < /root/TrCtrlProToc0l/TCP-auto-install.sh < /root/TrCtrlProToc0l/TCP-auto-install.sh < /root/TrCtrlProToc0l/TCP-auto-install.sh < /root/TrCtrlProToc0l/TCP-auto-install.sh <> $OutputLOG 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 894 | rm -rf [12].deb ; echo 895 | } 896 | 897 | 898 | 899 | # Debian 安装 3.16.0-4 内核(For ServerSpeeder) 900 | function debian_ss_kernel_3.16.0-4() { 901 | wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/ServerSpeeder/linux-image-3.16.0-4.deb 902 | echo ` debconf-get-selections linux-image-3.16.0-4-amd64 | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 903 | { dpkg -i 1.deb >> $OutputLOG 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 904 | rm -rf 1.deb 905 | } 906 | 907 | 908 | 909 | # Debian 安装 3.16.0-4 内核(apt-get install)(For ServerSpeeder) 910 | function debian_ssr_kernel_3.16.0-4_apt() { 911 | if ! grep snapshot.debian.org /etc/apt/sources.list -q ; then 912 | cat >> /etc/apt/sources.list << EOF 913 | deb http://snapshot.debian.org/archive/debian/20180620T205325Z/ jessie main contrib non-free 914 | deb-src http://snapshot.debian.org/archive/debian/20180620T205325Z/ jessie main contrib non-free 915 | EOF 916 | fi 917 | echo 'Acquire::Check-Valid-Until 0;' > /etc/apt/apt.conf.d/10-no-check-valid-until 918 | echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 919 | apt-get update >> $OutputLOG 2>&1 920 | echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 921 | apt-get install -y linux-image-3.16.0-4-amd64 >> $OutputLOG 2>&1 922 | apt-get install -y linux-headers-3.16.0-4-common linux-headers-3.16.0-4-all >> $OutputLOG 2>&1 923 | apt-get install -y grep unzip ethtool >> $OutputLOG 2>&1 924 | [[ ! $( dpkg -l | grep linux-image-3.16.0-4-amd64 ) ]] && { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 925 | } 926 | 927 | 928 | 929 | # Ubuntu 安装 4.4.0-47 内核(For ServerSpeeder) 930 | function ubuntu_ss_kernel_4.4.0-47() { 931 | wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/ServerSpeeder/linux-image-4.4.0-47.deb 932 | wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/ServerSpeeder/linux-headers-4.4.0-47-all.deb 933 | wget --no-check-certificate -qO 3.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/ServerSpeeder/linux-headers-4.4.0-47.deb 934 | echo ` debconf-get-selections linux-image-4.4.0-47-generic | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 935 | echo ` debconf-get-selections linux-headers-4.4.0-47 | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 936 | echo ` debconf-get-selections linux-headers-4.4.0-47-generic | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 937 | apt-get install -y grep unzip ethtool >> $OutputLOG 2>&1 938 | { dpkg -i [123].deb >> $OutputLOG 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 939 | rm -rf [123].deb 940 | } 941 | 942 | 943 | 944 | # Ubuntu 安装 4.4.0-47 内核(apt-get install)(For ServerSpeeder) 945 | function ubuntu_ss_kernel_4.4.0-47_apt() { 946 | [[ $CODENAME == bionic ]] && [[ ! `grep "xenial" /etc/apt/sources.list` ]] && echo -e "\ndeb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse" >> /etc/apt/sources.list 947 | echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 948 | apt-get update >> $OutputLOG 2>&1 949 | echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 950 | apt-get install -y linux-image-4.4.0-47-generic linux-image-extra-4.4.0-47-generic linux-headers-4.4.0-47-generic >> $OutputLOG 2>&1 951 | apt-get install -y grep unzip ethtool >> $OutputLOG 2>&1 952 | [[ ! $( dpkg -l | grep linux-image-4.4.0-47-generic ) ]] && { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 953 | } 954 | 955 | 956 | 957 | # Ubuntu 安装 3.16.0-43 内核(For ServerSpeeder) 958 | function _ubuntu_serverspeeder_kernel_3.16.0-43() { 959 | apt-get -y install module-init-tools >> $OutputLOG 2>&1 960 | wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/SSKernel/raw/master/Ubuntu/linux-image-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb 961 | wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/SSKernel/raw/master/Ubuntu/image-extra/linux-image-extra-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb 962 | wget --no-check-certificate -qO 3.deb https://github.com/Aniverse/SSKernel/raw/master/Ubuntu/headers/linux-headers-3.16.0-43-generic_3.16.0-43.58~14.04.1_amd64.deb 963 | apt-get install -y grep unzip ethtool >> $OutputLOG 2>&1 964 | echo ` debconf-get-selections linux-image-3.16.0-43-generic | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 965 | echo ` debconf-get-selections linux-image-extra-3.16.0-43-generic | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 966 | echo ` debconf-get-selections linux-headers-3.16.0-43-generic | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections 967 | { dpkg -i 1.deb >> $OutputLOG 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } 968 | dpkg -i 2.deb >> $OutputLOG 2>&1 ; apt-get -f -y install >> $OutputLOG 2>&1 969 | dpkg -i 3.deb >> $OutputLOG 2>&1 ; apt-get -f -y install >> $OutputLOG 2>&1 970 | rm -rf [123].deb 971 | } 972 | 973 | 974 | 975 | # Ubuntu 从系统源安装锐速内核(For ServerSpeeder) 976 | function ubuntu_serverspeeder_kernel_repo() { 977 | sed -i '/deb http:\/\/security.ubuntu.com\/ubuntu trusty-security main/'d /etc/apt/sources.list 978 | [[ `grep "trusty-security" /etc/apt/sources.list` ]] && sleep 0 || echo -e "\ndeb http://security.ubuntu.com/ubuntu trusty-security main" >> /etc/apt/sources.list 979 | echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 980 | { apt-get update >> $OutputLOG 2>&1 ; } && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } 981 | echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 982 | apt-get install -y grep unzip ethtool >> $OutputLOG 2>&1 983 | apt-get -y install linux-image-extra-$kernelver linux-image-$kernelver linux-headers-$kernelver >> $OutputLOG 2>&1 && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } 984 | [[ ! ` dpkg -l | grep linux-image-$kernelver ` ]] && { echo "${bold}${red}失败${normal}" | tee -a $OutputLOG ; exit_1 ; } 985 | sed -i '/deb http:\/\/security.ubuntu.com\/ubuntu trusty-security main/'d /etc/apt/sources.list 986 | echo -ne "\n ${bold}删除源,更新 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 987 | { apt-get update >> $OutputLOG 2>&1 ; } && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } 988 | } 989 | 990 | 991 | 992 | # Ubuntu 不卸载新内核的情况下使用老内核启动(For ServerSpeeder) 993 | function ubuntu_serverspeeder_updategrub() { 994 | sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux kernelver"/' /etc/default/grub 995 | sed -i "s/kernelver/$kernelver/" /etc/default/grub 996 | update_grub 997 | } 998 | 999 | 1000 | 1001 | 1002 | # 内核匹配的情况下安装锐速 1003 | function serverspeeder_install() { 1004 | ifconfig > /dev/null 2>&1 1005 | [ $? -gt '1' ] && apt-get install -y net-tools 1006 | # wget --no-check-certificate -qO /tmp/appex.sh https://github.com/Aniverse/ServerSpeeder/raw/master/install.sh && echo | bash /tmp/appex.sh 'install' 1007 | echo | bash <(wget --no-check-certificate -qO- https://github.com/Aniverse/ServerSpeeder/raw/master/install.sh) install 1008 | ps aux | grep -v grep | grep -q appex && echo -e "\n${bold}${green}锐速已在运行 ...${normal}\n" || echo -e "\n${bold}${red}锐速尚未在运行,可能安装失败!${normal}\n" 1009 | } 1010 | 1011 | function lotserver_install() { 1012 | bash <(wget --no-check-certificate -qO- https://github.com/Aniverse/lotServer/raw/master/lotServer.sh) install 1013 | ps aux | grep -v grep | grep -q appex && echo -e "\n${bold}${green}锐速已在运行 ...${normal}\n" || echo -e "\n${bold}${red}锐速尚未在运行,可能安装失败!${normal}\n" 1014 | } 1015 | 1016 | 1017 | 1018 | 1019 | ################################################################################################################################################################### 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | # Online.net 独服补充固件(For BBR) 1027 | function online_ubuntu_bbr_firmware() { 1028 | mkdir -p /lib/firmware/bnx2 1029 | if [[ ! -f /lib/firmware/bnx2/fw.lock ]]; then 1030 | touch /lib/firmware/bnx2/fw.lock 1031 | echo -ne " ${bold}下载可能缺少的固件 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 1032 | wget -qO /lib/firmware/bnx2/bnx2-mips-06-6.2.3.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Firmware/bnx2/bnx2-mips-06-6.2.3.fw 1033 | wget -qO /lib/firmware/bnx2/bnx2-mips-09-6.2.1b.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Firmware/bnx2/bnx2-mips-09-6.2.1b.fw 1034 | wget -qO /lib/firmware/bnx2/bnx2-rv2p-09ax-6.0.17.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Firmware/bnx2/bnx2-rv2p-09ax-6.0.17.fw 1035 | wget -qO /lib/firmware/bnx2/bnx2-rv2p-09-6.0.17.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Firmware/bnx2/bnx2-rv2p-09-6.0.17.fw 1036 | wget -qO /lib/firmware/bnx2/bnx2-rv2p-06-6.0.15.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Firmware/bnx2/bnx2-rv2p-06-6.0.15.fw 1037 | echo | tee -a $OutputLOG 1038 | fi 1039 | } 1040 | 1041 | 1042 | 1043 | # 安装 4.11.12 的内核(For BBR) 1044 | function bbr_kernel_4_11_12() { 1045 | install_libssl_100 1046 | echo -ne "\n ${bold}安装 4.11.12 内核及其头文件 ... ${normal} " | tee -a $OutputLOG ; echo >> $OutputLOG 1047 | wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/BBR/linux-headers-4.11.12-all.deb 1048 | wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/BBR/linux-headers-4.11.12-amd64.deb 1049 | wget --no-check-certificate -qO 3.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux.Kernel/BBR/linux-image-4.11.12-generic-amd64.deb 1050 | dpkg -i [123].deb >> $OutputLOG 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; } 1051 | rm -rf [123].deb ; echo 1052 | update_grub 1053 | } 1054 | 1055 | 1056 | 1057 | # 安装 4.19.102 的内核 1058 | function bbr_kernel_4_19_102() { 1059 | echo -ne "\n ${bold}安装 4.19.102 内核及其头文件 ... ${normal} " | tee -a $OutputLOG ; echo >> $OutputLOG 1060 | kernel_version=4.19.102-xanmod49 1061 | wget --no-check-certificate https://github.com/Aniverse/XanMod-DL/raw/master/linux-headers-$kernel_version.deb >> $OutputLOG 2>&1 1062 | wget --no-check-certificate https://github.com/Aniverse/XanMod-DL/raw/master/linux-image-$kernel_version.deb >> $OutputLOG 2>&1 1063 | dpkg -i linux-{headers,image}-$kernel_version.deb >> $OutputLOG 2>&1 1064 | rm -rf linux-{headers,image}-$kernel_version.deb ; echo 1065 | update_grub 1066 | } 1067 | 1068 | 1069 | 1070 | # 安装 4.14-bbrplus 内核(For BBR Plus) 1071 | # https://github.com/chiakge/Linux-NetSpeed/blob/master/tcp.sh 1072 | function bbr_plus_kernel_4_14() { 1073 | echo -ne "\n ${bold}安装 4.14.129 内核及其头文件 ... ${normal} " | tee -a $OutputLOG ; echo >> $OutputLOG 1074 | wget --no-check-certificate -qNO linux-image-4.14.129.deb https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-image-4.14.129-bbrplus.deb 1075 | wget --no-check-certificate -qNO linux-headers-4.14.129.deb https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-headers-4.14.129-bbrplus.deb 1076 | dpkg -i linux-image-4.14.129.deb >> $OutputLOG 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; } 1077 | dpkg -i linux-headers-4.14.129.deb >> $OutputLOG 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; } 1078 | rm -rf linux-*-4.14.129.deb ; echo 1079 | update_grub 1080 | } 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | # 检查安装魔改版 BBR 所需的必要软件包 1087 | function check_essential() { 1088 | apt_install_needed=no 1089 | [[ ! `command -v make` ]] && apt_install_needed=yes 1090 | [[ ! `command -v awk` ]] && apt_install_needed=yes 1091 | [[ ! `command -v gcc` ]] && apt_install_needed=yes 1092 | [[ ! `dpkg -l | grep libelf-dev` ]] && apt_install_needed=yes 1093 | [[ ! `dpkg -l | grep build-essential` ]] && apt_install_needed=yes 1094 | 1095 | if [[ $apt_install_needed == yes ]]; then 1096 | APT_UPGRADE 1097 | fi 1098 | 1099 | [[ ! `dpkg -l | grep libelf-dev` ]] && { echo -ne "\n ${bold}安装 libelf-dev ...${normal} " | tee -a $OutputLOG ; apt-get install -y libelf1 libelf-dev >> $OutputLOG 2>&1 ; echo | tee -a $OutputLOG 1100 | [[ ! `dpkg -l | grep libelf-dev` ]] && { echo -e "\n ${red}错误${bold} 安装 libelf-dev 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1101 | 1102 | # which make >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -ne "\n ${bold}安装 make ...${normal} " | tee -a $OutputLOG ; apt-get install -y make >> $OutputLOG 2>&1 ; echo | tee -a $OutputLOG 1103 | # which make >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -e "\n ${red}错误${bold} 安装 make 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1104 | # which gcc >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -ne "\n ${bold}安装 gcc ...${normal} " | tee -a $OutputLOG ; apt-get install -y gcc >> $OutputLOG 2>&1 ; echo | tee -a $OutputLOG 1105 | # which gcc >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -e "\n ${red}错误${bold} 安装 gcc 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1106 | 1107 | which awk >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -ne "\n ${bold}安装 awk ...${normal} " | tee -a $OutputLOG ; apt-get install -y gawk >> $OutputLOG 2>&1 ; echo | tee -a $OutputLOG 1108 | which awk >> $OutputLOG 2>&1 ; [ $? -ne '0' ] && { echo -e "\n ${red}错误${bold} 安装 awk 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1109 | 1110 | dpkg -l | grep build-essential -q || { echo -ne "\n ${bold}安装 build-essential ...${normal} " | tee -a $OutputLOG ; apt-get install -y build-essential >> $OutputLOG 2>&1 ; echo | tee -a $OutputLOG 1111 | dpkg -l | grep build-essential -q || { echo -e "\n ${red}错误${bold} 安装 build-essential 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1112 | 1113 | gcc_ver=$(gcc --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -1) 1114 | version_ge $gcc_ver 4.9 || { echo -e "\n ${red}错误${bold} gcc 版本低于 4.9!${normal}" | tee -a $OutputLOG ; exit_1 ; } 1115 | } 1116 | 1117 | 1118 | 1119 | 1120 | # 开启 BBR 或其他拥塞控制算法 1121 | function enable_bbr() { 1122 | bbr=$1 ; [[ -z $bbr ]] && bbr=bbr 1123 | sed -i '/net.core.default_qdisc.*/d' /etc/sysctl.conf 1124 | sed -i '/net.ipv4.tcp_congestion_control.*/d' /etc/sysctl.conf 1125 | echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf 1126 | echo "net.ipv4.tcp_congestion_control = $bbr" >> /etc/sysctl.conf 1127 | modprobe tcp_$bbr >> $OutputLOG 2>&1 1128 | # sysctl -w net.ipv4.tcp_congestion_control=$bbr >> $OutputLOG 2>&1 1129 | sysctl -p >> $OutputLOG 2>&1 1130 | } 1131 | 1132 | 1133 | 1134 | # 关闭 BBR 1135 | function disable_bbr() { 1136 | sed -i '/net.core.default_qdisc.*/d' /etc/sysctl.conf 1137 | sed -i '/net.ipv4.tcp_congestion_control.*/d' /etc/sysctl.conf 1138 | echo "net.ipv4.tcp_congestion_control = cubic" >> /etc/sysctl.conf 1139 | # [[ $bbr != bbr ]] && rm /lib/modules/`uname -r`/kernel/net/ipv4/tcp_$bbrname.ko 1140 | sysctl -p >> $OutputLOG 2>&1 1141 | } 1142 | 1143 | 1144 | 1145 | # 切换到其他 TCP 加速 1146 | function switch_cc() { 1147 | read -ep "干啥子? " tcpcc 1148 | sed -i '/net.core.default_qdisc.*/d' /etc/sysctl.conf 1149 | sed -i '/net.ipv4.tcp_congestion_control.*/d' /etc/sysctl.conf 1150 | echo "net.ipv4.tcp_congestion_control = $tcpcc" >> /etc/sysctl.conf 1151 | [[ $tcpcc =~ (bbr|bbrplus|tsunami|nanqinlang|bbr_powered) ]] && echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf 1152 | modprobe tcp_$tcpcc 1153 | sysctl -w net.ipv4.tcp_congestion_control=$tcpcc 1154 | sysctl -p 1155 | } 1156 | 1157 | 1158 | 1159 | # 检查 headers 1160 | function check_headers() { 1161 | # required_version=$(uname -r | cut -d- -f1) 1162 | # [[ ` echo $required_version | grep -E "[2345].[0-9]+.0" ` ]] && required_version=$( uname -r | grep -Eo "[2345].[0-9]+" ) 1163 | current_kernel_v=$(uname -r | grep -oE "[2345].[0-9]+.[0-9]+|[2345].[0-9]+.[0-9]+-[0-9]+") 1164 | headers_exits=$(dpkg -l | grep linux-headers | grep $current_kernel_v | wc -l) 1165 | if [[ $headers_exits == 0 ]]; then 1166 | echo -e "\n ${red}警告${jiacu} 没有安装与内核对应的头文件,先尝试安装头文件 ...${normal} " | tee -a $OutputLOG 1167 | install_lost_headers 1168 | fi 1169 | } 1170 | 1171 | 1172 | 1173 | # 安装缺少的头文件 1174 | function install_lost_headers() { 1175 | apt-get update >> $OutputLOG 2>&1 1176 | if [[ -z $(apt-cache policy linux-headers-$current_kernel_v) ]]; then 1177 | echo -e "\n ${red}错误${jiacu} 镜像源列表里找不到所需的头文件,请自行解决!${normal} \n" | tee -a $OutputLOG 1178 | exit_1 1179 | fi 1180 | headers_pkg=linux-headers-$current_kernel_v 1181 | [[ $DISTRO == ubuntu ]] && headers_pkg=linux-headers-$current_kernel_v-generic 1182 | echo -ne "\n ${bold}安装${green} linux-headers-$current_kernel_v${jiacu} ... ${normal}" | tee -a $OutputLOG 1183 | echo >> $OutputLOG 1184 | apt-get install -y $headers_pkg >> $OutputLOG 2>&1 || { echo -e "\n ${red}错误${jiacu} headers 安装失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1185 | echo -e "${bold}${green}DONE${normal}" 1186 | } 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | # 询问版本(BBR) 1193 | function get_version() { 1194 | unset required_version 1195 | echo -e "\n ${red}注意${jiacu} 不推荐使用高版本内核,可能无法成功安装或者无法成功编译魔改版 BBR!${normal}" 1196 | while [[ -z "${required_version}" ]]; do 1197 | echo -ne "\n ${yellow}输入你想要的内核版本号 (敲回车则使用最新内核):${normal}" ; read -e required_version 1198 | [[ -z "${required_version}" ]] && required_version=` wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk -F'\"v' '/v[4-9]./{print $2}' | cut -d/ -f1 | grep -v - | sort -V | tail -1 ` 1199 | [[ -z ` wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/ ` ]] && { echo -e "\n ${red}错误${jiacu} 这个内核不存在或无法使用本脚本下载,请重新输入!${normal}" ; unset required_version ; } 1200 | done 1201 | echo -e "\n ${yellow}输入你想要的内核版本号 (敲回车则使用最新内核):$required_version ${normal}" >> $OutputLOG 1202 | } 1203 | 1204 | 1205 | 1206 | # 确定安装内核? 1207 | function install_required() { 1208 | 1209 | digit_ver_image=`dpkg -l | grep linux-image | awk '{print $2}' | awk -F '-' '{print $3}' | grep "${required_version}"` 1210 | digit_ver_headers=`dpkg -l | grep linux-headers | awk '{print $2}' | awk -F '-' '{print $3}' | grep "${required_version}"` 1211 | digit_ver_modules=`dpkg -l | grep linux-modules | awk '{print $2}' | awk -F '-' '{print $3}' | grep "${required_version}"` 1212 | [[ $DeBUG == 1 ]] && echo "${required_version}" 1213 | 1214 | if [[ -z $digit_ver_modules ]]; then 1215 | install_required_modules 1216 | else 1217 | echo -e "\n ${bold}${green}$required_version${jiacu} 模组已安装 ...${normal}" | tee -a $OutputLOG 1218 | fi 1219 | 1220 | if [[ -z $digit_ver_image ]]; then 1221 | install_required_kernel 1222 | else 1223 | echo -e "\n ${bold}${green}$required_version${jiacu} 内核已安装 ...${normal}" | tee -a $OutputLOG 1224 | fi 1225 | 1226 | if [[ -z $digit_ver_headers ]]; then 1227 | install_required_headers 1228 | else 1229 | echo -e "\n ${bold}${green}$required_version${jiacu} 头文件已安装 ...${normal}" | tee -a $OutputLOG 1230 | fi 1231 | 1232 | echo 1233 | } 1234 | 1235 | 1236 | 1237 | # 安装自选版本的内核 1238 | function install_required_kernel() { 1239 | [[ $DeBUG == 1 ]] && echo "${required_version}" 1240 | image_name=` wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/ | grep linux-image | grep generic | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1 ` 1241 | image_url="http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/${image_name}" 1242 | 1243 | echo -ne "\n ${bold}安装 ${green}$required_version${jiacu} 内核 ... ${normal}" | tee -a $OutputLOG 1244 | echo >> $OutputLOG 1245 | wget -qO kernel.deb $image_url || { echo -e "\n ${red}错误${jiacu} 内核 下载失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1246 | dpkg -i kernel.deb >> $OutputLOG 2>&1 || { echo -e "\n ${red}错误${jiacu} 内核 安装失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1247 | echo -e "${bold}${green}DONE${normal}" 1248 | 1249 | rm -f kernel.deb 1250 | } 1251 | 1252 | 1253 | 1254 | # 安装自选版本的头文件 1255 | function install_required_headers() { 1256 | headers_all_name=` wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/ | grep "linux-headers" | grep "all" | awk -F'\">' '/all.deb/{print $2}' | cut -d'<' -f1 | head -1 ` 1257 | headers_all_url="http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/${headers_all_name}" 1258 | headers_bit_name=` wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/ | grep "linux-headers" | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1 ` 1259 | headers_bit_url="http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/${headers_bit_name}" 1260 | 1261 | echo -ne "\n ${bold}安装 ${green}$required_version${jiacu} headers_all ... ${normal}" | tee -a $OutputLOG 1262 | echo >> $OutputLOG 1263 | wget -qO headers1.deb $headers_all_url || { echo -e "\n ${red}错误${jiacu} headers_all 下载失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1264 | dpkg -i headers1.deb >> $OutputLOG 2>&1 || { echo -e "\n ${red}错误${jiacu} headers_all 安装失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1265 | echo -e "${bold}${green}DONE${normal}" 1266 | 1267 | echo -ne "\n ${bold}安装 ${green}$required_version${jiacu} headers ... ${normal}" | tee -a $OutputLOG 1268 | echo >> $OutputLOG 1269 | wget -qO headers2.deb $headers_bit_url || { echo -e "\n ${red}错误${jiacu} headers 下载失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1270 | dpkg -i headers2.deb >> $OutputLOG 2>&1 || { echo -e "\n ${red}错误${jiacu} headers_all 安装失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1271 | echo -e "${bold}${green}DONE${normal}" 1272 | 1273 | rm -f headers1.deb headers2.deb 1274 | } 1275 | 1276 | 1277 | 1278 | # 安装自选版本的模组(?) 1279 | function install_required_modules() { 1280 | modules_name=`wget -qO- http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/ | grep linux-modules | awk -F'\">' '/amd64.deb/{print $2}' | cut -d'<' -f1 | head -1` 1281 | if [[ $modules_name ]]; then 1282 | modules_url="http://kernel.ubuntu.com/~kernel-ppa/mainline/v${required_version}/${modules_name}" 1283 | 1284 | echo -ne "\n ${bold}安装 ${green}$required_version${jiacu} 模组 ... ${normal}" | tee -a $OutputLOG 1285 | echo >> $OutputLOG 1286 | wget -qO modules.deb $modules_url || { echo -e "\n ${red}错误${jiacu} 模组 下载失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1287 | dpkg -i modules.deb >> $OutputLOG 2>&1 || { echo -e "\n ${red}错误${jiacu} 模组 安装失败!${normal}\n" | tee -a $OutputLOG ; exit_1 ; } 1288 | echo -e "${bold}${green}DONE${normal}" 1289 | 1290 | rm -f modules.deb 1291 | fi 1292 | } 1293 | 1294 | 1295 | 1296 | ################################################################################################################################################################### 1297 | 1298 | function install_libssl_100() { 1299 | [[ $apt_install_needed == yes ]] && { 1300 | echo -ne "\n ${bold}需要安装相关依赖以安装内核,先更新系统源 ...${normal} " | tee -a $OutputLOG 1301 | echo >> $OutputLOG 1302 | apt-get update >> $OutputLOG 2>&1 1303 | echo | tee -a $OutputLOG 1304 | echo -ne "\n ${bold}修复可能存在的依赖问题 ...${normal} " | tee -a $OutputLOG 1305 | echo >> $OutputLOG 1306 | apt-get install -f -y >> $OutputLOG 2>&1 1307 | echo | tee -a $OutputLOG 1308 | [[ $CODENAME == buster ]] && apt-get install -y multiarch-support >> $OutputLOG 2>&1 ; } 1309 | 1310 | if [[ $CODENAME =~ (stretch|buster) ]]; then 1311 | [[ ! `dpkg -l | grep libssl1.0.0` ]] && { 1312 | echo -ne "\n ${bold}安装 libssl1.0.0 ...${normal} " | tee -a $OutputLOG 1313 | echo >> $OutputLOG 1314 | wget --no-check-certificate https://sourceforge.net/projects/aboxx/files/deb/libssl1.0.0_1.0.1t-1%2Bdeb8u7_amd64.deb/download -O libssl1.0.deb >> $OutputLOG 2>&1 1315 | dpkg -i libssl1.0.deb >> $OutputLOG 2>&1 1316 | rm -f libssl1.0.deb ; echo 1317 | [[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -e "\n ${red}错误${bold} 安装 libssl1.0.0 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1318 | else 1319 | [[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -ne "\n ${bold}安装 libssl1.0.0 ...${normal} " | tee -a $OutputLOG ; echo >> $OutputLOG ; apt-get install -y libssl1.0.0 >> $OutputLOG 2>&1 ; echo 1320 | [[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -e "\n$ ${red}错误${bold} 安装 libssl1.0.0 失败!${normal}" | tee -a $OutputLOG ; exit_1 ; } ; } 1321 | fi 1322 | } 1323 | 1324 | 1325 | # 禁用启动选项 1326 | function _disable_advanced_boot() { sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=""/' /etc/default/grub ; } 1327 | 1328 | # 更新引导 1329 | function update_grub() { 1330 | echo -ne "\n ${bold}更新引导 ... ${normal}" | tee -a $OutputLOG ; echo >> $OutputLOG 1331 | { update-grub >> $OutputLOG 2>&1 ; } && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } 1332 | } 1333 | 1334 | # 删除指定内核 1335 | function delete_kernel() { 1336 | echo -e "\n ${bold}卸载指定内核及其头文件 ... ${normal}\n" | tee -a $OutputLOG 1337 | 1338 | dpkg -l | grep linux-image | grep "${kernel_version}" | awk '{print $2}' > /log/kernel_tobe_del_list 1339 | dpkg -l | grep ovhkernel | grep "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1340 | dpkg -l | grep pve-kernel | grep "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1341 | dpkg -l | grep linux-headers | grep "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1342 | dpkg -l | grep linux-modules | grep "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1343 | dpkg -l | grep generic-hwe | grep "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1344 | 1345 | kernel_total_num=` cat /log/kernel_tobe_del_list | wc -l ` 1346 | 1347 | if [ $kernel_total_num -gt 1 ]; then 1348 | for (( integer = 1 ; integer <= ${kernel_total_num} ; integer++ )) ; do 1349 | # kernel_tobe_del=` dpkg -l | grep -E linux-[image,headers,modules] | grep -v binutils | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer} ` 1350 | kernel_tobe_del=` cat /log/kernel_tobe_del_list | sed -n "${integer}p" ` 1351 | echo -ne " 卸载 ${kernel_tobe_del} ... " | tee -a $OutputLOG ; echo >> $OutputLOG 1352 | echo `debconf-get-selections ${deb_del} | grep removing-running-kernel | grep $running_kernel | sed s/true/false/` | debconf-set-selections 1353 | [[ $DeBUG == 1 ]] && { echo -e "\n $integer, $kernel_tobe_del" ; } 1354 | apt-get -y purge $kernel_tobe_del >> $OutputLOG 2>&1 && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } || { echo "${red}${bold}失败${normal}" | tee -a $OutputLOG ; } 1355 | done 1356 | fi 1357 | 1358 | rm -f /log/kernel_tobe_del_list 1359 | update_grub 1360 | } 1361 | 1362 | 1363 | 1364 | #S23# 仅保留指定内核,删除其他内核 1365 | function delete_other_kernel() { 1366 | echo -e "\n ${bold}卸载其他内核及其头文件 ... ${normal}\n" | tee -a $OutputLOG 1367 | dpkg -l | grep linux-image | grep -v "${kernel_version}" | awk '{print $2}' > /log/kernel_tobe_del_list 1368 | dpkg -l | grep ovhkernel | grep -v "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1369 | dpkg -l | grep pve-kernel | grep -v "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1370 | dpkg -l | grep linux-headers | grep -v "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1371 | dpkg -l | grep linux-modules | grep -v "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1372 | dpkg -l | grep generic-hwe | grep -v "${kernel_version}" | awk '{print $2}' >> /log/kernel_tobe_del_list 1373 | 1374 | [[ $DeBUG == 1 ]] && cat /log/kernel_tobe_del_list 1375 | kernel_total_num=` cat /log/kernel_tobe_del_list | wc -l ` 1376 | 1377 | if [[ $kernel_total_num -ge 1 ]]; then 1378 | for (( integer = 1 ; integer <= ${kernel_total_num} ; integer++ )) ; do 1379 | # kernel_tobe_del=` dpkg -l | grep -E linux-[image,headers,modules] | grep -v binutils | awk '{print $2}' | grep -v "${kernel_version}" | head -${integer} ` 1380 | kernel_tobe_del=` cat /log/kernel_tobe_del_list | sed -n "${integer}p" ` 1381 | echo -ne " 卸载 ${kernel_tobe_del} ... " | tee -a $OutputLOG ; echo >> $OutputLOG 1382 | echo `debconf-get-selections ${deb_del} | grep removing-running-kernel | grep $running_kernel | sed s/true/false/` | debconf-set-selections 1383 | [[ $DeBUG == 1 ]] && { echo -e "\n $integer, $kernel_tobe_del" ; } 1384 | apt-get -y purge $kernel_tobe_del >> $OutputLOG 2>&1 && { echo "${green}${bold}完成${normal}" | tee -a $OutputLOG ; } || { echo "${red}${bold}失败${normal}" | tee -a $OutputLOG ; } 1385 | done 1386 | fi 1387 | 1388 | rm -f /log/kernel_tobe_del_list 1389 | update_grub 1390 | } 1391 | 1392 | 1393 | 1394 | ####################################################################################################################### 1395 | 1396 | 1397 | function status_done() { 1398 | echo -e " ${green}${bold}DONE${normal}" | tee -a "$OutputLOG" 1399 | } 1400 | function echo_task() { 1401 | printf "%s" "$@" | tee -a "$OutputLOG" # echo -ne "$1" | tee -a "$OutputLOG" 1402 | echo >> "$OutputLOG" 1403 | } 1404 | 1405 | # From QuickBox Lite 1406 | function APT_UPGRADE() { 1407 | rm -f /tmp/apt_status 1408 | echo -e "\n ${bold}更新系统镜像源列表 ... ${normal}" 1409 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update >> $OutputLOG 2>&1 1410 | if [[ "$?" != 0 ]]; then 1411 | echo "apt_update_failed=1" > /tmp/apt_status 1412 | echo_error "Something wrong with your apt sources or network connection, exiting ..." 1413 | kill -s TERM $TOP_PID >> /dev/null 2>&1 ; kill -s TERM $script_pid >> /dev/null 2>&1 ; exit 1 1414 | fi 1415 | # if git is not found on apt source list, then we assume this source list is incorrect 1416 | apt policy git 2>&1 | grep -q http || { 1417 | echo "apt_update_failed=1" > /tmp/apt_status 1418 | echo_error "Something wrong with your apt sources or network connection, exiting ..." 1419 | kill -s TERM $TOP_PID >> /dev/null 2>&1 ; kill -s TERM $script_pid >> /dev/null 2>&1 ; exit 1 1420 | } 1421 | echo -e "\n ${bold}升级软件包 ... ${normal}" 1422 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade >> $OutputLOG 2>&1 1423 | ## auto solve lock 1424 | if [ "$?" -eq 2 ]; then 1425 | echo_error "dpkg database is locked" 1426 | echo_task "Try to fix dpkg lock ... " 1427 | rm -f /var/lib/dpkg/updates/0* 1428 | locks=$(find /var/lib/dpkg/lock* && find /var/cache/apt/archives/lock*) 1429 | if [[ ${locks} == $(find /var/lib/dpkg/lock* && find /var/cache/apt/archives/lock*) ]]; then 1430 | for l in ${locks}; do 1431 | rm -rf ${l} 1432 | done 1433 | _execute "dpkg --configure -a" 1434 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" update >> $OutputLOG 2>&1 1435 | DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade >> $OutputLOG 2>&1 1436 | fi 1437 | if ! (apt-get check >/dev/null); then 1438 | apt-get install -f >> $OutputLOG 2>&1 1439 | if ! (apt-get check >/dev/null); then 1440 | echo "apt_install_failed=1" > /tmp/apt_status 1441 | echo_error "It seems there is something error when using apt-get, exiting ..." 1442 | kill -s TERM $TOP_PID >> /dev/null 2>&1 ; kill -s TERM $script_pid >> /dev/null 2>&1 ; exit 1 1443 | fi 1444 | fi 1445 | status_done 1446 | else 1447 | status_done 1448 | touch /tmp/apt.update.$(date "+%Y%m%d") 1449 | fi 1450 | } 1451 | 1452 | 1453 | # 启用 /etc/rc.local 1454 | function enable_rclocal() { 1455 | if [[ ! -f /etc/rc.local ]]; then 1456 | cat << EOF >/etc/rc.local 1457 | #!/bin/sh -e 1458 | # 1459 | # rc.local 1460 | # 1461 | # This script is executed at the end of each multiuser runlevel. 1462 | # Make sure that the script will "exit 0" on success or any other 1463 | # value on error. 1464 | # 1465 | # In order to enable or disable this script just change the execution 1466 | # bits. 1467 | # 1468 | # By default this script does nothing. 1469 | 1470 | exit 0 1471 | EOF 1472 | fi 1473 | chmod +x /etc/rc.local 1474 | systemctl start rc-local 1475 | } 1476 | 1477 | 1478 | # 启用自动安装(systemd) 1479 | function auto_install_via_systemd() { 1480 | cat << EOF > /etc/systemd/system/tcpauto.service 1481 | [Unit] 1482 | Description=Setup 1483 | After=network.target 1484 | 1485 | [Service] 1486 | Type=oneshot 1487 | ExecStart=/root/TrCtrlProToc0l/TCP-auto-install.sh 1488 | RemainAfterExit=true 1489 | 1490 | [Install] 1491 | WantedBy=multi-user.target 1492 | EOF 1493 | cat << EOF >> /root/TrCtrlProToc0l/TCP-auto-install.sh 1494 | systemctl disable tcpauto.service 1495 | rm -rf /etc/systemd/system/tcpauto.service /etc/TrCtrlProToc0l 1496 | sleep 1 1497 | EOF 1498 | chmod +x /root/TrCtrlProToc0l/TCP-auto-install.sh 1499 | systemctl daemon-reload 1500 | systemctl enable tcpauto.service >> $OutputLOG 2>&1 1501 | # debug 1502 | printf "%-100s\n" "-" | sed 's/\s/-/g' >> $OutputLOG 1503 | echo -e "\nls -lA /root/TrCtrlProToc0l\n" >> $OutputLOG 1504 | printf "%-100s\n" "-" | sed 's/\s/-/g' >> $OutputLOG 1505 | ls -lA /root/TrCtrlProToc0l >> $OutputLOG 2>&1 1506 | printf "%-100s\n" "-" | sed 's/\s/-/g' >> $OutputLOG 1507 | echo -e "\ncat /root/TrCtrlProToc0l/TCP-auto-install.sh\n" >> $OutputLOG 1508 | printf "%-100s\n" "-" | sed 's/\s/-/g' >> $OutputLOG 1509 | cat /root/TrCtrlProToc0l/TCP-auto-install.sh >> $OutputLOG 2>&1 1510 | printf "%-100s\n" "-" | sed 's/\s/-/g' >> $OutputLOG 1511 | } 1512 | 1513 | # 询问是否继续(重启版) 1514 | function ask_continue2() { echo -ne "\n ${bold}输入 ${bailvse}回车${jiacu} 继续,完成后会直接重启;按 ${baihongse}Ctrl+C${jiacu} 退出${normal} " ; read response ; echo ; } 1515 | 1516 | 1517 | ####################################################################################################################### 1518 | 1519 | 1520 | function builtin() { 1521 | if [[ ! -x /usr/local/bin/tcpcc ]]; then 1522 | wget -q https://github.com/Aniverse/TrCtrlProToc0l/raw/master/A -O /usr/local/bin/tcpcc && 1523 | chmod 755 /usr/local/bin/tcpcc 1524 | fi 1525 | } 1526 | 1527 | 1528 | ####################################################################################################################### 1529 | 1530 | cp -f /etc/default/grub "/etc/default/grub.bak.$(date "+%Y.%m.%d.%H.%M.%S")" 1531 | builtin 1532 | script_menu 1533 | read_response 1534 | cancel 1535 | -------------------------------------------------------------------------------- /Images/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/01.png -------------------------------------------------------------------------------- /Images/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/02.png -------------------------------------------------------------------------------- /Images/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/03.png -------------------------------------------------------------------------------- /Images/04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/04.png -------------------------------------------------------------------------------- /Images/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/05.png -------------------------------------------------------------------------------- /Images/Error01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/Error01.png -------------------------------------------------------------------------------- /Images/Error02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/Error02.png -------------------------------------------------------------------------------- /Images/OLD.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/612a34dd7ccdb7e26c488d29e7bd0c0a9c4261d2/Images/OLD.01.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TrCtrlProToc0l (AccTCP) 2 | > WARNING: This script may cause system reboot failure 3 | 4 | ![01](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/01.png) 5 | 6 | ## Usage 7 | 8 | ```shell 9 | bash <(curl -Ls https://git.io/AccTCP) 10 | ``` 11 | 12 | or 13 | 14 | ```shell 15 | wget --no-check-certificate -q https://github.com/Aniverse/TrCtrlProToc0l/raw/master/A 16 | bash A 17 | ``` 18 | 19 | 20 | 21 | ## Feature 22 | 23 | - **尽可能地减少交互,尽可能地傻瓜化** 24 | 25 | 本脚本把重启后要执行的操作(安装锐速、编译魔改 bbr)放到一个临时的脚本中,并用 systemd 实现开机自动执行脚本,实现了当前运行内核无法直接安装锐速/bbr 的情况下更换内核重启后自动安装 锐速 / 魔改BBR,无需再次运行脚本 26 | 27 | 此外,移除当前正在使用的内核时会碰到 `abort removing running kernel` 的 对话框,以及 Digital Ocean VPS 安装新内核时可能会出现 `what would you like to do about menu.list` 的对话框,本脚本使用了 `debconf-set-selections` 来避免这个交互 28 | 29 | 更进一步的无交互体验(比如说你连选项都不想输入的话)也可以做到,比如: 30 | 31 | ``` 32 | echo 5 | bash <(curl -Ls https://git.io/AccTCP) 33 | ``` 34 | 35 | 这个命令就是直接执行脚本的选项 5,也就是安装 LotServer,复制粘贴后不会有任何需要额外操作的地方,(换内核→删除其他内核→重启→重启后自动装锐速)这四个操作脚本会自动完成 36 | 37 | - **一键安装,一键切换** 38 | 39 | 本脚本可以安装、卸载 锐速(ServerSpeeder 和 LotServer)、原版 bbr、Yankee 版魔改 bbr、南琴浪版魔改 bbr、bbrplus,并支持在以上任意的加速方案中一键切换 40 | 41 | - **最新的内核适配** 42 | 43 | 针对 4.13-4.20、5.0-5.5 等更高版本的内核适配了两种魔改版 bbr(原先的魔改 bbr 在高于 4.12 的内核上就不能用了) 44 | 45 | ## Drawbacks 46 | 47 | - **不支持 CentOS** 48 | 49 | 本脚本作为 `inexistence` 中 `mingling` 的延伸,我认没打算去适配原本 `inexistence` 就不支持的系统 50 | 本来这类脚本也有很多,如有需要你可以去用那些适配范围更广的脚本 51 | 52 | 非 LTS 的 Ubuntu 系统(比如 Ubuntu 19.10)和比较老旧的系统(比如 Debian 7 和 Ubuntu 14.04)也不受支持 53 | 54 | ## Known Issues 55 | 56 | - **某些情况下编译魔改 bbr 会失败** 57 | 如果碰到编译失败的情况,请先安装 4.11.12 内核并使用这个内核启动(可以把其他内核先删掉),再编译魔改 bbr 58 | 59 | - **某些情况下重启后 锐速 或 BBR 没有安装成功** 60 | 自从换了 systemd 后这个情况很少见了。如果没成功的话只能手动再来一次了…… 61 | 62 | - **Debian 9 无法安装普通的 4.16 及以上内核** 63 | 因为依赖的原因装不上,暂时没有解决办法,不过一些第三方内核可以安装 64 | 65 | - **有时候提示卸载内核失败但其实是成功的** 66 | 因为卸载其他内核的时候就把那个内核给卸载了,所以等轮到卸载它的时候没东西可以卸载就提示失败 67 | 68 | ![Error01](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/Error01.png) 69 | ![Error02](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/Error02.png) 70 | 71 | ## More screenshots (OLD version) 72 | 73 | ![02](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/02.png) 74 | ![03](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/03.png) 75 | ![04](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/04.png) 76 | ![05](https://github.com/Aniverse/TrCtrlProToc0l/raw/master/Images/05.png) 77 | 78 | ## Some references 79 | 80 | https://github.com/FunctionClub/YankeeBBR 81 | https://sometimesnaive.org/article/linux/bash/tcp_nanqinlang 82 | https://moeclub.org/2017/06/06/249/ 83 | https://moeclub.org/2017/03/08/14/ 84 | https://www.94ish.me/1635.html 85 | http://xiaofd.win/onekey-ruisu.html 86 | https://teddysun.com/489.html 87 | -------------------------------------------------------------------------------- /compile_tcp_cc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # https://github.com/Aniverse/TrCtrlProToc0l 4 | # Author: Aniverse 5 | # 6 | # Thanks to https://github.com/KozakaiAya/TCP_BBR 7 | 8 | script_update=2020.08.17 9 | script_version=r11010 10 | ######################################################################################################## 11 | 12 | usage_guide() { 13 | apt-get install -y libelf-dev build-essential 14 | bash <(curl -s https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) tsunami nanqinlang bbrplus 15 | } 16 | ######################################################################################################## 17 | 18 | 19 | tcp_cc=$1 20 | #[[ -n $Outputs ]] && OutputLOG=">> $OutputLOG 2>&1" 21 | [[ ! $tcp_cc =~ (tsunami|nanqinlang|bbrplus|tsunamio) ]] && echo -e "不支持!" && exit 1 22 | function version_ge(){ test "$(echo "$@" | tr " " "\n" | sort -rV | head -1)" == "$1" ; } 23 | filename=tcp_$tcp_cc.c 24 | kernel_v=$(uname -r | cut -d- -f1) 25 | kernel_v2=$(uname -r | cut -d- -f1 | cut -d. -f1-2) 26 | 27 | version_ge $kernel_v 4.9.3 && [[ $tcp_cc == nanqinlang ]] && supported_list="4.9 4.10 4.11 4.12 4.13 4.14 4.15 4.16 4.17 4.18 4.19 4.20 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8" 28 | version_ge $kernel_v 4.9.3 && [[ $tcp_cc == tsunami ]] && supported_list="4.9 4.10 4.11 4.12 4.13 4.14 4.15 4.16 4.17 4.18 4.19 4.20 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8" 29 | version_ge $kernel_v 4.14 && [[ $tcp_cc == bbrplus ]] && supported_list="4.14 4.15 4.16 4.17 4.18 4.19 4.20 5.0" 30 | version_ge $kernel_v 5.4 && [[ $tcp_cc == tsunamio ]] && supported_list="5.4" 31 | 32 | mkdir -p compile_tcp_cc 33 | cd compile_tcp_cc 34 | 35 | for supported_kernel in $supported_list ; do 36 | if [[ $kernel_v2 == $supported_kernel ]]; then 37 | if [[ $kernel_v2 =~ (4.9|4.10|4.11|4.12) ]]; then 38 | supported_kernel="4.12_and_below" 39 | elif [[ $kernel_v2 == 5.8 ]]; then 40 | supported_kernel="5.8-rc" 41 | fi 42 | wget https://raw.githubusercontent.com/KozakaiAya/TCP_BBR/master/code/v${supported_kernel}/$filename -O $filename --no-check-certificate 43 | fi 44 | done 45 | 46 | [[ ! -f $filename ]] && echo -e "下载源码失败!" && exit 1 47 | 48 | ######################################################################################################################## 49 | # [[ $gcc_ver == 7.3 ]] && [[ $kernel_v2 == 4.15 ]] && echo "ccflags-y=-I/usr/lib/gcc/x86_64-linux-gnu/7/include" >> Makefile 50 | 51 | gcc_version=$(gcc --version | grep ^gcc | sed 's/^.* //g') 52 | include_path="ccflags-y=-I/usr/lib/gcc/x86_64-linux-gnu/$gcc_version/include" 53 | 54 | echo "obj-m:=tcp_$tcp_cc.o" > Makefile 55 | echo "$include_path" >> Makefile 56 | mkdir -p /lib/modules/$(uname -r)/build 57 | make -C /lib/modules/$(uname -r)/build M=$(pwd) modules CC=$(which gcc) 58 | 59 | if [ ! -f ./tcp_$tcp_cc.ko ]; then 60 | echo "编译 $tcp_cc 失败" 61 | fi 62 | 63 | cp -f tcp_$tcp_cc.ko /lib/modules/$(uname -r)/kernel/net/ipv4 64 | insmod /lib/modules/$(uname -r)/kernel/net/ipv4/tcp_$tcp_cc.ko 65 | modprobe tcp_$tcp_cc 66 | 67 | if [ ! $? -eq 0 ]; then 68 | echo "载入 $tcp_cc 失败" 69 | fi 70 | 71 | depmod -a 72 | 73 | # cp -f tcp_$tcp_cc.ko /lib/modules/$(uname -r)/kernel/drivers/ 74 | # echo "tcp_$tcp_cc" | tee -a /etc/modules 75 | # depmod 76 | # modprobe tcp_$tcp_cc 77 | 78 | cd .. 79 | rm -rf compile_tcp_cc 80 | echo 81 | --------------------------------------------------------------------------------