-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathinstall.sh
executable file
·56 lines (45 loc) · 1.36 KB
/
install.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
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: ./install.sh <algo>"
echo "<algo>: bbr | tsunami | nanqinlang"
exit 1
fi
algo=$1
bbr_file=tcp_$1
bbr_src=$bbr_file.c
bbr_obj=$bbr_file.o
bbr_kernelobj=$bbr_file.ko
gcc_version=$(gcc --version | grep ^gcc | sed 's/^.* //g')
include_path="ccflags-y=-I/usr/lib/gcc/x86_64-linux-gnu/$gcc_version/include"
if [ ! -f "./$bbr_src" ]; then
echo "$bbr_src not found! Please download from https://github.com/KozakaiAya/TCP_BBR first"
exit 1
fi
if [ $(id -u) -ne 0 ]; then
echo "Cowardly refuse to continue without root permission"
exit 1
fi
echo "===== Start Compilation: $bbr_file ====="
echo "obj-m:=$bbr_obj" > Makefile
echo "$include_path" >> Makefile
make -C /lib/modules/$(uname -r)/build M=`pwd` modules CC=/usr/bin/gcc
if [ ! -f "./$bbr_kernelobj"]; then
echo "Build failed, please check your environment"
exit 1
fi
echo "===== Start Installation: $bbr_file ====="
cp $bbr_kernelobj /lib/modules/$(uname -r)/kernel/drivers/
echo "$bbr_file" | sudo tee -a /etc/modules
depmod
modprobe "$bbr_file"
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=$algo" >> /etc/sysctl.conf
sysctl -p
ret=$?
if [ $ret -eq 0 ]; then
echo "===== Installation succeeded, enjoy! ====="
exit 0
else
echo "Something went wrong, please check your environment"
exit 1
fi