forked from oooldking/script
-
Notifications
You must be signed in to change notification settings - Fork 223
/
superspeed.sh
415 lines (386 loc) · 16.6 KB
/
superspeed.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#!/usr/bin/env bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
PURPLE="\033[0;35m"
CYAN='\033[0;36m'
PLAIN='\033[0m'
checkroot(){
[[ $EUID -ne 0 ]] && echo -e "${RED}请使用 root 用户运行本脚本!${PLAIN}" && exit 1
}
checksystem() {
if [ -f /etc/redhat-release ]; then
release="centos"
elif cat /etc/issue | grep -Eqi "debian"; then
release="debian"
elif cat /etc/issue | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
release="centos"
elif cat /proc/version | grep -Eqi "debian"; then
release="debian"
elif cat /proc/version | grep -Eqi "ubuntu"; then
release="ubuntu"
elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
release="centos"
fi
}
checkpython() {
if [ ! -e '/usr/bin/python' ]; then
echo "正在安装 Python"
if [ "${release}" == "centos" ]; then
yum update > /dev/null 2>&1
yum -y install python > /dev/null 2>&1
else
apt-get update > /dev/null 2>&1
apt-get -y install python > /dev/null 2>&1
fi
fi
}
checkcurl() {
if [ ! -e '/usr/bin/curl' ]; then
echo "正在安装 Curl"
if [ "${release}" == "centos" ]; then
yum update > /dev/null 2>&1
yum -y install curl > /dev/null 2>&1
else
apt-get update > /dev/null 2>&1
apt-get -y install curl > /dev/null 2>&1
fi
fi
}
checkwget() {
if [ ! -e '/usr/bin/wget' ]; then
echo "正在安装 Wget"
if [ "${release}" == "centos" ]; then
yum update > /dev/null 2>&1
yum -y install wget > /dev/null 2>&1
else
apt-get update > /dev/null 2>&1
apt-get -y install wget > /dev/null 2>&1
fi
fi
}
checkspeedtest() {
if [ ! -e './speedtest-cli/speedtest' ]; then
echo "正在安装 Speedtest-cli"
wget --no-check-certificate -qO speedtest.tgz https://bintray.com/ookla/download/download_file?file_path=ookla-speedtest-1.0.0-$(uname -m)-linux.tgz > /dev/null 2>&1
fi
mkdir -p speedtest-cli && tar zxvf speedtest.tgz -C ./speedtest-cli/ > /dev/null 2>&1 && chmod a+rx ./speedtest-cli/speedtest
}
speed_test(){
speedLog="./speedtest.log"
true > $speedLog
speedtest-cli/speedtest -p no -s $1 --accept-license > $speedLog 2>&1
is_upload=$(cat $speedLog | grep 'Upload')
if [[ ${is_upload} ]]; then
local REDownload=$(cat $speedLog | awk -F ' ' '/Download/{print $3}')
local reupload=$(cat $speedLog | awk -F ' ' '/Upload/{print $3}')
local relatency=$(cat $speedLog | awk -F ' ' '/Latency/{print $2}')
local nodeID=$1
local nodeLocation=$2
local nodeISP=$3
strnodeLocation="${nodeLocation} "
LANG=C
#echo $LANG
temp=$(echo "${REDownload}" | awk -F ' ' '{print $1}')
if [[ $(awk -v num1=${temp} -v num2=0 'BEGIN{print(num1>num2)?"1":"0"}') -eq 1 ]]; then
printf "${RED}%-6s${YELLOW}%s%s${GREEN}%-24s${CYAN}%s%-10s${BLUE}%s%-10s${PURPLE}%-8s${PLAIN}\n" "${nodeID}" "${nodeISP}" "|" "${strnodeLocation:0:24}" "↑ " "${reupload}" "↓ " "${REDownload}" "${relatency}" | tee -a $log
fi
else
local cerror="ERROR"
fi
}
preinfo() {
echo "———————————————————SuperSpeed 全面测速版——————————————————"
echo " bash <(curl -Lso- https://git.io/superspeed)"
echo " 全部节点列表: https://git.io/superspeedList"
echo " 节点更新: 2020/04/09 | 脚本更新: 2020/04/09"
echo "——————————————————————————————————————————————————————————"
}
selecttest() {
echo -e " 测速类型: ${GREEN}1.${PLAIN} 三网测速 ${GREEN}2.${PLAIN} 取消测速"
echo -ne " ${GREEN}3.${PLAIN} 电信节点 ${GREEN}4.${PLAIN} 联通节点 ${GREEN}5.${PLAIN} 移动节点"
while :; do echo
read -p " 请输入数字选择测速类型: " selection
if [[ ! $selection =~ ^[1-5]$ ]]; then
echo -ne " ${RED}输入错误${PLAIN}, 请输入正确的数字!"
else
break
fi
done
}
runtest() {
[[ ${selection} == 2 ]] && exit 1
if [[ ${selection} == 1 ]]; then
echo "——————————————————————————————————————————————————————————"
echo "ID 测速服务器信息 上传/Mbps 下载/Mbps 延迟/ms"
start=$(date +%s)
speed_test '3633' '上海' '电信'
speed_test '24012' '内蒙古呼和浩特' '电信'
speed_test '27377' '北京5G' '电信'
speed_test '29026' '四川成都' '电信'
# speed_test '29071' '四川成都' '电信'
speed_test '17145' '安徽合肥5G' '电信'
speed_test '27594' '广东广州5G' '电信'
# speed_test '27810' '广西南宁' '电信'
speed_test '27575' '新疆乌鲁木齐' '电信'
# speed_test '26352' '江苏南京5G' '电信'
speed_test '5396' '江苏苏州5G' '电信'
# speed_test '5317' '江苏连云港5G' '电信'
# speed_test '7509' '浙江杭州' '电信'
speed_test '23844' '湖北武汉' '电信'
speed_test '29353' '湖北武汉5G' '电信'
speed_test '28225' '湖南长沙5G' '电信'
speed_test '3973' '甘肃兰州' '电信'
# speed_test '19076' '重庆' '电信'
#***
# speed_test '21005' '上海' '联通'
speed_test '24447' '上海5G' '联通'
# speed_test '5103' '云南昆明' '联通'
speed_test '5145' '北京' '联通'
# speed_test '5505' '北京' '联通'
# speed_test '9484' '吉林长春' '联通'
speed_test '2461' '四川成都' '联通'
speed_test '27154' '天津5G' '联通'
# speed_test '5509' '宁夏银川' '联通'
# speed_test '5724' '安徽合肥' '联通'
# speed_test '5039' '山东济南' '联通'
speed_test '26180' '山东济南5G' '联通'
speed_test '26678' '广东广州5G' '联通'
# speed_test '16192' '广东深圳' '联通'
# speed_test '6144' '新疆乌鲁木齐' '联通'
speed_test '13704' '江苏南京' '联通'
speed_test '5485' '湖北武汉' '联通'
# speed_test '26677' '湖南株洲' '联通'
speed_test '4870' '湖南长沙' '联通'
# speed_test '4690' '甘肃兰州' '联通'
# speed_test '4884' '福建福州' '联通'
# speed_test '31985' '重庆' '联通'
speed_test '4863' '陕西西安' '联通'
#***
# speed_test '30154' '上海' '移动'
# speed_test '25637' '上海5G' '移动'
# speed_test '26728' '云南昆明' '移动'
# speed_test '27019' '内蒙古呼和浩特' '移动'
speed_test '30232' '内蒙呼和浩特5G' '移动'
# speed_test '30293' '内蒙古通辽5G' '移动'
speed_test '25858' '北京' '移动'
speed_test '16375' '吉林长春' '移动'
# speed_test '24337' '四川成都' '移动'
speed_test '17184' '天津5G' '移动'
# speed_test '26940' '宁夏银川' '移动'
# speed_test '31815' '宁夏银川' '移动'
# speed_test '26404' '安徽合肥5G' '移动'
speed_test '27151' '山东临沂5G' '移动'
# speed_test '25881' '山东济南5G' '移动'
# speed_test '27100' '山东青岛5G' '移动'
# speed_test '26501' '山西太原5G' '移动'
speed_test '31520' '广东中山' '移动'
# speed_test '6611' '广东广州' '移动'
# speed_test '4515' '广东深圳' '移动'
# speed_test '15863' '广西南宁' '移动'
# speed_test '16858' '新疆乌鲁木齐' '移动'
speed_test '26938' '新疆乌鲁木齐5G' '移动'
# speed_test '17227' '新疆和田' '移动'
# speed_test '17245' '新疆喀什' '移动'
# speed_test '17222' '新疆阿勒泰' '移动'
# speed_test '27249' '江苏南京5G' '移动'
# speed_test '21845' '江苏常州5G' '移动'
# speed_test '26850' '江苏无锡5G' '移动'
# speed_test '17320' '江苏镇江5G' '移动'
speed_test '25883' '江西南昌5G' '移动'
# speed_test '17223' '河北石家庄' '移动'
# speed_test '26331' '河南郑州5G' '移动'
# speed_test '6715' '浙江宁波5G' '移动'
# speed_test '4647' '浙江杭州' '移动'
# speed_test '16503' '海南海口' '移动'
# speed_test '28491' '湖南长沙5G' '移动'
# speed_test '16145' '甘肃兰州' '移动'
speed_test '16171' '福建福州' '移动'
# speed_test '18444' '西藏拉萨' '移动'
speed_test '16398' '贵州贵阳' '移动'
speed_test '25728' '辽宁大连' '移动'
# speed_test '16167' '辽宁沈阳' '移动'
# speed_test '17584' '重庆' '移动'
# speed_test '26380' '陕西西安' '移动'
# speed_test '29105' '陕西西安5G' '移动'
# speed_test '29083' '青海西宁5G' '移动'
# speed_test '26656' '黑龙江哈尔滨' '移动'
end=$(date +%s)
rm -rf speedtest*
echo "——————————————————————————————————————————————————————————"
time=$(( $end - $start ))
if [[ $time -gt 60 ]]; then
min=$(expr $time / 60)
sec=$(expr $time % 60)
echo -ne " 测试完成, 本次测速耗时: ${min} 分 ${sec} 秒"
else
echo -ne " 测试完成, 本次测速耗时: ${time} 秒"
fi
echo -ne "\n 当前时间: "
echo $(date +%Y-%m-%d" "%H:%M:%S)
echo -e " ${GREEN}# 三网测速中为避免节点数不均及测试过久,每部分未使用所${PLAIN}"
echo -e " ${GREEN}# 有节点,如果需要使用全部节点,可分别选择三网节点检测${PLAIN}"
fi
if [[ ${selection} == 3 ]]; then
echo "——————————————————————————————————————————————————————————"
echo "ID 测速服务器信息 上传/Mbps 下载/Mbps 延迟/ms"
start=$(date +%s)
speed_test '3633' '上海' '电信'
speed_test '24012' '内蒙古呼和浩特' '电信'
speed_test '27377' '北京5G' '电信'
speed_test '29026' '四川成都' '电信'
speed_test '29071' '四川成都' '电信'
speed_test '17145' '安徽合肥5G' '电信'
speed_test '27594' '广东广州5G' '电信'
speed_test '27810' '广西南宁' '电信'
speed_test '27575' '新疆乌鲁木齐' '电信'
speed_test '26352' '江苏南京5G' '电信'
speed_test '5396' '江苏苏州5G' '电信'
speed_test '5317' '江苏连云港5G' '电信'
speed_test '7509' '浙江杭州' '电信'
speed_test '23844' '湖北武汉' '电信'
speed_test '29353' '湖北武汉5G' '电信'
speed_test '28225' '湖南长沙5G' '电信'
speed_test '3973' '甘肃兰州' '电信'
speed_test '19076' '重庆' '电信'
end=$(date +%s)
rm -rf speedtest*
echo "——————————————————————————————————————————————————————————"
time=$(( $end - $start ))
if [[ $time -gt 60 ]]; then
min=$(expr $time / 60)
sec=$(expr $time % 60)
echo -ne " 测试完成, 本次测速耗时: ${min} 分 ${sec} 秒"
else
echo -ne " 测试完成, 本次测速耗时: ${time} 秒"
fi
echo -ne "\n 当前时间: "
echo $(date +%Y-%m-%d" "%H:%M:%S)
fi
if [[ ${selection} == 4 ]]; then
echo "——————————————————————————————————————————————————————————"
echo "ID 测速服务器信息 上传/Mbps 下载/Mbps 延迟/ms"
start=$(date +%s)
speed_test '21005' '上海' '联通'
speed_test '24447' '上海5G' '联通'
speed_test '5103' '云南昆明' '联通'
speed_test '5145' '北京' '联通'
speed_test '5505' '北京' '联通'
speed_test '9484' '吉林长春' '联通'
speed_test '2461' '四川成都' '联通'
speed_test '27154' '天津5G' '联通'
speed_test '5509' '宁夏银川' '联通'
speed_test '5724' '安徽合肥' '联通'
speed_test '5039' '山东济南' '联通'
speed_test '26180' '山东济南5G' '联通'
speed_test '26678' '广东广州5G' '联通'
speed_test '16192' '广东深圳' '联通'
speed_test '6144' '新疆乌鲁木齐' '联通'
speed_test '13704' '江苏南京' '联通'
speed_test '5485' '湖北武汉' '联通'
speed_test '26677' '湖南株洲' '联通'
speed_test '4870' '湖南长沙' '联通'
speed_test '4690' '甘肃兰州' '联通'
speed_test '4884' '福建福州' '联通'
speed_test '31985' '重庆' '联通'
speed_test '4863' '陕西西安' '联通'
end=$(date +%s)
rm -rf speedtest*
echo "——————————————————————————————————————————————————————————"
time=$(( $end - $start ))
if [[ $time -gt 60 ]]; then
min=$(expr $time / 60)
sec=$(expr $time % 60)
echo -ne " 测试完成, 本次测速耗时: ${min} 分 ${sec} 秒"
else
echo -ne " 测试完成, 本次测速耗时: ${time} 秒"
fi
echo -ne "\n 当前时间: "
echo $(date +%Y-%m-%d" "%H:%M:%S)
fi
if [[ ${selection} == 5 ]]; then
echo "——————————————————————————————————————————————————————————"
echo "ID 测速服务器信息 上传/Mbps 下载/Mbps 延迟/ms"
start=$(date +%s)
speed_test '30154' '上海' '移动'
speed_test '25637' '上海5G' '移动'
speed_test '26728' '云南昆明' '移动'
speed_test '27019' '内蒙古呼和浩特' '移动'
speed_test '30232' '内蒙呼和浩特5G' '移动'
speed_test '30293' '内蒙古通辽5G' '移动'
speed_test '25858' '北京' '移动'
speed_test '16375' '吉林长春' '移动'
speed_test '24337' '四川成都' '移动'
speed_test '17184' '天津5G' '移动'
speed_test '26940' '宁夏银川' '移动'
speed_test '31815' '宁夏银川' '移动'
speed_test '26404' '安徽合肥5G' '移动'
speed_test '27151' '山东临沂5G' '移动'
speed_test '25881' '山东济南5G' '移动'
speed_test '27100' '山东青岛5G' '移动'
speed_test '26501' '山西太原5G' '移动'
speed_test '31520' '广东中山' '移动'
speed_test '6611' '广东广州' '移动'
speed_test '4515' '广东深圳' '移动'
speed_test '15863' '广西南宁' '移动'
speed_test '16858' '新疆乌鲁木齐' '移动'
speed_test '26938' '新疆乌鲁木齐5G' '移动'
speed_test '17227' '新疆和田' '移动'
speed_test '17245' '新疆喀什' '移动'
speed_test '17222' '新疆阿勒泰' '移动'
speed_test '27249' '江苏南京5G' '移动'
speed_test '21845' '江苏常州5G' '移动'
speed_test '26850' '江苏无锡5G' '移动'
speed_test '17320' '江苏镇江5G' '移动'
speed_test '25883' '江西南昌5G' '移动'
speed_test '17223' '河北石家庄' '移动'
speed_test '26331' '河南郑州5G' '移动'
speed_test '6715' '浙江宁波5G' '移动'
speed_test '4647' '浙江杭州' '移动'
speed_test '16503' '海南海口' '移动'
speed_test '28491' '湖南长沙5G' '移动'
speed_test '16145' '甘肃兰州' '移动'
speed_test '16171' '福建福州' '移动'
speed_test '18444' '西藏拉萨' '移动'
speed_test '16398' '贵州贵阳' '移动'
speed_test '25728' '辽宁大连' '移动'
speed_test '16167' '辽宁沈阳' '移动'
speed_test '17584' '重庆' '移动'
speed_test '26380' '陕西西安' '移动'
speed_test '29105' '陕西西安5G' '移动'
speed_test '29083' '青海西宁5G' '移动'
speed_test '26656' '黑龙江哈尔滨' '移动'
end=$(date +%s)
rm -rf speedtest*
echo "——————————————————————————————————————————————————————————"
time=$(( $end - $start ))
if [[ $time -gt 60 ]]; then
min=$(expr $time / 60)
sec=$(expr $time % 60)
echo -ne " 测试完成, 本次测速耗时: ${min} 分 ${sec} 秒"
else
echo -ne " 测试完成, 本次测速耗时: ${time} 秒"
fi
echo -ne "\n 当前时间: "
echo $(date +%Y-%m-%d" "%H:%M:%S)
fi
}
runall() {
checkroot;
checksystem;
checkpython;
checkcurl;
checkwget;
checkspeedtest;
clear
speed_test;
preinfo;
selecttest;
runtest;
rm -rf speedtest*
}
runall