forked from Aniverse/TrCtrlProToc0l
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA
1387 lines (1079 loc) · 68.5 KB
/
A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
# Author: Aniverse
# https://github.com/Aniverse/TrCtrlProToc0l
#
#################################################################################
#
# Thanks to
# https://github.com/FunctionClub/YankeeBBR
# https://sometimesnaive.org/article/linux/bash/tcp_nanqinlang
# https://moeclub.org/2017/06/06/249/
# https://moeclub.org/2017/03/09/14/
# https://www.94ish.me/1635.html
# http://xiaofd.win/onekey-ruisu.html
# https://teddysun.com/489.html
#
#################################################################################
ScriptVersion=3.0.6
ScriptDate=2019.07.16
usage_guide() {
bash <(wget -qO- https://github.com/Aniverse/TrCtrlProToc0l/raw/master/A)
bash <(curl -s https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/A)
}
#################################################################################
# 颜色 -----------------------------------------------------------------------------------
black=$(tput setaf 0) ; red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3); bold=$(tput bold)
blue=$(tput setaf 4) ; magenta=$(tput setaf 5) ; cyan=$(tput setaf 6) ; white=$(tput setaf 7) ; normal=$(tput sgr0)
on_black=$(tput setab 0); on_red=$(tput setab 1) ; on_green=$(tput setab 2); on_yellow=$(tput setab 3)
on_blue=$(tput setab 4) ; on_magenta=$(tput setab 5) ; on_cyan=$(tput setab 6) ; on_white=$(tput setab 7)
shanshuo=$(tput blink) ; wuguangbiao=$(tput civis) ; guangbiao=$(tput cnorm) ; jiacu=${normal}${bold}
underline=$(tput smul) ; reset_underline=$(tput rmul) ; dim=$(tput dim)
standout=$(tput smso) ; reset_standout=$(tput rmso) ; title=${standout}
baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue} ; bailvse=${white}${on_green}
baiqingse=${white}${on_cyan} ; baihongse=${white}${on_red} ; baizise=${white}${on_magenta}
heibaise=${black}${on_white} ; heihuangse=${on_yellow}${black}
### 是否为 IPv4 地址(其实也不一定是) ###
function isValidIpAddress() { echo $1 | grep -qE '^[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?$' ; }
### 是否为内网 IPv4 地址 ###
function isInternalIpAddress() { echo $1 | grep -qE '(192\.168\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(172\.((1[6-9])|(2\d)|(3[0-1]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))|(10\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.((\d{1,2})$|(1\d{2})$|(2[0-4]\d)$|(25[0-5])$))' ; }
function exit_1() { rm -rf /etc/TrCtrlProToc0l /tmp/system_kernel_list /log/kernel_tobe_del_list $HOME/1 ; exit 1 ; }
# -----------------------------------------------------------------------------------
mkdir -p /etc/TrCtrlProToc0l /log/tcp ; cd /etc/TrCtrlProToc0l
cancel() { echo -e "${normal}"
rm -rf /tmp/system_kernel_list /log/kernel_tobe_del_list /etc/TrCtrlProToc0l $HOME/1
exit ; }
trap cancel SIGINT
# Outputs="/dev/null"
export DEBIAN_FRONTEND=noninteractive
SETUPDATE=$(date "+%Y.%m.%d.%H:%M:%S")
export Outputs="/log/tcp/$SETUPDATE.log"
SysSupport=0 ; DeBUG=0
[[ $1 == -d ]] && DeBUG=1 && skip_emmm=1
[[ $1 == -s ]] && skip_emmm=1
KernelBit=$(getconf LONG_BIT)
[[ $KernelBit == 32 ]] && KernelBitVer=i386 ; [[ $KernelBit == 64 ]] && KernelBitVer=amd64
DISTRO=` awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release | tr 'A-Z' 'a-z' `
DISTROU=` awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release `
CODENAME=` cat /etc/os-release | grep VERSION= | tr '[A-Z]' '[a-z]' | sed 's/\"\|(\|)\|[0-9.,]\|version\|lts//g' | awk '{print $2}' `
[[ $DISTRO == ubuntu ]] && osversion=` grep Ubuntu /etc/issue | head -1 | grep -oE "[0-9.]+" `
[[ $DISTRO == debian ]] && osversion=` cat /etc/debian_version `
[[ $CODENAME =~ (xenial|bionic|jessie|stretch|buster) ]] && SysSupport=1
# -----------------------------------------------------------------------------------
[[ $EUID -ne 0 ]] && echo -e "\n${red}错误${jiacu} 请使用 root 运行本脚本!${normal}" && exit_1
[[ ! $DeBUG == 1 ]] && {
[[ -d /proc/vz ]] && echo -e "\n${red}错误${jiacu} 不支持 OpenVZ!${normal}" && exit_1
# Xen-PV 也不支持,不过就不作检测了……
[[ ! $KernelBit == 64 ]] && echo -e "\n${red}错误${jiacu} 不支持非 64 位系统!${normal}" && exit_1
[[ -z "$(dpkg -l |grep 'grub-')" ]] && echo -e "\n${red}错误${jiacu} 未发现 grub!${normal}" && exit_1
[[ ! $SysSupport == 1 ]] && echo -e "\n${red}错误${jiacu} 不支持 Debian 8/9/10、Ubuntu 16.04/18.04 以外的系统!${normal}" && exit_1 ; }
function emmm() { clear
echo -e " ${bold}如果脚本出了问题,可以输入这条命令查看日志:${red}cat $Outputs${jiacu}"
read -ep " 知道了没? ${cyan}" input
[[ $input != "知道了" ]] && {
echo -e "\n ${jiacu}你如果不知道的话那我也不知道脚本要怎么运行了 …… 我什么也不知道
不过你可以选择出门右转: ${yellow}${underline}bash <(wget -qO- https://github.com/chiakge/Linux-NetSpeed/raw/master/tcp.sh)${reset_underline}${normal}
${bold}那就不关我事了${normal}\n"
exit_1 ; }
}
# 菜单
function script_menu() { clear ; echo
# [[ $CODENAME =~ (bionic|stretch) ]] && enable_rclocal
# 确保 debconf-get-selections 存在
for ddd in debconf-set-selections debconf-get-selections ; do
[[ ! `command -v $ddd` ]] && wget --no-check-certificate -qO /usr/bin/$ddd https://github.com/Aniverse/inexistence/raw/master/00.Installation/script/$ddd && chmod +x /usr/bin/$ddd ; done
# 操作系统、内核等参数检测
[ -f /etc/redhat-release ] && KNA=$(awk '{print $1}' /etc/redhat-release)
[ -f /etc/os-release ] && KNA=$(awk -F'[= "]' '/PRETTY_NAME/{print $3}' /etc/os-release)
[ -f /etc/lsb-release ] && KNA=$(awk -F'[="]+' '/DISTRIB_ID/{print $2}' /etc/lsb-release)
# tcp_control=` awk '{print $1}' /proc/sys/net/ipv4/tcp_available_congestion_control `
tcp_control=` cat /proc/sys/net/ipv4/tcp_congestion_control `
tcp_control_all=` cat /proc/sys/net/ipv4/tcp_available_congestion_control `
# tcp_control_all=` cat /proc/sys/net/ipv4/tcp_allowed_congestion_control `
running_kernel=` uname -r `
arch=$( uname -m )
lbit=$( getconf LONG_BIT )
# dpkg -l | grep "$running_kernel"
tcp_c_name=$tcp_control
[[ $tcp_control == reno ]] && tcp_c_name="reno (系统默认算法)"
[[ $tcp_control == cubic ]] && tcp_c_name="cubic (系统默认算法)"
[[ $tcp_control == bbr ]] && tcp_c_name="bbr (原版 BBR)"
[[ $tcp_control == bbr_powered ]] && tcp_c_name="bbr_powered (用 Vicer 脚本安装的 Yankee 版 魔改 BBR)"
[[ $tcp_control == tsunami ]] && tcp_c_name="tsunami (Yankee 版 魔改 BBR)"
[[ $tcp_control == nanqinlang ]] && tcp_c_name="nanqinlang (南琴浪 版 魔改 BBR)"
# 以后准备增加检查当前系统是否有可用内核但是没启用的情况(比如装了4.11.12,但是当前锐速使用了3.16.0-43,这样要切换到BBR的话其实不需要删掉内核或者重新安装4.11.12的)
# 不过想不删掉其他内核只用那个内核的话还是有点麻烦的,估计还是会写成把其他内核删掉的方法
# digit_ver_image=`dpkg -l | grep linux-image | awk '{print $2}' | awk -F '-' '{print $3}'`
# digit_ver_headers=`dpkg -l | grep linux-headers | awk '{print $2}' | awk -F '-' '{print $3}'`
# 检查理论上内核是否支持锐速
LSKernel="${red}否${jiacu}"
SSKernel="${red}否${jiacu}"
LS_Kernel_url='https://raw.githubusercontent.com/Aniverse/lotServer/master/lotServer.log'
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)
MyKernel=$(wget --no-check-certificate -qO- "$LS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |grep "$AcceVer" |tail -n 1)
[[ -n $MyKernel ]] && LSKernel="${green}是${jiacu}"
unset MyKernel
SS_Kernel_url='https://raw.githubusercontent.com/0oVicero0/serverSpeeder_kernel/master/serverSpeeder.txt'
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)
MyKernel=$(wget --no-check-certificate -qO- "$SS_Kernel_url" |grep "$KNA/" |grep "/x$KernelBit/" |grep "/$running_kernel/" |grep "$AcceVer" |tail -n 1)
[[ -n $MyKernel ]] && SSKernel="${green}是${jiacu}"
# 检查理论上内核是否支持原版 BBR(内核高于 4.9 也不一定就有 bbr)
function version_ge(){ test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1" ; }
# 2018.10.23 这个以后再拿去判断,现在懒得动了
# 2019.04.25 也有的内核里这里没有 bbr
ls /lib/modules/$(uname -r)/kernel/net/ipv4 2>/dev/null | grep -q bbr && bbr_exist=yes || bbr_exist=no
kernel_vvv=$(uname -r | cut -d- -f1)
if version_ge $kernel_vvv 4.9 ; then BBRKernel="${green}是${jiacu}" ; else BBRKernel="${red}否${jiacu}" ; fi
if version_ge $kernel_vvv 4.9.3 && ! version_ge $kernel_vvv 5.3 ; then YKKernel="${green}是${jiacu}" ; else YKKernel="${red}否${jiacu}" ; fi
if version_ge $kernel_vvv 4.9.3 && ! version_ge $kernel_vvv 5.3 ; then NQLKernel="${green}是${jiacu}" ; else NQLKernel="${red}否${jiacu}" ; fi
if version_ge $kernel_vvv 4.14 && ! version_ge $kernel_vvv 5.1 ; then BBRPKernel="${green}是${jiacu}"
elif version_ge $kernel_vvv 5.1 ; then BBRPKernel="${green}无需 bbrplus${jiacu}" ; else BBRPKernel="${red}否${jiacu}" ; fi
# 检查 锐速 与 BBR 是否已启用
[[ ` ps aux | grep appex | grep -v grep ` ]] && SSrunning="${green}是${jiacu}" || SSrunning="${red}否${jiacu}"
if [[ $tcp_control =~ ("nanqinlang"|"tsunami") ]]; then bbrinuse="${green}是${jiacu}"
elif [[ `echo $tcp_control | grep bbr` ]]; then bbrinuse="${green}是${jiacu}"
else bbrinuse="${red}否${jiacu}" ; fi
dpkg -l | grep linux-image | awk '{print $2}' >> /tmp/system_kernel_list
dpkg -l | grep ovhkernel | awk '{print $2}' >> /tmp/system_kernel_list
dpkg -l | grep pve-kernel | awk '{print $2}' >> /tmp/system_kernel_list
dpkg -l | grep linux-headers | awk '{print $2}' >> /tmp/system_kernel_list
dpkg -l | grep linux-modules | awk '{print $2}' >> /tmp/system_kernel_list
dpkg -l | grep generic-hwe | awk '{print $2}' >> /tmp/system_kernel_list
echo -e " ${baizise}${bold} El Psy Congroo! ${normal} "
echo -e " ${bold}"
echo -e " 当前操作系统 ${green}$DISTROU $osversion $CODENAME (x$lbit)${jiacu}"
echo -e " 当前正在使用的 TCP 拥塞控制算法 ${green}$tcp_c_name${jiacu}"
[[ $DeBUG == 1 ]] &&
echo -e " 当前可以使用的 TCP 拥塞控制算法 ${green}$tcp_control_all${jiacu}"
echo -e " 当前正在使用的系统内核 ${green}$running_kernel${jiacu}"
echo -e " 当前内核是否支持 bbr $BBRKernel"
echo -e " 当前内核是否支持 bbrplus $BBRPKernel"
echo -e " 当前内核是否支持 Yankee 版魔改 bbr $YKKernel"
echo -e " 当前内核是否支持 南琴浪 版魔改 bbr $NQLKernel"
echo -e " 当前内核是否支持 ServerSpeeder $SSKernel"
echo -e " 当前内核是否支持 LotServer $LSKernel"
echo -e " 当前 BBR 是否已启用 $bbrinuse"
echo -e " 当前 锐速 是否已启用 $SSrunning"
echo -e "\n 当前系统内所有已安装的 kernel/headers/modules 列表\n"
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"
echo -e "\n ${jiacu}当前脚本版本:$ScriptVersion 脚本更新时间:$ScriptDate"
[[ $DeBUG == 1 ]] && echo -e "\n 当前脚本已处于调试模式"
echo -e "\n ${yellow}${bold}使用本脚本前请先阅读本脚本 GitHub 上的 README;作者水平菜,不保证脚本不会翻车${jiacu}\n"
echo -e " 如果脚本出了问题,可以输入这条命令查看日志:${red}cat $Outputs${jiacu}"
echo -e "\n 如需报错请务必附上日志${jiacu}\n"
[[ ! $( dpkg -l | grep $(uname -r) ) ]] && echo -e "\n ${bold}${red}注意${jiacu} 系统中似乎检测不到你当前的内核,你可能正在使用来自 netboot 的内核。\n 这种情况下本脚本的功能不一定能正常工作!\n"
# 下次考虑把 exit_1 也加上报错信息提示
echo -e " ${green}(01) ${jiacu}安装 原版 BBR "
echo -e " ${green}(02) ${jiacu}安装 魔改 BBR / tsunami "
echo -e " ${green}(03) ${jiacu}安装 魔改 BBR / nanqinlang "
echo -e " ${green}(04) ${jiacu}安装 bbrplus "
echo -e " ${green}(05) ${jiacu}安装 锐速 / LotServer "
echo -e " ${green}(06) ${jiacu}安装 锐速 / ServerSpeeder "
[[ $DeBUG == 1 ]] &&
echo -e " ${green}(11) ${jiacu}安装 指定内核"
echo -e " ${green}(12) ${jiacu}安装 4.11.12 内核"
echo -e " ${green}(13) ${jiacu}安装 ServerSpeeder 内核(4.4.0-47 或 3.12.1)"
echo -e " ${green}(14) ${jiacu}安装 ServerSpeeder 内核(3.16.0-43 或 3.16.0-4)"
echo -e " ${green}(15) ${jiacu}安装 LotServer 内核(4.15.0-30 或 4.9.0-4)"
echo -e " ${green}(16) ${jiacu}安装 LotServer 内核(MoeClub 脚本)"
echo -e " ${green}(17) ${jiacu}安装 4.14.129-bbrplus 内核"
echo -e " ${green}(21) ${jiacu}卸载 BBR "
echo -e " ${green}(22) ${jiacu}卸载 锐速 "
echo -e " ${green}(23) ${jiacu}卸载 多余内核 "
echo -e " ${green}(24) ${jiacu}卸载 指定内核 "
[[ $DeBUG == 1 ]] && {
echo -e " ${green}(25) ${jiacu}卸载 所有内核(作死) "
echo -e " ${green}(31) ${jiacu}安装 Xanmod "
echo -e " ${green}(32) ${jiacu}安装 Xanmod,并删除其他内核 "
echo -e " ${green}(33) ${jiacu}安装 liquorix "
echo -e " ${green}(39) ${jiacu}安装 HWE 内核(Ubuntu 专用)"
}
echo -e " ${green}(41) ${jiacu}安装 锐速 / LotServer (MoeClub 脚本)"
echo -e " ${green}(90) ${jiacu}重启 "
[[ $DeBUG == 1 ]] && {
echo -e " ${green}(96) ${jiacu}切换拥塞控制算法 "
echo -e " ${green}(98) ${jiacu}调试 "
}
echo -e " ${green}(99) ${jiacu}返回 \n"
rm -f /tmp/system_kernel_list ; }
# action
function read_response() {
read -ep " ${yellow}你想做什么?(默认返回) ${normal}" response ; echo -n "${normal}"
case $response in
1 | 01) # 安装 原版 BBR
bbr_install ;;
2 | 02) # 安装 魔改 BBR (Yankee)
ykbbr_install ;;
3 | 03) # 安装 魔改 BBR (nanqinlang)
nqlbbr_install ;;
4 | 04) # 安装 bbrplus
bbr_plus_install ;;
5 | 05) # 安装 LotServer
ls_install ;;
6 | 06) # 安装 ServerSpeeder
ss_install ;;
11) # 安装 最新内核
selected_kernel_install ;;
12) # 安装 4.11.12 内核
online_ubuntu_bbr_firmware ; bbr_kernel_4_11_12 ;;
13) # 安装 特定的 ServerSpeeder 内核(4.4.0-47/3.12.1)
ss_kernel_install ;;
14) # 安装 ServerSpeeder 内核(3.16.0-43/3.16.0-4)
[[ $DISTRO == debian ]] && debian_ssr_kernel_3.16.0-4_apt
[[ $CODENAME == xenial ]] && kernelver=3.16.0-43-generic && ubuntu_serverspeeder_kernel_repo ;;
15) # 安装 LotServer 支持的内核(只支持新系统)(4.15.0-30/4.9.0-4)
ss_kernel_install_v2 ;;
16) # 安装 LotServer 支持的内核(支持 Ubuntu 14.04/16.04/18.04,Debian 7/8/9)
Debian_Kernel.sh ;;
17) # 安装 bbrplus 内核
bbr_plus_kernel_4_14 ;;
21) # 卸载 BBR
bbr_uninstall ;;
22) # 卸载 锐速
ss_uninstall ;;
23) # 卸载 多余内核
while [[ -z $kernel_version ]]; do
echo -ne "\n ${bold}请输入你要 ${baihongse}保留${jiacu} 的内核版本,其他版本的内核将会被卸载:${normal} " ; read -e kernel_version
[[ ! ` dpkg -l | grep linux-image | grep "$kernel_version" ` ]] && { echo -e "\n ${bold}${red}错误${jiacu} 大佬,你压根就没装这个内核吧!${normal}" ; unset kernel_version ; }
done
delete_other_kernel ; delete_other_kernel ;;
24) # 卸载 多余内核
while [[ -z $kernel_version ]]; do
echo -ne "\n ${bold}请输入你要 ${baihongse}卸载${jiacu} 的内核版本,其他版本的内核将会被保留:${normal} " ; read -e kernel_version
[[ ! ` dpkg -l | grep linux-image | grep "$kernel_version" ` ]] && { echo -e "\n ${bold}${red}错误${jiacu} 大佬,你压根就没装这个内核吧!${normal}" ; unset kernel_version ; }
done
delete_kernel ;;
25) # 卸载 所有内核
echo -ne "\n ${bold}想清楚了?${normal} " ; read
kernel_version=10086
delete_other_kernel ; delete_other_kernel ;;
31) # 安装 xanmod
xanmod_install ;;
32) # 安装 xanmod,删除其他内核
xanmod_install ; delete_other_kernel ; delete_other_kernel ;;
33) # 安装 liquorix
liquorix_install ;;
39) # 安装 HWE 内核
[[ $CODENAME == xenial ]] && apt-get install -y linux-generic-hwe-16.04
[[ $CODENAME == bionic ]] && apt-get install -y linux-generic-hwe-18.04 ;;
41) # MoeClub 脚本安装锐速
echo | bash <(wget -qO- https://github.com/MoeClub/lotServer/raw/master/Install.sh) install ;;
90) # 重启
reboot ;;
96) # 切换 TCP 拥塞控制算法
switch_cc ;;
98) # 启用调试模式
DeBUG=1 ; script_menu ; read_response ;;
""| 99) # 返回
echo ; exit 0 ;;
*) echo ; exit 0 ;;
esac ; }
###################################################################################################################################################################
# [[ `grep "Advanced options for Ubuntu" /etc/default/grub` ]] && sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=""/' /etc/default/grub
#S1# 安装 原版 BBR
function bbr_install() {
if [[ $BBRKernel == "${green}是${jiacu}" ]]; then
echo -ne "\n ${bold}理论上当前内核已支持 ${green}原版 BBR,尝试直接启用 BBR ...${normal} "
enable_bbr ; echo
[[ $(cat /proc/sys/net/ipv4/tcp_congestion_control) == bbr ]] && echo -e "\n ${bold}BBR 已启用 ...\n${normal}" || echo -e "\n ${bold}${red}警告 BBR 可能开启失败!考虑换个内核?${normal}\n"
else
ask_continue2
# echo -e " ${bold}当前内核不支持 BBR,先安装 ${green}4.11.12${jiacu} 内核以启用 BBR ...${normal} "
online_ubuntu_bbr_firmware
bbr_kernel_4_11_12
enable_bbr
[[ ! $DeBUG == 1 ]] && echo -ne "\n ${bold}即将重启系统,重启后 ${green}BBR${jiacu} 将会启动 ... ${normal}\n" && reboot
fi ; }
#S2# 安装 Yankee版魔改 BBR
function ykbbr_install() {
if [[ $YKKernel == "${green}是${jiacu}" ]]; then
echo -e "\n ${bold}理论上当前内核已支持 ${green}Yankee${jiacu} 版魔改 BBR,安装并启用魔改 BBR ...${normal} "
check_headers
check_essential
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) tsunami >> $Outputs 2>&1
enable_bbr tsunami
if [[ ` lsmod | grep tsunami ` ]]; then echo -e "\n ${bold}已开启 ${green}Yankee 版魔改 BBR${jiacu} ...${normal}\n"
else echo -e "\n ${bold}${red}错误 ${green}Yankee 版魔改 BBR${jiacu} 开启失败!考虑换个内核?${normal}\n" ; exit_1 ; fi
else
ask_continue2
# echo -e " ${bold}当前内核不支持 ${green}Yankee${jiacu} 版魔改 BBR,先安装 ${green}4.11.12${jiacu} 内核 ...${normal} "
online_ubuntu_bbr_firmware
check_essential
bbr_kernel_4_11_12
kernel_version=4.11.12 && delete_other_kernel
bbr_tsunami_autoinstall
enable_bbr tsunami
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}Yankee${jiacu} 版魔改 BBR ... ${normal}\n" && reboot
fi ; }
#S3# 安装 南琴浪版魔改 BBR
function nqlbbr_install() {
if [[ $NQLKernel == "${green}是${jiacu}" ]]; then
echo -e "\n ${bold}理论上当前内核已支持 ${green}南琴浪${jiacu} 版魔改 BBR,安装并启用魔改 BBR ...${normal} "
check_headers
check_essential
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) nanqinlang >> $Outputs 2>&1
enable_bbr nanqinlang
if [[ ` lsmod | grep nanqinlang ` ]]; then echo -e "\n ${bold}已开启 ${green}南琴浪${jiacu} 版魔改 BBR ...${normal}\n\n"
else echo -e "\n ${bold}${red}错误 ${green}南琴浪 版魔改 BBR${jiacu} 开启失败!考虑换个内核?${normal}\n" ; exit_1 ; fi
else
ask_continue2
# echo -e " ${bold}当前内核不支持 ${green}南琴浪${jiacu} 版魔改 BBR,先安装 ${green}4.11.12${jiacu} 内核 ...${normal} "
online_ubuntu_bbr_firmware
check_essential
bbr_kernel_4_11_12
kernel_version=4.11.12 && delete_other_kernel
bbr_nanqinlang_autoinstall
enable_bbr nanqinlang
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}南琴浪${jiacu} 版魔改 BBR ... ${normal}\n" && reboot
fi ; }
#S4# 安装 BBR Plus
function bbr_plus_install() {
if [[ $running_kernel == "4.14.129-bbrplus" ]]; then
enable_bbr bbrplus
if [[ ` lsmod | grep bbrplus ` ]]; then echo -e "\n ${bold}已开启 ${green}bbrplus${jiacu} ...${normal}\n"
else echo -e "\n ${bold}${red}错误 ${green}bbrplus${jiacu} 开启失败!考虑装 4.14.129 内核试试?${normal}\n" ; exit_1 ; fi
elif [[ $BBRPKernel == "${green}是${jiacu}" ]]; then
echo -e "\n ${bold}或许当前内核已支持 ${green}bbrplus${jiacu},实际上能不能装上我也不知道 ...${normal} "
check_headers
check_essential
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) bbrplus >> $Outputs 2>&1
enable_bbr bbrplus
if [[ ` lsmod | grep bbrplus ` ]]; then echo -e "\n ${bold}已开启 ${green}bbrplus${jiacu} ...${normal}\n"
else echo -e "\n ${bold}${red}错误 ${green}bbrplus${jiacu} 开启失败!考虑装 4.14.129 内核试试?${normal}\n" ; exit_1 ; fi
else
ask_continue2
online_ubuntu_bbr_firmware
check_essential
kernel_version=4.14.129
bbr_plus_kernel_4_14
delete_other_kernel
# bbr_plus_autoinstall # 其实那个内核里已经带了编译好的……
enable_bbr bbrplus
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}bbrplus ... ${normal}\n" && reboot
fi ; }
#S5# 安装 LotServer
function ls_install() {
if [[ $LSKernel == "${green}是${jiacu}" ]]; then
echo -e "\n ${bold}理论上当前内核已支持 ${green}LotServer${jiacu},直接安装 ... ${normal} \n"
lotserver_install
elif [[ $LSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == ubuntu ]]; then
ask_continue2
ss_kernel_install_v2
delete_other_kernel
delete_other_kernel
lotserver_autoinstall
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}LotServer${jiacu} ... ${normal}\n" && reboot
elif [[ $LSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == debian ]]; then
ask_continue2
ss_kernel_install_v2
delete_other_kernel
delete_other_kernel
lotserver_autoinstall
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}LotServer${jiacu} ... ${normal}\n" && reboot
fi ; }
#S6# 安装 ServerSpeeder
function ss_install() {
if [[ $SSKernel == "${green}是${jiacu}" ]]; then
echo -e "\n ${bold}理论上当前内核已支持 ${green}锐速${jiacu},直接安装 ... ${normal} "
serverspeeder_install
elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == ubuntu ]] && [[ ! $CODENAME == bionic ]]; then
ask_continue2
echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}3.16.0-43${jiacu} 内核 ... ${normal} \n"
export kernelver=3.16.0-43-generic
ubuntu_serverspeeder_kernel_repo
export kernel_version=3.16.0-43-generic
delete_other_kernel
delete_other_kernel
serverspeeder_autoinstall
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot
elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $CODENAME == bionic ]]; then
ask_continue2
echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}4.4.0-47${jiacu} 内核 ... ${normal} \n"
kernel_version=4.4.0-47
ubuntu_ss_kernel_4.4.0-47_apt
delete_other_kernel
delete_other_kernel # 可能上一次卸载的时候又给你强行安装一个 4.4.0 最新的内核,所以再删一次
serverspeeder_autoinstall
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot
elif [[ $SSKernel == "${red}否${jiacu}" ]] && [[ $DISTRO == debian ]]; then
ask_continue2
echo -ne " ${bold}当前内核不支持 ServerSpeeder,安装 ${green}3.16.0-4${jiacu} 内核 ... ${normal} \n"
kernel_version=3.16.0-4
debian_ssr_kernel_3.16.0-4_apt
delete_other_kernel
delete_other_kernel # 可能上一次卸载的时候又给你强行安装一个 3.16.0 最新的内核(目前是 3.16.0-7),所以再删一次
serverspeeder_autoinstall
[[ ! $DeBUG == 1 ]] && echo -e "\n ${bold}即将重启系统,重启后会自动安装 ${green}ServerSpeeder${jiacu} ... ${normal}\n" && reboot
fi ; }
# 卸载 锐速
function ss_uninstall() {
echo -ne "\n ${bold}${red}警告 ${jiacu}即将开始卸载 ${green}锐速${jiacu},敲 回车 继续,否则退出${normal} " ; read input
case $input in
"" ) echo ;;
* ) echo ; read_response ;;
esac
[[ `grep "Advanced options for Ubuntu" /etc/default/grub` ]] && sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT=""/' /etc/default/grub && update-grub >> $Outputs 2>&1
wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh" && echo | bash /tmp/appex.sh 'uninstall'
echo -e " ${bold}${red}已卸载 锐速,但安装的内核仍保留${normal}\n" ; }
# 卸载 BBR
function bbr_uninstall() {
echo -ne "\n ${bold}${red}警告 ${jiacu}即将开始卸载 ${green}BBR${jiacu},敲 回车 继续,否则退出${normal} " ; read input
case $input in
"" ) echo ;;
* ) echo ; read_response ;;
esac
if [[ $tcp_control =~ (nanqinlang|tsunami|bbr|bbr_powered|bbrplus) ]]; then
bbrname=$tcp_control ; disable_bbr ; echo -e " ${bold}${red}已卸载 BBR,但安装的内核仍保留${normal}\n"
else
echo -e " ${bold}${red}错误 ${jiacu}你并没有使用本脚本安装 BBR ...${normal}\n"
read_response
fi ; }
# 安装 指定内核(BBR)
function selected_kernel_install() {
get_version
install_required
echo ; }
#S13# 安装 特定锐速内核(OLD)
function ss_kernel_install() {
if [[ $CODENAME =~ (xenial|bionic) ]]; then
echo -e "\n ${bold}安装 ${green}4.4.0-47${jiacu} 内核 ...${normal} \n"
kernel_version=4.4.0-47
ubuntu_ss_kernel_4.4.0-47_apt
elif [[ $CODENAME == jessie ]]; then
echo -e "\n ${bold}安装 ${green}3.12-1${jiacu} 内核 ...${normal} \n"
kernel_version=3.12-1
debian_serverspeeder_kernel_3.12.1
else
echo -e "\n ${red}注意${jiacu} 本功能只支持 Debian 8 和 Ubuntu 16.04/18.04 !${normal}"
fi
echo ; }
#S14# 安装 特定锐速内核(New)
function ss_kernel_install_v2() {
if [[ $CODENAME == bionic ]]; then
echo -e "\n ${bold}安装 ${green}4.15.0-30${jiacu} 内核 ...${normal} \n"
kernel_version=4.15.0-30-generic
apt-get update
apt-get -y install linux-image-$kernel_version linux-headers-$kernel_version linux-modules-$kernel_version linux-modules-extra-$kernel_version
kernel_version=4.15.0-30
dpkg -l | grep linux-image-$kernel_version -q || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
elif [[ $CODENAME == stretch ]]; then
echo -e "\n ${bold}安装 ${green}4.9.0-4${jiacu} 内核 ...${normal} \n"
kernel_version=4.9.0-4-amd64
apt-get update
apt-get -y install linux-image-$kernel_version linux-headers-$kernel_version
kernel_version=4.9.0-4
dpkg -l | grep linux-image-$kernel_version -q || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
else
echo -e "\n ${red}注意${jiacu} 本功能只支持 Debian 9/Ubuntu 18.04 !${normal}"
exit_1
fi
echo ; }
#S16# MoeClub 版换 LotServer 内核脚本
function Debian_Kernel.sh() {
# bash <( wget -qO- https://moeclub.org/attachment/LinuxShell/Debian_Kernel.sh )
deb_issue="$(cat /etc/issue)"
deb_relese="$(echo $deb_issue |grep -io 'Ubuntu\|Debian' |sed -r 's/(.*)/\L\1/')"
os_ver="$(dpkg --print-architecture)"
[ -n "$os_ver" ] || exit 1
if [ "$deb_relese" == 'ubuntu' ]; then
deb_ver="$(echo $deb_issue |grep -o '[0-9]*\.[0-9]*' |head -n1)"
if [ "$deb_ver" == "14.04" ]; then
item="3.16.0-77-generic" && ver='trusty'
elif [ "$deb_ver" == "16.04" ]; then
item="4.8.0-36-generic" && ver='xenial'
elif [ "$deb_ver" == "18.04" ]; then
item="4.15.0-30-generic" && ver='bionic'
else
exit 1
fi
url='archive.ubuntu.com'
urls='security.ubuntu.com'
elif [ "$deb_relese" == 'debian' ]; then
deb_ver="$(echo $deb_issue |grep -o '[0-9]*' |head -n1)"
if [ "$deb_ver" == "7" ]; then
item="3.2.0-4-${os_ver}" && ver='wheezy' && url='archive.debian.org' && urls='archive.debian.org'
elif [ "$deb_ver" == "8" ]; then
item="3.16.0-4-${os_ver}" && ver='jessie' && url='archive.debian.org' && urls='deb.debian.org'
elif [ "$deb_ver" == "9" ]; then
item="4.9.0-4-${os_ver}" && ver='stretch' && url='deb.debian.org' && urls='deb.debian.org'
else
exit 1
fi
else
exit 1
fi
[ -n "$item" ] && [ -n "$urls" ] && [ -n "$url" ] && [ -n "$ver" ] || exit 1
if [ "$deb_relese" == 'ubuntu' ]; then
echo "deb http://${url}/${deb_relese} ${ver} main restricted universe multiverse" >/etc/apt/sources.list
echo "deb http://${url}/${deb_relese} ${ver}-updates main restricted universe multiverse" >>/etc/apt/sources.list
echo "deb http://${url}/${deb_relese} ${ver}-backports main restricted universe multiverse" >>/etc/apt/sources.list
echo "deb http://${urls}/${deb_relese} ${ver}-security main restricted universe multiverse" >>/etc/apt/sources.list
elif [ "$deb_relese" == 'debian' ]; then
echo "deb http://${url}/${deb_relese} ${ver} main" >/etc/apt/sources.list
echo "deb-src http://${url}/${deb_relese} ${ver} main" >>/etc/apt/sources.list
echo "deb http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list
echo "deb-src http://${urls}/${deb_relese}-security ${ver}/updates main" >>/etc/apt/sources.list
fi
apt-get update
apt-get install --no-install-recommends -y linux-image-${item} linux-headers-${item} # 这里加个 headers
while true; do
List_Kernel="$(dpkg -l |grep 'linux-image\|linux-modules\|linux-generic\|linux-headers' |grep -v "$item")"
Num_Kernel="$(echo "$List_Kernel" |sed '/^$/d' |wc -l)"
[ "$Num_Kernel" -eq "0" ] && break
for kernel in `echo "$List_Kernel" |awk '{print $2}'`
do
if [ -f "/var/lib/dpkg/info/${kernel}.prerm" ]; then
sed -i 's/linux-check-removal/#linux-check-removal/' "/var/lib/dpkg/info/${kernel}.prerm"
sed -i 's/uname -r/echo purge/' "/var/lib/dpkg/info/${kernel}.prerm"
fi
dpkg --force-depends --purge "$kernel"
done
done
apt-get autoremove -y
[ -d '/var/lib/apt/lists' ] && find /var/lib/apt/lists -type f -delete
}
# 安装 xanmod,apt
function xanmod_apt_install() {
echo 'deb http://deb.xanmod.org releases main' | tee /etc/apt/sources.list.d/xanmod-kernel.list
wget -qO- http://deb.xanmod.org/gpg.key | apt-key add -
kernel_version=5.2
apt-get update
apt-get install -y linux-xanmod ; }
# 安装 xanmod,apt,lts
function xanmod_apt_install_lts() {
wget https://dl.xanmod.org/xanmod-repository.deb -O xanmod-repository.deb -4
dpkg -i xanmod-repository.deb
# apt-get install -y gnupg
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86F7D09EE734E623
kernel_version=4.19
apt-get update
apt-get install -y linux-firmware intel-microcode iucode-tool
apt-get install -y linux-xanmod-lts ; }
function xanmod_dpkg_install() {
wget https://github.com/Aniverse/inexistence/raw/files/linux.kernel/xanmod/linux-headers-$kernel_version.deb
wget https://github.com/Aniverse/inexistence/raw/files/linux.kernel/xanmod/linux-image-$kernel_version.deb
dpkg -i linux-image-$kernel_version.deb
dpkg -i linux-headers-$kernel_version.deb
}
#S31# 安装 xanmod
function xanmod_install() {
echo ; read -ep " ${bold}输入你要安装的 Xanmod 版本: ${normal}" XanmodVer ; echo
online_ubuntu_bbr_firmware
# https://sourceforge.net/projects/xanmod/files/releases/
# https://xanmod.org/
if [[ $XanmodVer == 4.12 ]]; then
kernel_version=4.12.14-xanmod15
xanmod_dpkg_install
elif [[ $XanmodVer == 4.14 ]]; then # To be added
kernel_version=4.14.90-xanmod54
xanmod_dpkg_install
elif [[ $XanmodVer == 4.15 ]]; then
kernel_version=4.15.13-xanmod12
xanmod_dpkg_install
elif [[ $XanmodVer == 4.16 ]]; then
kernel_version=4.16.12-xanmod11
xanmod_dpkg_install
elif [[ $XanmodVer == 4.17 ]]; then
kernel_version=4.17.14-xanmod9
xanmod_dpkg_install
elif [[ $XanmodVer == 4.18 ]]; then
kernel_version=4.18.16-xanmod9
xanmod_dpkg_install
elif [[ $XanmodVer == 4.19 ]]; then # 4.19 是 LTS,以后再说
echo -e "Use lts instead" ; exit 1
kernel_version=4.19.57-xanmod29
xanmod_dpkg_install
elif [[ $XanmodVer == 4.20 ]]; then
kernel_version=4.20.12-xanmod7
xanmod_dpkg_install
elif [[ $XanmodVer == 5.0 ]]; then
kernel_version=5.0.13-xanmod8
xanmod_dpkg_install
elif [[ $XanmodVer == 5.1 ]]; then # To be added
kernel_version=5.1.16-xanmod10
xanmod_dpkg_install
elif [[ $XanmodVer == apt ]]; then # Current 5.2.0
kernel_version=xanmod ; xanmod_apt_install
elif [[ $XanmodVer == lts ]]; then
kernel_version=xanmod ; xanmod_apt_install_lts
fi
}
# 安装 liquorix
function liquorix_install() {
online_ubuntu_bbr_firmware
if [[ $DISTRO == ubuntu ]]; then
[[ ! `command -v add-apt-repository` ]] && apt-get install -y software-properties-common
add-apt-repository ppa:damentz/liquorix
elif [[ $DISTRO == debian ]]; then
[[ ! $(command -v curl) ]] && apt-get install -y curl
[ $(dpkg-query -W -f='${Status}' apt-transport-https 2>/dev/null | grep -c "ok installed") -eq 0 ] && apt-get install -y apt-transport-https
echo "deb http://liquorix.net/debian sid main
deb-src http://liquorix.net/debian sid main" > /etc/apt/sources.list.d/liquorix.list
curl https://liquorix.net/linux-liquorix.pub | apt-key add -
fi
apt-get update
apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64 -y ; }
###################################################################################################################################################################
# 重启后自动安装 BBR Plus
function bbr_plus_autoinstall() {
mkdir -p /etc/TrCtrlProToc0l
cat > /etc/TrCtrlProToc0l/TCP-auto-install.sh <<EOF
#!/bin/bash
cd /etc/TrCtrlProToc0l
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) bbrplus
sysctl -p
EOF
auto_install_via_systemd ; }
# 重启后自动安装 南琴浪 版 BBR
function bbr_nanqinlang_autoinstall() {
mkdir -p /etc/TrCtrlProToc0l
cat > /etc/TrCtrlProToc0l/TCP-auto-install.sh <<EOF
#!/bin/bash
cd /etc/TrCtrlProToc0l
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) nanqinlang
sysctl -p
EOF
auto_install_via_systemd ; }
# 重启后自动安装 Yankee 版 BBR
function bbr_tsunami_autoinstall() {
mkdir -p /etc/TrCtrlProToc0l
cat > /etc/TrCtrlProToc0l/TCP-auto-install.sh <<EOF
#!/bin/bash
cd /etc/TrCtrlProToc0l
bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/Aniverse/TrCtrlProToc0l/master/compile_tcp_cc.sh) tsunami
sysctl -p
EOF
auto_install_via_systemd ; }
# 重启后自动安装锐速 ServerSpeeder
function serverspeeder_autoinstall() {
mkdir -p /etc/TrCtrlProToc0l
wget --no-check-certificate -q https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh -O /etc/TrCtrlProToc0l/ss.sh
cat > /etc/TrCtrlProToc0l/TCP-auto-install.sh <<EOF
#!/bin/bash
echo | bash /etc/TrCtrlProToc0l/ss.sh 'install'
EOF
auto_install_via_systemd ; }
# 重启后自动安装锐速 LotServer
function lotserver_autoinstall() {
mkdir -p /etc/TrCtrlProToc0l
wget --no-check-certificate -q https://github.com/Aniverse/lotServer/raw/master/lotServer.sh -O /etc/TrCtrlProToc0l/ls.sh
cat > /etc/TrCtrlProToc0l/TCP-auto-install.sh <<EOF
#!/bin/bash
bash /etc/TrCtrlProToc0l/ls.sh install
EOF
auto_install_via_systemd ; }
###################################################################################################################################################################
# Debian 安装 3.12.1 内核(For ServerSpeeder)
function debian_serverspeeder_kernel_3.12.1() {
wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-headers-3.12-1.deb
wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-image-3.12-1.deb
echo ` debconf-get-selections linux-image-3.12-1-amd64 | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections
echo ` debconf-get-selections linux-headers-3.12-1-common | grep -C5 "keep the local version currently installed" | grep keep_current | sed "s/select/note/g"` | debconf-set-selections
{ dpkg -i [12].deb >> $Outputs 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
rm -rf [12].deb ; echo ; }
# Debian 安装 3.16.0-4 内核(For ServerSpeeder)
function debian_ss_kernel_3.16.0-4() {
wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-image-3.16.0-4.deb
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
{ dpkg -i 1.deb >> $Outputs 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
rm -rf 1.deb ; }
# Debian 安装 3.16.0-4 内核(apt-get install)(For ServerSpeeder)
function debian_ssr_kernel_3.16.0-4_apt() {
grep snapshot.debian.org /etc/apt/sources.list -q ||
cat >> /etc/apt/sources.list << EOF
deb http://snapshot.debian.org/archive/debian/20180620T205325Z/ jessie main contrib non-free
deb-src http://snapshot.debian.org/archive/debian/20180620T205325Z/ jessie main contrib non-free
EOF
echo 'Acquire::Check-Valid-Until 0;' > /etc/apt/apt.conf.d/10-no-check-valid-until
echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
apt-get update >> $Outputs 2>&1
echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
apt-get install -y linux-image-3.16.0-4-amd64 >> $Outputs 2>&1
apt-get install -y linux-headers-3.16.0-4-common linux-headers-3.16.0-4-all >> $Outputs 2>&1
apt-get install -y grep unzip ethtool >> $Outputs 2>&1
[[ ! $( dpkg -l | grep linux-image-3.16.0-4-amd64 ) ]] && { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; } ; }
# Ubuntu 安装 4.4.0-47 内核(For ServerSpeeder)
function ubuntu_ss_kernel_4.4.0-47() {
wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-image-4.4.0-47.deb
wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-headers-4.4.0-47-all.deb
wget --no-check-certificate -qO 3.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/ServerSpeeder/linux-headers-4.4.0-47.deb
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
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
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
apt-get install -y grep unzip ethtool >> $Outputs 2>&1
{ dpkg -i [123].deb >> $Outputs 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
rm -rf [123].deb ; }
# Ubuntu 安装 4.4.0-47 内核(apt-get install)(For ServerSpeeder)
function ubuntu_ss_kernel_4.4.0-47_apt() {
[[ $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
echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
apt-get update >> $Outputs 2>&1
echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
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 >> $Outputs 2>&1
apt-get install -y grep unzip ethtool >> $Outputs 2>&1
[[ ! $( dpkg -l | grep linux-image-4.4.0-47-generic ) ]] && { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; } ; }
# Ubuntu 安装 3.16.0-43 内核(For ServerSpeeder)
function _ubuntu_serverspeeder_kernel_3.16.0-43() {
apt-get -y install module-init-tools >> $Outputs 2>&1
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
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
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
apt-get install -y grep unzip ethtool >> $Outputs 2>&1
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
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
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
{ dpkg -i 1.deb >> $Outputs 2>&1 ; } || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" | tee -a $Outputs ; exit_1 ; }
dpkg -i 2.deb >> $Outputs 2>&1 ; apt-get -f -y install >> $Outputs 2>&1
dpkg -i 3.deb >> $Outputs 2>&1 ; apt-get -f -y install >> $Outputs 2>&1
rm -rf [123].deb ; }
# Ubuntu 从系统源安装锐速内核(For ServerSpeeder)
function ubuntu_serverspeeder_kernel_repo() {
sed -i '/deb http:\/\/security.ubuntu.com\/ubuntu trusty-security main/'d /etc/apt/sources.list
[[ `grep "trusty-security" /etc/apt/sources.list` ]] && sleep 0 || echo -e "\ndeb http://security.ubuntu.com/ubuntu trusty-security main" >> /etc/apt/sources.list
echo -ne "\n ${bold}添加源,更新 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
{ apt-get update >> $Outputs 2>&1 ; } && { echo "${green}${bold}完成${normal}" | tee -a $Outputs ; }
echo -ne "\n ${bold}安装内核 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
apt-get install -y grep unzip ethtool >> $Outputs 2>&1
apt-get -y install linux-image-extra-$kernelver linux-image-$kernelver linux-headers-$kernelver >> $Outputs 2>&1 && { echo "${green}${bold}完成${normal}" | tee -a $Outputs ; }
[[ ! ` dpkg -l | grep linux-image-$kernelver ` ]] && { echo "${bold}${red}失败${normal}" | tee -a $Outputs ; exit_1 ; }
sed -i '/deb http:\/\/security.ubuntu.com\/ubuntu trusty-security main/'d /etc/apt/sources.list
echo -ne "\n ${bold}删除源,更新 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
{ apt-get update >> $Outputs 2>&1 ; } && { echo "${green}${bold}完成${normal}" | tee -a $Outputs ; } ; }
# Ubuntu 不卸载新内核的情况下使用老内核启动(For ServerSpeeder)
function ubuntu_serverspeeder_updategrub() {
sed -i 's/GRUB_DEFAULT=.*/GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux kernelver"/' /etc/default/grub
sed -i "s/kernelver/$kernelver/" /etc/default/grub
update_grub ; }
# 内核匹配的情况下安装锐速
function serverspeeder_install() { wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh" && echo | bash /tmp/appex.sh 'install'
ps aux | grep -v grep | grep -q appex && echo -e "\n${bold}${green}锐速已在运行 ...${normal}\n" || echo -e "\n${bold}${red}锐速尚未在运行,可能安装失败!${normal}\n" ; }
function lotserver_install() {
bash <(wget --no-check-certificate -qO- https://github.com/Aniverse/lotServer/raw/master/lotServer.sh) install
ps aux | grep -v grep | grep -q appex && echo -e "\n${bold}${green}锐速已在运行 ...${normal}\n" || echo -e "\n${bold}${red}锐速尚未在运行,可能安装失败!${normal}\n" ; }
###################################################################################################################################################################
# Online.net 独服补充固件(For BBR)
function online_ubuntu_bbr_firmware() {
mkdir -p /lib/firmware/bnx2
if [[ ! -f /lib/firmware/bnx2/fw.lock ]]; then
touch /lib/firmware/bnx2/fw.lock
echo -ne " ${bold}下载可能缺少的固件 ... ${normal}" | tee -a $Outputs ; echo >> $Outputs
wget -qO /lib/firmware/bnx2/bnx2-mips-06-6.2.3.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Firmware/bnx2-mips-06-6.2.3.fw
wget -qO /lib/firmware/bnx2/bnx2-mips-09-6.2.1b.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Firmware/bnx2-mips-09-6.2.1b.fw
wget -qO /lib/firmware/bnx2/bnx2-rv2p-09ax-6.0.17.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Firmware/bnx2-rv2p-09ax-6.0.17.fw
wget -qO /lib/firmware/bnx2/bnx2-rv2p-09-6.0.17.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Firmware/bnx2-rv2p-09-6.0.17.fw
wget -qO /lib/firmware/bnx2/bnx2-rv2p-06-6.0.15.fw https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Firmware/bnx2-rv2p-06-6.0.15.fw
echo | tee -a $Outputs
fi ; }
# 安装 4.11.12 的内核(For BBR)
function bbr_kernel_4_11_12() {
if [[ $CODENAME =~ (stretch|buster) ]]; then
[[ ! `dpkg -l | grep libssl1.0.0` ]] && {
echo -ne "\n ${bold}安装 libssl1.0.0 ...${normal} " | tee -a $Outputs
wget --no-check-certificate https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Deb%20Package/Jessie/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb -O libssl1.0.deb >> $Outputs 2>&1
dpkg -i libssl1.0.deb >> $Outputs 2>&1
rm -f libssl1.0.deb ; echo | tee -a $Outputs
[[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -e "\n ${red}错误${bold} 安装 libssl1.0.0 失败!${normal}" | tee -a $Outputs ; exit_1 ; } ; }
else
[[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -ne "\n ${bold}安装 libssl1.0.0 ...${normal} " | tee -a $Outputs ; apt-get install -y libssl1.0.0 >> $Outputs 2>&1 ; echo | tee -a $Outputs
[[ ! `dpkg -l | grep libssl1.0.0` ]] && { echo -e "\n$ ${red}错误${bold} 安装 libssl1.0.0 失败!${normal}" | tee -a $Outputs ; exit_1 ; } ; }
fi
echo -ne "\n ${bold}安装 4.11.12 内核及其头文件 ... ${normal} " | tee -a $Outputs ; echo >> $Outputs
wget --no-check-certificate -qO 1.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/BBR/linux-headers-4.11.12-all.deb
wget --no-check-certificate -qO 2.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/BBR/linux-headers-4.11.12-amd64.deb
wget --no-check-certificate -qO 3.deb https://github.com/Aniverse/BitTorrentClientCollection/raw/master/Linux%20Kernel/BBR/linux-image-4.11.12-generic-amd64.deb
dpkg -i [123].deb >> $Outputs 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; }
rm -rf [123].deb ; echo
update_grub ; }
# 安装 4.14-bbrplus 内核(For BBR Plus)
# https://github.com/chiakge/Linux-NetSpeed/blob/master/tcp.sh
function bbr_plus_kernel_4_14() {
echo -ne "\n ${bold}安装 4.14.129 内核及其头文件 ... ${normal} " | tee -a $Outputs ; echo >> $Outputs
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
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
dpkg -i linux-image-4.14.129.deb >> $Outputs 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; }
dpkg -i linux-headers-4.14.129.deb >> $Outputs 2>&1 || { echo -e "\n ${bold}${red}错误${jiacu} 安装 内核 失败!${normal}" ; exit_1 ; }
rm -rf linux-*-4.14.129.deb ; echo
update_grub ; }