forked from 52fancy/GooGle-BBR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBBR.sh
91 lines (79 loc) · 2.58 KB
/
BBR.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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
rm -f $0
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root to install BBR"
exit
fi
clear
echo "+------------------------------------------------------------------------+"
echo "| GooGle TCP BBR |"
echo "+------------------------------------------------------------------------+"
echo "| A tool to auto-compile & install BBR on CentOS |"
echo "+------------------------------------------------------------------------+"
echo "| Welcome to http://github.com/52fancy |"
echo "+------------------------------------------------------------------------+"
if [ ! -f "/boot/grub/grub.conf" ];then
echo "不支持当前系统,即将退出程序!"
exit
fi
Get_RHEL_Version()
{
if grep -Eqi "release 5." /etc/redhat-release; then
RHEL_Version='5'
elif grep -Eqi "release 6." /etc/redhat-release; then
RHEL_Version='6'
elif grep -Eqi "release 7." /etc/redhat-release; then
RHEL_Version='7'
fi
}
Get_OS_Bit()
{
if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then
OS_Bit='64'
else
OS_Bit='32'
fi
}
Get_RHEL_Version
if [ $RHEL_Version != "6" ]; then
echo "Error: You must be CentOS 6 to run this script, please use CentOS 6 to install BBR"
exit
fi
Install()
{
if lsmod | grep -Eqi "bbr"; then
echo "您已经成功安装BBR"
exit
else
read -p "即将升级内核?[Y]:" is_update
if [[ ${is_update} == "y" || ${is_update} == "Y" ]]; then
Get_OS_Bit
if [ $OS_Bit = "64" ]; then
rpm -ivh https://github.com/52fancy/GooGle-BBR/raw/master/kernel/kernel-4.10.el6.x86_64.rpm --force
fi
if [ $OS_Bit = "32" ]; then
rpm -ivh https://github.com/52fancy/GooGle-BBR/raw/master/kernel/kernel-4.10.el6.i686.rpm --force
fi
sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
sysctl -p >/dev/null 2>&1
read -p "重启后生效,是否重启?[Y]:" is_reboot
if [[ ${is_reboot} == "y" || ${is_reboot} == "Y" ]]; then
reboot
else
exit
fi
else
echo "程序即将退出安装"
exit
fi
fi
}
Install
exit