Skip to content
This repository was archived by the owner on Apr 12, 2020. It is now read-only.

Commit cb869bf

Browse files
authored
add nocheckvirt up
1 parent 4ea2dbd commit cb869bf

4 files changed

+566
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
#!/bin/bash
2+
Green_font="\033[32m" && Red_font="\033[31m" && Font_suffix="\033[0m"
3+
Info="${Green_font}[Info]${Font_suffix}"
4+
Error="${Red_font}[Error]${Font_suffix}"
5+
echo -e "${Green_font}
6+
#===============================================
7+
# Project: tcp_nanqinlang
8+
# Description: --centos --rinetd --multiNIC
9+
# Version: based on linhua's origin
10+
# Origin: https://github.com/linhua55/lkl_study
11+
# Author: linhua && nanqinlang
12+
# Blog: https://sometimesnaive.org
13+
# Github: https://github.com/nanqinlang
14+
#===============================================
15+
${Font_suffix}"
16+
17+
check_system(){
18+
#sort
19+
[[ -z "`cat /etc/redhat-release | grep -iE "CentOS"`" ]] && echo -e "${Error} only support CentOS !" && exit 1
20+
#bit
21+
[[ "`uname -m`" != "x86_64" ]] && echo -e "${Error} only support 64bit !" && exit 1
22+
}
23+
24+
check_root(){
25+
[[ "`id -u`" != "0" ]] && echo -e "${Error} must be root user !" && exit 1
26+
}
27+
28+
check_ovz(){
29+
yum update && yum install -y virt-what
30+
[[ "`virt-what`" != "openvz" ]] && echo -e "${Error} only support OpenVZ !" && exit 1
31+
}
32+
33+
check_requirement(){
34+
# check iptables
35+
yum install -y iptables
36+
37+
# check "iptables grep cut xargs ip awk"
38+
for CMD in iptables grep cut xargs ip awk
39+
do
40+
if ! type -p ${CMD}; then
41+
echo -e "${Error} requirement not found, please check !" && exit 1
42+
fi
43+
done
44+
}
45+
46+
directory(){
47+
[[ ! -d /home/tcp_nanqinlang ]] && mkdir -p /home/tcp_nanqinlang
48+
cd /home/tcp_nanqinlang
49+
}
50+
51+
download(){
52+
wget https://raw.githubusercontent.com/nanqinlang-tcp/tcp_nanqinlang/master/Rinetd/module/rinetd
53+
[[ ! -f rinetd ]] && echo -e "${Error} rinetd download failed, please check !" && exit 1
54+
chmod +x rinetd
55+
}
56+
57+
config-port(){
58+
echo -e "${Info} 输入你想加速的端口"
59+
read -p "(多个端口号用空格隔开。不支持端口段。默认使用 8080):" ports
60+
61+
if [[ -z "${ports}" ]]; then
62+
echo -e "0.0.0.0 8080 0.0.0.0 8080\c" >> config-port.conf
63+
else
64+
for port in ${ports}
65+
do
66+
echo "0.0.0.0 ${port} 0.0.0.0 ${port}" >> config-port.conf
67+
done
68+
fi
69+
}
70+
71+
config-rinetd(){
72+
#IFACE=`ip -4 addr | awk '{if ($1 ~ /inet/ && $NF ~ /^[ve]/) {a=$NF}} END{print a}'`
73+
74+
# multi NIC
75+
IFACES=`ip -4 addr | grep "global" | awk '{print $7}'`
76+
if [[ ! -z ${IFACES} ]]; then
77+
echo -e "#!/bin/bash \ncd /home/tcp_nanqinlang \nnohup ./rinetd -f -c config-port.conf raw\c" > config-rinetd.sh
78+
for IFACE in ${IFACES}
79+
do
80+
if [[ ! -z ${IFACE} ]]; then
81+
echo -e " ${IFACE}\c" >> config-rinetd.sh
82+
fi
83+
done
84+
echo -e " &" >> config-rinetd.sh
85+
chmod +x config-rinetd.sh
86+
fi
87+
}
88+
89+
self-start(){
90+
sed -i "s/exit 0/ /ig" /etc/rc.d/rc.local
91+
echo -e "\n/home/tcp_nanqinlang/config-rinetd.sh\c" >> /etc/rc.d/rc.local
92+
chmod +x /etc/rc.d/rc.local
93+
}
94+
95+
run-it-now(){
96+
./config-rinetd.sh
97+
}
98+
99+
install(){
100+
check_system
101+
check_root
102+
check_ovz
103+
check_requirement
104+
directory
105+
download
106+
config-port
107+
config-rinetd
108+
self-start
109+
run-it-now
110+
status
111+
}
112+
113+
status(){
114+
if [[ ! -z `ps -A | grep rinetd` ]]; then
115+
echo -e "${Info} tcp_nanqinlang is running !"
116+
else echo -e "${Error} tcp_nanqinlang not running, please check !"
117+
fi
118+
}
119+
120+
uninstall(){
121+
check_root
122+
kill -9 `ps -A | grep rinetd | awk '{print $1}'`
123+
rm -rf /home/tcp_nanqinlang
124+
iptables -t raw -F
125+
sed -i '/\/home\/tcp_nanqinlang\/config-rinetd.sh/d' /etc/rc.d/rc.local
126+
echo -e "${Info} uninstall finished."
127+
}
128+
129+
130+
131+
echo -e "${Info} 选择你要使用的功能: "
132+
echo -e "1.安装 rinetd-bbr\n2.检查 rinetd-bbr 运行状态\n3.卸载 rinetd-bbr"
133+
read -p "输入数字以选择:" function
134+
135+
while [[ ! "${function}" =~ ^[1-3]$ ]]
136+
do
137+
echo -e "${Error} 无效输入"
138+
echo -e "${Info} 请重新选择" && read -p "输入数字以选择:" function
139+
done
140+
141+
if [[ "${function}" == "1" ]]; then
142+
install
143+
elif [[ "${function}" == "2" ]]; then
144+
status
145+
else
146+
uninstall
147+
fi
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
Green_font="\033[32m" && Red_font="\033[31m" && Font_suffix="\033[0m"
3+
Info="${Green_font}[Info]${Font_suffix}"
4+
Error="${Red_font}[Error]${Font_suffix}"
5+
echo -e "${Green_font}
6+
#===============================================
7+
# Project: tcp_nanqinlang
8+
# Description: --centos --rinetd --singleNIC
9+
# Version: based on linhua's origin
10+
# Origin: https://github.com/linhua55/lkl_study
11+
# Author: linhua && nanqinlang
12+
# Blog: https://sometimesnaive.org
13+
# Github: https://github.com/nanqinlang
14+
#===============================================
15+
${Font_suffix}"
16+
17+
check_system(){
18+
#sort
19+
[[ -z "`cat /etc/redhat-release | grep -iE "CentOS"`" ]] && echo -e "${Error} only support CentOS !" && exit 1
20+
#bit
21+
[[ "`uname -m`" != "x86_64" ]] && echo -e "${Error} only support 64bit !" && exit 1
22+
}
23+
24+
check_root(){
25+
[[ "`id -u`" != "0" ]] && echo -e "${Error} must be root user !" && exit 1
26+
}
27+
28+
check_ovz(){
29+
yum update && yum install -y virt-what
30+
[[ "`virt-what`" != "openvz" ]] && echo -e "${Error} only support OpenVZ !" && exit 1
31+
}
32+
33+
check_requirement(){
34+
# check iptables
35+
yum install -y iptables
36+
37+
# check "iptables grep cut xargs ip awk"
38+
for CMD in iptables grep cut xargs ip awk
39+
do
40+
if ! type -p ${CMD}; then
41+
echo -e "${Error} requirement not found, please check !" && exit 1
42+
fi
43+
done
44+
}
45+
46+
directory(){
47+
[[ ! -d /home/tcp_nanqinlang ]] && mkdir -p /home/tcp_nanqinlang
48+
cd /home/tcp_nanqinlang
49+
}
50+
51+
download(){
52+
wget https://raw.githubusercontent.com/nanqinlang-tcp/tcp_nanqinlang/master/Rinetd/module/rinetd
53+
[[ ! -f rinetd ]] && echo -e "${Error} rinetd download failed, please check !" && exit 1
54+
chmod +x rinetd
55+
}
56+
57+
config-port(){
58+
echo -e "${Info} 输入你想加速的端口"
59+
read -p "(多个端口号用空格隔开。不支持端口段。默认使用 8080):" ports
60+
61+
if [[ -z "${ports}" ]]; then
62+
echo -e "0.0.0.0 8080 0.0.0.0 8080\c" >> config-port.conf
63+
else
64+
for port in ${ports}
65+
do
66+
echo "0.0.0.0 ${port} 0.0.0.0 ${port}" >> config-port.conf
67+
done
68+
fi
69+
}
70+
71+
config-rinetd(){
72+
IFACE=`ip -4 addr | awk '{if ($1 ~ /inet/ && $NF ~ /^[ve]/) {a=$NF}} END{print a}'`
73+
echo -e "#!/bin/bash \n cd /home/tcp_nanqinlang \n nohup ./rinetd -f -c config-port.conf raw ${IFACE} &" >> config-rinetd.sh && chmod +x config-rinetd.sh
74+
}
75+
76+
self-start(){
77+
sed -i "s/exit 0/ /ig" /etc/rc.d/rc.local
78+
echo -e "\n/home/tcp_nanqinlang/config-rinetd.sh\c" >> /etc/rc.d/rc.local
79+
chmod +x /etc/rc.d/rc.local
80+
}
81+
82+
run-it-now(){
83+
./config-rinetd.sh
84+
}
85+
86+
install(){
87+
check_system
88+
check_root
89+
check_ovz
90+
check_requirement
91+
directory
92+
download
93+
config-port
94+
config-rinetd
95+
self-start
96+
run-it-now
97+
status
98+
}
99+
100+
status(){
101+
if [[ ! -z `ps -A | grep rinetd` ]]; then
102+
echo -e "${Info} tcp_nanqinlang is running !"
103+
else echo -e "${Error} tcp_nanqinlang not running, please check !"
104+
fi
105+
}
106+
107+
uninstall(){
108+
check_root
109+
kill -9 `ps -A | grep rinetd | awk '{print $1}'`
110+
rm -rf /home/tcp_nanqinlang
111+
iptables -t raw -F
112+
sed -i '/\/home\/tcp_nanqinlang\/config-rinetd.sh/d' /etc/rc.d/rc.local
113+
echo -e "${Info} uninstall finished."
114+
}
115+
116+
117+
118+
echo -e "${Info} 选择你要使用的功能: "
119+
echo -e "1.安装 rinetd-bbr\n2.检查 rinetd-bbr 运行状态\n3.卸载 rinetd-bbr"
120+
read -p "输入数字以选择:" function
121+
122+
while [[ ! "${function}" =~ ^[1-3]$ ]]
123+
do
124+
echo -e "${Error} 无效输入"
125+
echo -e "${Info} 请重新选择" && read -p "输入数字以选择:" function
126+
done
127+
128+
if [[ "${function}" == "1" ]]; then
129+
install
130+
elif [[ "${function}" == "2" ]]; then
131+
status
132+
else
133+
uninstall
134+
fi

0 commit comments

Comments
 (0)