forked from affvps/shell_for_ss_ssr_ssrr_kcptun_bbr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbr.init
executable file
·108 lines (97 loc) · 2.22 KB
/
bbr.init
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
#!/bin/bash
# chkconfig: 2345 90 10
# description: This commit implements a new TCP congestion control algorithm: BBR (Bottleneck Bandwidth and RTT)
### BEGIN INIT INFO
# Provides: BBR
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Bottleneck Bandwidth and RTT
# Description: Start or stop the BBR server
### END INIT INFO
NAME="BBR"
BIN=/usr/bin/rinetd-bbr
CONF=/etc/rinetd-bbr/bbr.conf
version="1.0"
RETVAL=0
[ -x ${BIN} ] || exit 0
if [ ! -r ${CONF} ]; then
echo "config file ${CONF} not found!"
exit 1
fi
check_running(){
PID=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [ ! -z $PID ]; then
return 0
else
return 1
fi
}
do_start(){
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is already running!"
exit 0
else
echo "starting BBR..."
#nohup $BIN -f -c $CONF raw venet0:0 >/dev/null 2>&1 &
$BIN -f -c $CONF raw venet0:0 >/dev/null 2>&1 &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
sleep 0.3
check_running
echo "Starting $NAME success!pid:$PID ."
else
echo "Starting $NAME failed!"
fi
fi
}
do_stop(){
check_running
if [ $? -eq 0 ]; then
echo "stopping BBR with pid:$PID..."
kill -9 $PID
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "Stopping $NAME success!"
else
echo "Stopping $NAME failed!"
fi
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_status(){
check_running
if [ $? -eq 0 ]; then
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
RETVAL=1
fi
}
do_restart(){
do_stop
do_start
}
do_config(){
vi ${CONF}
}
do_viewconfig(){
cat ${CONF}
echo
}
case "$1" in
start|stop|restart|status|config|viewconfig)
do_$1
;;
[vV][eE][rR][sS][iI][oO][nN]|-[vV][eE][rR][sS][iI][oO][nN]|--[vV][eE][rR][sS][iI][oO][nN]|-[vV]|--[vV])
;;
*)
echo "Usage: $0 { start | stop | restart | status | config | viewconfig }"
RETVAL=1
;;
esac
exit $RETVAL