forked from ylx2016/Linux-NetSpeed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tcpx.sh
2015 lines (1884 loc) · 86.8 KB
/
tcpx.sh
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
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: CentOS 7/8,Debian/ubuntu,oraclelinux
# Description: BBR+BBRplus+Lotserver
# Version: 100.0.1.21
# Author: 千影,cx9208,YLX
# 更新内容及反馈: https://blog.ylx.me/archives/783.html
#=================================================
# RED='\033[0;31m'
# GREEN='\033[0;32m'
# YELLOW='\033[0;33m'
# SKYBLUE='\033[0;36m'
# PLAIN='\033[0m'
sh_ver="100.0.1.21"
github="raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master"
imgurl=""
headurl=""
github_network=1
Green_font_prefix="\033[32m"
Red_font_prefix="\033[31m"
Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
if [ -f "/etc/sysctl.d/bbr.conf" ]; then
rm -rf /etc/sysctl.d/bbr.conf
fi
# 检查当前用户是否为 root 用户
if [ "$EUID" -ne 0 ]; then
echo "请使用 root 用户身份运行此脚本"
exit
fi
# 检查github网络
check_github() {
# 检测域名的可访问性函数
check_domain() {
local domain="$1"
if ! curl --head --silent --fail "$domain" >/dev/null; then
echo -e "${Error}无法访问 $domain,请检查网络或者本地DNS"
github_network=0
fi
}
# 检测所有域名的可访问性
check_domain "https://raw.githubusercontent.com"
check_domain "https://api.github.com"
check_domain "https://github.com"
if [ "$github_network" -eq 0 ]; then
echo -e "${Error}github网络访问受限,将影响内核的安装以及脚本的检查更新,5秒后继续运行脚本"
sleep 5
else
# 所有域名均可访问,打印成功提示
echo "${Green_font_prefix}github可访问${Font_color_suffix},继续执行脚本..."
fi
}
#检查连接
checkurl() {
url=$(curl --max-time 5 --retry 3 --retry-delay 2 --connect-timeout 2 -s --head $1 | head -n 1)
# echo ${url}
if [[ ${url} == *200* || ${url} == *302* || ${url} == *308* ]]; then
echo "下载地址检查OK,继续!"
else
echo "下载地址检查出错,退出!"
exit 1
fi
}
#cn使用fastgit.org的github加速
check_cn() {
geoip=$(wget --user-agent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" --no-check-certificate -qO- https://api.ip.sb/geoip -T 10 | grep "\"country_code\":\"CN\"")
if [[ "$geoip" != "" ]]; then
# echo "下面使用fastgit.org的加速服务"
# echo ${1//github.com/download.fastgit.org}
echo https://endpoint.fastgit.org/$1
else
echo $1
fi
}
#安装BBR内核
installbbr() {
kernel_version="5.9.6"
bit=$(uname -m)
rm -rf bbr
mkdir bbr && cd bbr || exit
if [[ "${release}" == "centos" ]]; then
if [[ ${version} == "7" ]]; then
if [[ ${bit} == "x86_64" ]]; then
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
#github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}' | awk -F '[_]' '{print $3}')
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=$github_ver
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
#headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/kernel-headers-${github_ver}-1.x86_64.rpm
#imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/kernel-${github_ver}-1.x86_64.rpm
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-headers-c7.rpm $headurl
wget -N -O kernel-c7.rpm $imgurl
yum install -y kernel-c7.rpm
yum install -y kernel-headers-c7.rpm
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
elif [[ "${release}" == "ubuntu" || "${release}" == "debian" ]]; then
if [[ ${bit} == "x86_64" ]]; then
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Debian_Kernel' | grep '_latest_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=$github_ver
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
#headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-headers-${github_ver}_${github_ver}-1_amd64.deb
#imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-image-${github_ver}_${github_ver}-1_amd64.deb
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers-d10.deb $headurl
wget -N -O linux-image-d10.deb $imgurl
dpkg -i linux-image-d10.deb
dpkg -i linux-headers-d10.deb
elif [[ ${bit} == "aarch64" ]]; then
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Debian_Kernel' | grep '_arm64_' | grep '_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=$github_ver
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
#headurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-headers-${github_ver}_${github_ver}-1_amd64.deb
#imgurl=https://github.com/ylx2016/kernel/releases/download/$github_tag/linux-image-${github_ver}_${github_ver}-1_amd64.deb
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers-d10.deb $headurl
wget -N -O linux-image-d10.deb $imgurl
dpkg -i linux-image-d10.deb
dpkg -i linux-headers-d10.deb
else
echo -e "${Error} 不支持x86_64及arm64/aarch64以外的系统 !" && exit 1
fi
fi
cd .. && rm -rf bbr
BBR_grub
echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功,默认从排第一的高版本内核启动"
check_kernel
}
#安装BBRplus内核 4.14.129
installbbrplus() {
kernel_version="4.14.160-bbrplus"
bit=$(uname -m)
rm -rf bbrplus
mkdir bbrplus && cd bbrplus || exit
if [[ "${release}" == "centos" ]]; then
if [[ ${version} == "7" ]]; then
if [[ ${bit} == "x86_64" ]]; then
kernel_version="4.14.129_bbrplus"
detele_kernel_head
headurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-headers-4.14.129-bbrplus.rpm
imgurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/centos/7/kernel-4.14.129-bbrplus.rpm
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-headers-c7.rpm $headurl
wget -N -O kernel-c7.rpm $imgurl
yum install -y kernel-c7.rpm
yum install -y kernel-headers-c7.rpm
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
if [[ ${bit} == "x86_64" ]]; then
kernel_version="4.14.129-bbrplus"
detele_kernel_head
headurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-headers-4.14.129-bbrplus.deb
imgurl=https://github.com/cx9208/Linux-NetSpeed/raw/master/bbrplus/debian-ubuntu/x64/linux-image-4.14.129-bbrplus.deb
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers.deb $headurl
wget -N -O linux-image.deb $imgurl
dpkg -i linux-image.deb
dpkg -i linux-headers.deb
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
cd .. && rm -rf bbrplus
BBR_grub
echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功,默认从排第一的高版本内核启动"
check_kernel
}
#安装Lotserver内核
installlot() {
bit=$(uname -m)
if [[ ${bit} != "x86_64" ]]; then
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
if [[ ${bit} == "x86_64" ]]; then
bit='x64'
fi
if [[ ${bit} == "i386" ]]; then
bit='x32'
fi
if [[ "${release}" == "centos" ]]; then
rpm --import http://${github}/lotserver/${release}/RPM-GPG-KEY-elrepo.org
yum remove -y kernel-firmware
yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-firmware-${kernel_version}.rpm
yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-${kernel_version}.rpm
yum remove -y kernel-headers
yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-headers-${kernel_version}.rpm
yum install -y http://${github}/lotserver/${release}/${version}/${bit}/kernel-devel-${kernel_version}.rpm
fi
if [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
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
kernel_version="3.16.0-77-generic" && item="3.16.0-77-generic" && ver='trusty'
elif [ "$deb_ver" == "16.04" ]; then
kernel_version="4.8.0-36-generic" && item="4.8.0-36-generic" && ver='xenial'
elif [ "$deb_ver" == "18.04" ]; then
kernel_version="4.15.0-30-generic" && 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
kernel_version="3.2.0-4-${os_ver}" && item="3.2.0-4-${os_ver}" && ver='wheezy' && url='archive.debian.org' && urls='archive.debian.org'
elif [ "$deb_ver" == "8" ]; then
kernel_version="3.16.0-4-${os_ver}" && item="3.16.0-4-${os_ver}" && ver='jessie' && url='archive.debian.org' && urls='archive.debian.org'
elif [ "$deb_ver" == "9" ]; then
kernel_version="4.9.0-4-${os_ver}" && item="4.9.0-4-${os_ver}" && ver='stretch' && url='archive.debian.org' && urls='archive.debian.org'
else
exit 1
fi
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
apt-get update || apt-get --allow-releaseinfo-change update
apt-get install --no-install-recommends -y linux-image-${item}
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
if [ "$deb_ver" == "8" ]; then
dpkg -l | grep -q 'linux-base' || {
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'
dpkg -i '/tmp/linux-base_3.5_all.deb'
}
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'
dpkg -i '/tmp/linux-image-3.16.0-4-amd64_3.16.43-2+deb8u5_amd64.deb'
if [ $? -ne 0 ]; then
exit 1
fi
elif [ "$deb_ver" == "9" ]; then
dpkg -l | grep -q 'linux-base' || {
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'
dpkg -i '/tmp/linux-base_4.5_all.deb'
}
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'
dpkg -i '/tmp/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb'
##备选
#https://sys.if.ci/download/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
#http://mirror.cs.uchicago.edu/debian-security/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
#https://debian.sipwise.com/debian-security/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
#http://srv24.dsidata.sk/security.debian.org/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
#https://pubmirror.plutex.de/debian-security/pool/updates/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3+deb9u1_amd64.deb
#https://packages.mendix.com/debian/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3_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
#http://snapshot.debian.org/archive/debian/20171231T180144Z/pool/main/l/linux/linux-image-4.9.0-4-amd64_4.9.65-3_amd64.deb
if [ $? -ne 0 ]; then
exit 1
fi
else
exit 1
fi
fi
apt-get autoremove -y
[ -d '/var/lib/apt/lists' ] && find /var/lib/apt/lists -type f -delete
fi
BBR_grub
echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功,默认从排第一的高版本内核启动"
check_kernel
}
#安装xanmod内核 from xanmod.org
installxanmod() {
kernel_version="5.5.1-xanmod1"
bit=$(uname -m)
if [[ ${bit} != "x86_64" ]]; then
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
rm -rf xanmod
mkdir xanmod && cd xanmod || exit
if [[ "${release}" == "centos" ]]; then
if [[ ${version} == "7" ]]; then
if [[ ${bit} == "x86_64" ]]; then
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_lts_latest_' | grep 'xanmod' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=$github_ver
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-headers-c7.rpm $headurl
wget -N -O kernel-c7.rpm $imgurl
yum install -y kernel-c7.rpm
yum install -y kernel-headers-c7.rpm
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
elif [[ ${version} == "8" ]]; then
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_lts_C8_latest_' | grep 'xanmod' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=$github_ver
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-headers-c8.rpm $headurl
wget -N -O kernel-c8.rpm $imgurl
yum install -y kernel-c8.rpm
yum install -y kernel-headers-c8.rpm
fi
elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
if [[ ${bit} == "x86_64" ]]; then
# kernel_version="5.11.4-xanmod"
# xanmod_ver_b=$(rm -rf /tmp/url.tmp && curl -o /tmp/url.tmp 'https://dl.xanmod.org/dl/changelog/?C=N;O=D' && grep folder.gif /tmp/url.tmp | head -n 1 | awk -F "[/]" '{print $5}' | awk -F "[>]" '{print $2}')
# xanmod_ver_s=$(rm -rf /tmp/url.tmp && curl -o /tmp/url.tmp 'https://dl.xanmod.org/changelog/${xanmod_ver_b}/?C=M;O=D' && grep $xanmod_ver_b /tmp/url.tmp | head -n 3 | awk -F "[-]" '{print $2}')
#sourceforge_xanmod_lts_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
#sourceforge_xanmod_lts_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
#sourceforge_xanmod_lts_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_stable_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_stable_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_stable_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_cacule_ver=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/ | grep 'class="folder ">' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_cacule_file_img=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/ | grep 'linux-image' | head -n 1 | awk -F '"' '{print $2}')
# sourceforge_xanmod_cacule_file_head=$(curl -s https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/ | grep 'linux-headers' | head -n 1 | awk -F '"' '{print $2}')
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Debian_Kernel' | grep '_lts_latest_' | grep 'xanmod' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}')
#echo -e "获取的xanmod lts版本号为:${sourceforge_xanmod_lts_ver}"
echo -e "获取的xanmod lts版本号为:${github_ver}"
# kernel_version=$sourceforge_xanmod_stable_ver
kernel_version=$github_ver
# detele_kernel_head
# headurl=https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/${sourceforge_xanmod_stable_file_head}/download
# imgurl=https://sourceforge.net/projects/xanmod/files/releases/stable/${sourceforge_xanmod_stable_ver}/${sourceforge_xanmod_stable_file_img}/download
#kernel_version=$sourceforge_xanmod_lts_ver
detele_kernel_head
#headurl=https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/${sourceforge_xanmod_cacule_file_head}/download
#imgurl=https://sourceforge.net/projects/xanmod/files/releases/cacule/${sourceforge_xanmod_cacule_ver}/${sourceforge_xanmod_cacule_file_img}/download
#headurl=https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/${sourceforge_xanmod_lts_file_head}/download
#imgurl=https://sourceforge.net/projects/xanmod/files/releases/lts/${sourceforge_xanmod_lts_ver}/${sourceforge_xanmod_lts_file_img}/download
headurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep -v 'headers' | grep -v 'devel' | awk -F '"' '{print $4}')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers-d10.deb $headurl
wget -N -O linux-image-d10.deb $imgurl
dpkg -i linux-image-d10.deb
dpkg -i linux-headers-d10.deb
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
cd .. && rm -rf xanmod
BBR_grub
echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功,默认从排第一的高版本内核启动"
check_kernel
}
#安装bbr2内核 集成到xanmod内核了
#安装bbrplus 新内核
#2021.3.15 开始由https://github.com/UJX6N/bbrplus-5.19 替换bbrplusnew
#2021.4.12 地址更新为https://github.com/ylx2016/kernel/releases
#2021.9.2 再次改为https://github.com/UJX6N/bbrplus
#2022.9.6 改为https://github.com/UJX6N/bbrplus-5.19
#2022.11.24 改为https://github.com/UJX6N/bbrplus-6.x_stable
installbbrplusnew() {
github_ver_plus=$(curl -s https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases | grep /bbrplus-6.x_stable/releases/tag/ | head -1 | awk -F "[/]" '{print $8}' | awk -F "[\"]" '{print $1}')
github_ver_plus_num=$(curl -s https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases | grep /bbrplus-6.x_stable/releases/tag/ | head -1 | awk -F "[/]" '{print $8}' | awk -F "[\"]" '{print $1}' | awk -F "[-]" '{print $1}')
echo -e "获取的UJX6N的bbrplus-6.x_stable版本号为:${github_ver_plus}"
echo -e "如果下载地址出错,可能当前正在更新,超过半天还是出错请反馈,大陆自行解决污染问题"
echo -e "安装失败这边反馈,内核问题给UJX6N反馈"
# kernel_version=$github_ver_plus
bit=$(uname -m)
#if [[ ${bit} != "x86_64" ]]; then
# echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
#fi
rm -rf bbrplusnew
mkdir bbrplusnew && cd bbrplusnew || exit
if [[ "${release}" == "centos" ]]; then
if [[ ${version} == "7" ]]; then
if [[ ${bit} == "x86_64" ]]; then
#github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
#github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
#echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=${github_ver_plus_num}-bbrplus
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'rpm' | grep 'headers' | grep 'el7' | awk -F '"' '{print $4}' | grep 'http')
imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'rpm' | grep -v 'devel' | grep -v 'headers' | grep -v 'Source' | grep 'el7' | awk -F '"' '{print $4}' | grep 'http')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-c7.rpm $headurl
wget -N -O kernel-headers-c7.rpm $imgurl
yum install -y kernel-c7.rpm
yum install -y kernel-headers-c7.rpm
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
if [[ ${version} == "8" ]]; then
if [[ ${bit} == "x86_64" ]]; then
#github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Centos_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
#github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'rpm' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
#echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=${github_ver_plus_num}-bbrplus
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'rpm' | grep 'headers' | grep 'el8.x86_64' | grep 'https' | awk -F '"' '{print $4}' | grep 'http')
imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'rpm' | grep -v 'devel' | grep -v 'headers' | grep -v 'Source' | grep 'el8.x86_64' | grep 'https' | awk -F '"' '{print $4}' | grep 'http')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O kernel-c8.rpm $headurl
wget -N -O kernel-headers-c8.rpm $imgurl
yum install -y kernel-c8.rpm
yum install -y kernel-headers-c8.rpm
else
echo -e "${Error} 不支持x86_64以外的系统 !" && exit 1
fi
fi
elif [[ "${release}" == "debian" || "${release}" == "ubuntu" ]]; then
if [[ ${bit} == "x86_64" ]]; then
#github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
#github_ver=$(curl -s 'http s://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
#echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=${github_ver_plus_num}-bbrplus
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'https' | grep 'amd64.deb' | grep 'headers' | awk -F '"' '{print $4}' | grep 'http')
imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'https' | grep 'amd64.deb' | grep 'image' | awk -F '"' '{print $4}' | grep 'http')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers-d10.deb $headurl
wget -N -O linux-image-d10.deb $imgurl
dpkg -i linux-image-d10.deb
dpkg -i linux-headers-d10.deb
elif [[ ${bit} == "aarch64" ]]; then
#github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Ubuntu_Kernel' | grep '_latest_bbrplus_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}')
#github_ver=$(curl -s 'http s://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}')
#echo -e "获取的版本号为:${Green_font_prefix}${github_ver}${Font_color_suffix}"
kernel_version=${github_ver_plus_num}-bbrplus
detele_kernel_head
headurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'https' | grep 'arm64.deb' | grep 'headers' | awk -F '"' '{print $4}')
imgurl=$(curl -s 'https://api.github.com/repos/UJX6N/bbrplus-6.x_stable/releases' | grep ${github_ver_plus} | grep 'https' | grep 'arm64.deb' | grep 'image' | awk -F '"' '{print $4}')
headurl=$(check_cn $headurl)
imgurl=$(check_cn $imgurl)
echo -e "正在检查headers下载连接...."
checkurl $headurl
echo -e "正在检查内核下载连接...."
checkurl $imgurl
wget -N -O linux-headers-d10.deb $headurl
wget -N -O linux-image-d10.deb $imgurl
dpkg -i linux-image-d10.deb
dpkg -i linux-headers-d10.deb
else
echo -e "${Error} 不支持x86_64及arm64/aarch64以外的系统 !" && exit 1
fi
fi
cd .. && rm -rf bbrplusnew
BBR_grub
echo -e "${Tip} 内核安装完毕,请参考上面的信息检查是否安装成功,默认从排第一的高版本内核启动"
check_kernel
}
#启用BBR+fq
startbbrfq() {
remove_bbr_lotserver
echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR+FQ修改成功,重启生效!"
}
#启用BBR+fq_pie
startbbrfqpie() {
remove_bbr_lotserver
echo "net.core.default_qdisc=fq_pie" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR+FQ_PIE修改成功,重启生效!"
}
#启用BBR+cake
startbbrcake() {
remove_bbr_lotserver
echo "net.core.default_qdisc=cake" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR+cake修改成功,重启生效!"
}
#启用BBRplus
startbbrplus() {
remove_bbr_lotserver
echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbrplus" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBRplus修改成功,重启生效!"
}
#启用Lotserver
startlotserver() {
remove_bbr_lotserver
if [[ "${release}" == "centos" ]]; then
yum install ethtool -y
else
apt-get update || apt-get --allow-releaseinfo-change update
apt-get install ethtool -y
fi
#bash <(wget -qO- https://git.io/lotServerInstall.sh) install
#echo | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/1265578519/lotServer/main/lotServerInstall.sh) install
# echo | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/fei5seven/lotServer/master/lotServerInstall.sh) install
echo | bash <(wget --no-check-certificate -qO- https://raw.githubusercontent.com/wxlost/lotServer/master/lotServerInstall.sh) install
sed -i '/advinacc/d' /appex/etc/config
sed -i '/maxmode/d' /appex/etc/config
echo -e "advinacc=\"1\"
maxmode=\"1\"" >>/appex/etc/config
/appex/bin/lotServer.sh restart
start_menu
}
#启用BBR2+FQ
startbbr2fq() {
remove_bbr_lotserver
echo "net.core.default_qdisc=fq" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR2修改成功,重启生效!"
}
#启用BBR2+FQ_PIE
startbbr2fqpie() {
remove_bbr_lotserver
echo "net.core.default_qdisc=fq_pie" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR2修改成功,重启生效!"
}
#启用BBR2+CAKE
startbbr2cake() {
remove_bbr_lotserver
echo "net.core.default_qdisc=cake" >>/etc/sysctl.d/99-sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr2" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}BBR2修改成功,重启生效!"
}
#开启ecn
startecn() {
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
echo "net.ipv4.tcp_ecn=1" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}开启ecn结束!"
}
#关闭ecn
closeecn() {
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
echo "net.ipv4.tcp_ecn=0" >>/etc/sysctl.d/99-sysctl.conf
sysctl --system
echo -e "${Info}关闭ecn结束!"
}
#卸载bbr+锐速
remove_bbr_lotserver() {
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sysctl --system
rm -rf bbrmod
if [[ -e /appex/bin/lotServer.sh ]]; then
echo | bash <(wget -qO- https://raw.githubusercontent.com/fei5seven/lotServer/master/lotServerInstall.sh) uninstall
fi
clear
# echo -e "${Info}:清除bbr/lotserver加速完成。"
# sleep 1s
}
#卸载全部加速
remove_all() {
rm -rf /etc/sysctl.d/*.conf
#rm -rf /etc/sysctl.conf
#touch /etc/sysctl.conf
if [ ! -f "/etc/sysctl.conf" ]; then
touch /etc/sysctl.conf
else
cat /dev/null >/etc/sysctl.conf
fi
sysctl --system
sed -i '/DefaultTimeoutStartSec/d' /etc/systemd/system.conf
sed -i '/DefaultTimeoutStopSec/d' /etc/systemd/system.conf
sed -i '/DefaultRestartSec/d' /etc/systemd/system.conf
sed -i '/DefaultLimitCORE/d' /etc/systemd/system.conf
sed -i '/DefaultLimitNOFILE/d' /etc/systemd/system.conf
sed -i '/DefaultLimitNPROC/d' /etc/systemd/system.conf
sed -i '/soft nofile/d' /etc/security/limits.conf
sed -i '/hard nofile/d' /etc/security/limits.conf
sed -i '/soft nproc/d' /etc/security/limits.conf
sed -i '/hard nproc/d' /etc/security/limits.conf
sed -i '/ulimit -SHn/d' /etc/profile
sed -i '/ulimit -SHn/d' /etc/profile
sed -i '/required pam_limits.so/d' /etc/pam.d/common-session
systemctl daemon-reload
rm -rf bbrmod
sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/fs.file-max/d' /etc/sysctl.conf
sed -i '/net.core.rmem_max/d' /etc/sysctl.conf
sed -i '/net.core.wmem_max/d' /etc/sysctl.conf
sed -i '/net.core.rmem_default/d' /etc/sysctl.conf
sed -i '/net.core.wmem_default/d' /etc/sysctl.conf
sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_recycle/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.conf
sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.conf
sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
if [[ -e /appex/bin/lotServer.sh ]]; then
bash <(wget -qO- https://raw.githubusercontent.com/fei5seven/lotServer/master/lotServerInstall.sh) uninstall
fi
clear
echo -e "${Info}:清除加速完成。"
sleep 1s
}
#优化系统配置
optimizing_system() {
if [ ! -f "/etc/sysctl.conf" ]; then
touch /etc/sysctl.conf
fi
sed -i '/net.ipv4.tcp_retries2/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.conf
sed -i '/fs.file-max/d' /etc/sysctl.conf
sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.conf
sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.conf
sed -i '/net.ipv4.route.gc_timeout/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_syn_retries/d' /etc/sysctl.conf
sed -i '/net.core.somaxconn/d' /etc/sysctl.conf
sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.conf
sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf
echo "net.ipv4.tcp_retries2 = 8
net.ipv4.tcp_slow_start_after_idle = 0
fs.file-max = 1000000
fs.inotify.max_user_instances = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 32768
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_orphans = 32768
# forward ipv4
#net.ipv4.ip_forward = 1" >>/etc/sysctl.conf
sysctl -p
echo "* soft nofile 1000000
* hard nofile 1000000" >/etc/security/limits.conf
echo "ulimit -SHn 1000000" >>/etc/profile
read -p "需要重启VPS后,才能生效系统优化配置,是否现在重启 ? [Y/n] :" yn
[ -z "${yn}" ] && yn="y"
if [[ $yn == [Yy] ]]; then
echo -e "${Info} VPS 重启中..."
reboot
fi
}
optimizing_system_johnrosen1() {
if [ ! -f "/etc/sysctl.d/99-sysctl.conf" ]; then
touch /etc/sysctl.d/99-sysctl.conf
fi
sed -i '/net.ipv4.tcp_fack/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_early_retrans/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.neigh.default.unres_qlen/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_max_orphans/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_buckets/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/kernel.pid_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/vm.nr_hugepages/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.optmem_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.route_localnet/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.all.forwarding/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.default.forwarding/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.lo.forwarding/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.default.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.lo.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.all.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.default.accept_ra/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.netdev_max_backlog/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.netdev_budget/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.netdev_budget_usecs/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/fs.file-max /d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.rmem_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.wmem_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.rmem_default/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.wmem_default/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.somaxconn/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.icmp_echo_ignore_all/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.icmp_echo_ignore_broadcasts/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.icmp_ignore_bogus_error_responses/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.secure_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.send_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.rp_filter/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_keepalive_time/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_keepalive_intvl/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_keepalive_probes/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_synack_retries/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_syncookies/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_rfc1337/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_timestamps/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_fin_timeout/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.ip_local_port_range/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_max_tw_buckets/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_fastopen/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_rmem/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_wmem/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.udp_rmem_min/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.udp_wmem_min/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.arp_ignore /d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.arp_ignore/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.all.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.conf.default.arp_announce/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_autocorking/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_slow_start_after_idle/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_max_syn_backlog/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_notsent_lowat/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_no_metrics_save/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_ecn/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_ecn_fallback/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_frto/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.all.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.conf.default.accept_redirects/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/vm.swappiness/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.ip_unprivileged_port_start/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/vm.overcommit_memory/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.neigh.default.gc_thresh3/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.neigh.default.gc_thresh2/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv6.neigh.default.gc_thresh1/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.nf_conntrack_max/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_tcp_timeout_fin_wait/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_tcp_timeout_time_wait/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_tcp_timeout_close_wait/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.netfilter.nf_conntrack_tcp_timeout_established/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/fs.inotify.max_user_instances/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/fs.inotify.max_user_watches/d' /etc/sysctl.d/99-sysctl.conf
sed -i '/net.ipv4.tcp_low_latency/d' /etc/sysctl.d/99-sysctl.conf
cat >'/etc/sysctl.d/99-sysctl.conf' <<EOF
net.ipv4.tcp_fack = 1
net.ipv4.tcp_early_retrans = 3
net.ipv4.neigh.default.unres_qlen=10000
net.ipv4.conf.all.route_localnet=1
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
#net.ipv6.conf.all.forwarding = 1 #awsipv6问题
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.lo.forwarding = 1
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.accept_ra = 2
net.core.netdev_max_backlog = 100000
net.core.netdev_budget = 50000
net.core.netdev_budget_usecs = 5000
#fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.rmem_default = 67108864
net.core.wmem_default = 67108864
net.core.optmem_max = 65536
net.core.somaxconn = 1000000
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_keepalive_probes = 2
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.udp_rmem_min = 8192
net.ipv4.udp_wmem_min = 8192
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_autocorking = 0
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_max_syn_backlog = 819200
net.ipv4.tcp_notsent_lowat = 16384
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_ecn = 1
net.ipv4.tcp_ecn_fallback = 1
net.ipv4.tcp_frto = 0