-
Notifications
You must be signed in to change notification settings - Fork 163
/
bbr_c9.sh
107 lines (94 loc) · 3.06 KB
/
bbr_c9.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
#!/bin/bash
cat << "EOF"
BBR configuration script for RHEL/CentOS Stream 9/Rocky Linux/AlmaLinux x86_64
Author: M1Screw
Github: https://github.com/M1Screw/Airport-toolkit
Usage:
./bbr_c9.sh mainline --> Install mainline kernel and enable BBR
./bbr_c9.sh bbr --> Enable BBR
./bbr_c9.sh status --> Check BBR and kernel status
./bbr_c9.sh update --> Update the mainline kernel
EOF
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script!"; exit 1; }
do_elrepo(){
echo "Install and configure the elrepo"
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
yum install -y https://www.elrepo.org/elrepo-release-9.el9.elrepo.noarch.rpm
}
do_kernel(){
echo "Install mainline kernel"
yum --enablerepo=elrepo-kernel install kernel-ml -y
grub2-set-default 0
}
do_headers(){
echo "Install mainline kernel-headers and clean the default one"
yum remove kernel-headers -y
yum --enablerepo=elrepo-kernel install kernel-ml-headers -y
}
do_tools(){
echo "Install mainline kernel-tools and clean the default one"
yum remove kernel-tools kernel-tools-libs -y
yum --enablerepo=elrepo-kernel install kernel-ml-tools kernel-ml-tools-libs -y
}
do_enable_bbr(){
echo "Enable BBR module"
modprobe tcp_bbr
echo "tcp_bbr" | tee --append /etc/modules-load.d/modules.conf
echo "Configure BBR in sysctl.conf"
echo "net.core.default_qdisc=fq" | tee --append /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | tee --append /etc/sysctl.conf
sysctl -p
}
do_status_check(){
echo "Current running kernel:\n"
uname -r
echo "===================================="
echo "BBR module status:\n"
lsmod | grep bbr
echo "===================================="
echo "Available IPv4 Congestion Control:\n"
sysctl net.ipv4.tcp_available_congestion_control
echo "===================================="
echo "Active IPv4 Congestion Control:\n"
sysctl net.ipv4.tcp_congestion_control
echo "===================================="
echo "Installed kernel packages:\n"
rpm -qa | grep kernel
echo "===================================="
echo "System booting kernel options:\n"
ls -l /boot/vmlinuz-*
}
do_update_kernel(){
echo "Upgrade kernel and related packages"
yum --enablerepo=elrepo-kernel update kernel-ml kernel-ml-headers kernel-ml-tools-libs -y
}
do_reboot(){
echo "System require a reboot to complete the mainline kernel installation process, press Y to continue, or press any key else to exit this script."
read is_reboot
if [[ ${is_reboot} == "y" || ${is_reboot} == "Y" ]]; then
reboot
else
echo "Reboot has been canceled..."
exit 0
fi
}
if [[ $1 == "status" ]]; then
do_status_check
exit 0
fi
if [[ $1 == "bbr" ]]; then
do_enable_bbr
exit 0
fi
if [[ $1 == "update" ]]; then
do_update_kernel
exit 0
fi
if [[ $1 == "mainline" ]]; then
do_elrepo
do_kernel
do_headers
do_tools
do_enable_bbr
do_reboot
fi