Update 测速中文
This commit is contained in:
343
测速中文
343
测速中文
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# 精准网络测速一键脚本
|
# 精准网络测速一键脚本 - 终极修复版
|
||||||
# 支持多系统:Ubuntu/Debian/CentOS/RHEL/Alpine
|
# 支持多系统:Ubuntu/Debian/CentOS/RHEL/Alpine
|
||||||
# 功能:网络连通性测试、多节点延迟测试、Speedtest测速
|
# 功能:网络连通性测试、多节点延迟测试、Speedtest测速
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ install_tools() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 安装必要工具
|
# 安装必要工具
|
||||||
TOOLS=("curl" "wget" "ping" "bc" "pip3" "python3")
|
TOOLS=("curl" "wget" "ping" "bc" "python3")
|
||||||
for tool in "${TOOLS[@]}"; do
|
for tool in "${TOOLS[@]}"; do
|
||||||
if ! check_command "$tool"; then
|
if ! check_command "$tool"; then
|
||||||
echo -e "${BLUE}安装 $tool...${NC}"
|
echo -e "${BLUE}安装 $tool...${NC}"
|
||||||
@@ -76,7 +76,7 @@ install_tools() {
|
|||||||
"bc")
|
"bc")
|
||||||
$INSTALL_CMD bc >/dev/null 2>&1 || echo -e "${YELLOW}⚠️ bc 安装失败${NC}"
|
$INSTALL_CMD bc >/dev/null 2>&1 || echo -e "${YELLOW}⚠️ bc 安装失败${NC}"
|
||||||
;;
|
;;
|
||||||
"pip3"|"python3")
|
"python3")
|
||||||
if [ "$PM" = "apt-get" ]; then
|
if [ "$PM" = "apt-get" ]; then
|
||||||
$INSTALL_CMD python3 python3-pip >/dev/null 2>&1 || echo -e "${YELLOW}⚠️ python3 安装失败${NC}"
|
$INSTALL_CMD python3 python3-pip >/dev/null 2>&1 || echo -e "${YELLOW}⚠️ python3 安装失败${NC}"
|
||||||
elif [ "$PM" = "yum" ] || [ "$PM" = "dnf" ]; then
|
elif [ "$PM" = "yum" ] || [ "$PM" = "dnf" ]; then
|
||||||
@@ -93,132 +93,171 @@ install_tools() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# 清理和修复speedtest安装
|
# 终极speedtest安装方案
|
||||||
clean_speedtest() {
|
install_speedtest_ultimate() {
|
||||||
echo -e "${BLUE}🧹 清理可能损坏的speedtest...${NC}"
|
echo -e "${BLUE}🚀 终极speedtest安装方案...${NC}"
|
||||||
|
|
||||||
# 卸载各种版本的speedtest
|
# 方法1: 直接下载预编译的二进制文件(最可靠)
|
||||||
apt-get remove -y speedtest-cli 2>/dev/null
|
echo -e "${BLUE}方法1: 下载预编译二进制...${NC}"
|
||||||
pip uninstall -y speedtest-cli 2>/dev/null
|
|
||||||
pip3 uninstall -y speedtest-cli 2>/dev/null
|
|
||||||
rm -f /usr/local/bin/speedtest-cli
|
|
||||||
rm -f /usr/bin/speedtest
|
|
||||||
rm -f /usr/bin/speedtest-cli
|
|
||||||
|
|
||||||
echo -e "${GREEN}✅ 清理完成${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 安装speedtest - 增强版本
|
|
||||||
install_speedtest() {
|
|
||||||
echo -e "${BLUE}📦 检查并安装speedtest...${NC}"
|
|
||||||
|
|
||||||
# 检查是否已安装
|
|
||||||
if check_command speedtest; then
|
|
||||||
echo -e "${GREEN}✅ speedtest 已安装${NC}"
|
|
||||||
speedtest --version
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 清理旧版本
|
|
||||||
clean_speedtest
|
|
||||||
|
|
||||||
# 方法1: 安装官方ookla speedtest (首选)
|
|
||||||
echo -e "${BLUE}尝试安装官方speedtest...${NC}"
|
|
||||||
if check_command curl; then
|
|
||||||
if curl -s https://install.speedtest.net/app/cli/install.deb.sh | bash >/dev/null 2>&1; then
|
|
||||||
if $UPDATE_CMD >/dev/null 2>&1 && $INSTALL_CMD speedtest >/dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}✅ 官方speedtest安装成功${NC}"
|
|
||||||
speedtest --version
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 方法2: 直接下载二进制文件
|
|
||||||
echo -e "${BLUE}尝试下载二进制speedtest...${NC}"
|
|
||||||
if check_command wget; then
|
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
if [ "$ARCH" = "x86_64" ]; then
|
if [ "$ARCH" = "x86_64" ]; then
|
||||||
SPEEDTEST_URL="https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz"
|
BINARY_URL="https://github.com/tmplink/speedtest/raw/master/speedtest_x86_64"
|
||||||
elif [ "$ARCH" = "aarch64" ]; then
|
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||||
SPEEDTEST_URL="https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-aarch64.tgz"
|
BINARY_URL="https://github.com/tmplink/speedtest/raw/master/speedtest_aarch64"
|
||||||
else
|
else
|
||||||
SPEEDTEST_URL="https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz"
|
echo -e "${YELLOW}⚠️ 不支持的架构: $ARCH,尝试x86_64版本${NC}"
|
||||||
|
BINARY_URL="https://github.com/tmplink/speedtest/raw/master/speedtest_x86_64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if wget -q -O speedtest.tgz "$SPEEDTEST_URL" && \
|
if curl -s -L -o /tmp/speedtest "$BINARY_URL" && chmod +x /tmp/speedtest; then
|
||||||
tar -xzf speedtest.tgz && \
|
mv /tmp/speedtest /usr/local/bin/speedtest
|
||||||
mv speedtest /usr/local/bin/ && \
|
|
||||||
chmod +x /usr/local/bin/speedtest; then
|
|
||||||
echo -e "${GREEN}✅ 二进制speedtest安装成功${NC}"
|
echo -e "${GREEN}✅ 二进制speedtest安装成功${NC}"
|
||||||
speedtest --version
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
rm -f speedtest.tgz
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 方法3: 使用pip安装
|
# 方法2: 使用Python speedtest库
|
||||||
echo -e "${BLUE}尝试pip安装speedtest-cli...${NC}"
|
echo -e "${BLUE}方法2: 安装Python speedtest库...${NC}"
|
||||||
if check_command pip3; then
|
if check_command python3; then
|
||||||
if pip3 install speedtest-cli >/dev/null 2>&1; then
|
cat > /usr/local/bin/speedtest.py << 'EOF'
|
||||||
echo -e "${GREEN}✅ speedtest-cli pip安装成功${NC}"
|
#!/usr/bin/env python3
|
||||||
return 0
|
import speedtest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
try:
|
||||||
|
s = speedtest.Speedtest()
|
||||||
|
s.get_best_server()
|
||||||
|
|
||||||
|
print("测试下载速度...")
|
||||||
|
download_speed = s.download() / 1024 / 1024 # 转换为Mbps
|
||||||
|
print(f"下载速度: {download_speed:.2f} Mbps")
|
||||||
|
|
||||||
|
print("测试上传速度...")
|
||||||
|
upload_speed = s.upload() / 1024 / 1024 # 转换为Mbps
|
||||||
|
print(f"上传速度: {upload_speed:.2f} Mbps")
|
||||||
|
|
||||||
|
print("测试延迟...")
|
||||||
|
ping = s.results.ping
|
||||||
|
print(f"网络延迟: {ping:.2f} ms")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"测速失败: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
EOF
|
||||||
|
if python3 -c "import speedtest" 2>/dev/null; then
|
||||||
|
echo -e "${GREEN}✅ Python speedtest已安装${NC}"
|
||||||
|
else
|
||||||
|
if python3 -m pip install speedtest-cli >/dev/null 2>&1; then
|
||||||
|
echo -e "${GREEN}✅ Python speedtest安装成功${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
chmod +x /usr/local/bin/speedtest.py
|
||||||
|
# 创建包装脚本
|
||||||
|
cat > /usr/local/bin/speedtest << 'EOF'
|
||||||
|
#!/bin/bash
|
||||||
|
/usr/bin/python3 /usr/local/bin/speedtest.py
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/speedtest
|
||||||
|
echo -e "${GREEN}✅ Python版speedtest安装成功${NC}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# 方法4: 使用包管理器安装
|
# 方法3: 使用wget和curl进行基本测速
|
||||||
echo -e "${BLUE}尝试包管理器安装...${NC}"
|
echo -e "${YELLOW}⚠️ 无法安装标准speedtest,将使用基础测速方法${NC}"
|
||||||
if [ "$PM" = "apt-get" ]; then
|
|
||||||
if $INSTALL_CMD speedtest-cli >/dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}✅ speedtest-cli 包管理器安装成功${NC}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
elif [ "$PM" = "yum" ] || [ "$PM" = "dnf" ]; then
|
|
||||||
if $INSTALL_CMD speedtest-cli >/dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}✅ speedtest-cli 包管理器安装成功${NC}"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${YELLOW}⚠️ speedtest安装失败,将使用备用测速方法${NC}"
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# 备用网络测速方法
|
# 增强版网络测速
|
||||||
backup_speed_test() {
|
enhanced_speed_test() {
|
||||||
echo -e "${CYAN}🔄 使用备用方法进行网络测速...${NC}"
|
echo -e "${CYAN}🌐 增强版网络测速...${NC}"
|
||||||
|
|
||||||
# 测试下载速度到多个测速服务器
|
# 测试国内CDN速度
|
||||||
servers=(
|
echo -e "${BLUE}测试国内下载速度...${NC}"
|
||||||
"http://speedtest.ftp.otenet.gr/files/test1Mb.db"
|
domestic_servers=(
|
||||||
"http://ipv4.download.thinkbroadband.com/1MB.zip"
|
"https://mirrors.aliyun.com/ubuntu/ls-lR.gz"
|
||||||
"http://proof.ovh.net/files/1Mb.dat"
|
"https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ls-lR.gz"
|
||||||
|
"https://mirrors.ustc.edu.cn/ubuntu/ls-lR.gz"
|
||||||
)
|
)
|
||||||
|
|
||||||
for server in "${servers[@]}"; do
|
for server in "${domestic_servers[@]}"; do
|
||||||
echo -e "${BLUE}测试服务器: $(basename $server)${NC}"
|
domain=$(echo "$server" | awk -F/ '{print $3}')
|
||||||
if check_command wget; then
|
echo -e "测试 $domain ..."
|
||||||
start_time=$(date +%s)
|
if check_command curl; then
|
||||||
if wget -O /dev/null --timeout=10 --tries=2 "$server" >/dev/null 2>&1; then
|
start_time=$(date +%s%N)
|
||||||
end_time=$(date +%s)
|
if curl -s --max-time 10 -o /dev/null "$server" 2>/dev/null; then
|
||||||
duration=$((end_time - start_time))
|
end_time=$(date +%s%N)
|
||||||
if [ $duration -eq 0 ]; then
|
duration=$(( (end_time - start_time) / 1000000 )) # 毫秒
|
||||||
duration=1
|
download_time=$(echo "scale=2; $duration / 1000" | bc -l 2>/dev/null || echo "0")
|
||||||
fi
|
if [ "$download_time" != "0" ] && [ $(echo "$download_time > 0" | bc -l 2>/dev/null) -eq 1 ]; then
|
||||||
speed=$(echo "scale=2; 8 / $duration" | bc -l 2>/dev/null || echo "N/A")
|
speed=$(echo "scale=2; 1.0 / $download_time * 8" | bc -l 2>/dev/null || echo "N/A")
|
||||||
echo -e "${GREEN} 下载速度: ${speed} Mbps${NC}"
|
echo -e "${GREEN} 下载速度: ${speed} Mbps${NC}"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW} 服务器不可用${NC}"
|
echo -e "${YELLOW} 连接成功但速度计算失败${NC}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW} 连接失败${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# 使用iperf3测试(如果可用)
|
# 测试国际速度
|
||||||
if check_command iperf3; then
|
echo -e "${BLUE}测试国际连接速度...${NC}"
|
||||||
echo -e "${BLUE}使用iperf3测试...${NC}"
|
international_servers=(
|
||||||
iperf3 -c speedtest.serverius.net -p 5202 -t 5 -O 2 2>/dev/null | grep -E "sender|receiver" | head -2
|
"https://www.google.com/favicon.ico"
|
||||||
|
"https://www.github.com/favicon.ico"
|
||||||
|
"https://www.cloudflare.com/favicon.ico"
|
||||||
|
)
|
||||||
|
|
||||||
|
for server in "${international_servers[@]}"; do
|
||||||
|
domain=$(echo "$server" | awk -F/ '{print $3}')
|
||||||
|
echo -e "测试 $domain ..."
|
||||||
|
if check_command curl; then
|
||||||
|
if curl -s --max-time 10 -o /dev/null -w "HTTP状态: %{http_code}\n下载大小: %{size_download} bytes\n总时间: %{time_total} s\n" "$server"; then
|
||||||
|
echo -e "${GREEN} 连接成功${NC}"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW} 连接失败${NC}"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# 使用ping测试网络质量
|
||||||
|
echo -e "${BLUE}网络质量测试...${NC}"
|
||||||
|
test_hosts=("223.5.5.5" "114.114.114.114" "8.8.8.8" "1.1.1.1")
|
||||||
|
for host in "${test_hosts[@]}"; do
|
||||||
|
if ping -c 3 -W 2 "$host" >/dev/null 2>&1; then
|
||||||
|
result=$(ping -c 3 -W 2 "$host" 2>/dev/null | grep "packet loss" | awk '{print " 丢包率: "$6" | "}')
|
||||||
|
avg_ping=$(ping -c 3 -W 2 "$host" 2>/dev/null | grep "min/avg/max" | awk -F'/' '{print $5}')
|
||||||
|
echo -e "${GREEN}$host - 平均延迟: ${avg_ping}ms $result${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${RED}$host - 无法连接${NC}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# 简单speedtest测速(如果安装成功)
|
||||||
|
simple_speedtest() {
|
||||||
|
echo -e "${CYAN}🚀 执行Speedtest测速...${NC}"
|
||||||
|
|
||||||
|
if check_command speedtest; then
|
||||||
|
echo -e "${GREEN}使用系统speedtest命令...${NC}"
|
||||||
|
if speedtest --simple 2>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /usr/local/bin/speedtest.py ] && check_command python3; then
|
||||||
|
echo -e "${GREEN}使用Python speedtest...${NC}"
|
||||||
|
python3 /usr/local/bin/speedtest.py
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}⚠️ 未找到可用的speedtest,使用增强测速...${NC}"
|
||||||
|
enhanced_speed_test
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查系统兼容性
|
# 检查系统兼容性
|
||||||
@@ -240,6 +279,16 @@ check_system() {
|
|||||||
# 检查内核版本
|
# 检查内核版本
|
||||||
KERNEL=$(uname -r)
|
KERNEL=$(uname -r)
|
||||||
echo -e "${GREEN}✅ 内核版本: $KERNEL${NC}"
|
echo -e "${GREEN}✅ 内核版本: $KERNEL${NC}"
|
||||||
|
|
||||||
|
# 检查网络状态
|
||||||
|
echo -e "${BLUE}🌐 检查网络状态...${NC}"
|
||||||
|
if check_command curl; then
|
||||||
|
if curl -s --connect-timeout 5 https://www.baidu.com >/dev/null; then
|
||||||
|
echo -e "${GREEN}✅ 网络连接正常${NC}"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}⚠️ 网络连接可能有限制${NC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 网络连通性测试
|
# 网络连通性测试
|
||||||
@@ -259,7 +308,7 @@ test_connectivity() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ "$connected" = false ]; then
|
if [ "$connected" = false ]; then
|
||||||
handle_error "网络连接失败,请检查网络设置"
|
echo -e "${YELLOW}⚠️ 基础网络连接测试失败,但继续测试...${NC}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +337,6 @@ test_latency() {
|
|||||||
echo -e "${RED}$result ❌${NC}"
|
echo -e "${RED}$result ❌${NC}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# 如果没有bc,简单显示结果
|
|
||||||
echo -e "${GREEN}$result${NC}"
|
echo -e "${GREEN}$result${NC}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -300,53 +348,12 @@ test_latency() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Speedtest测速 - 增强版本
|
|
||||||
test_speed() {
|
|
||||||
echo -e "${CYAN}🚀 进行Speedtest测速...${NC}"
|
|
||||||
|
|
||||||
# 调试信息
|
|
||||||
echo -e "${BLUE}可用的speedtest命令:${NC}"
|
|
||||||
which speedtest 2>/dev/null && echo -e " speedtest: $(speedtest --version 2>/dev/null || echo '无法获取版本')"
|
|
||||||
which speedtest-cli 2>/dev/null && echo -e " speedtest-cli: $(speedtest-cli --version 2>/dev/null || echo '无法获取版本')"
|
|
||||||
|
|
||||||
# 检查是否有可用的speedtest命令
|
|
||||||
SPEEDTEST_CMD=""
|
|
||||||
if check_command speedtest; then
|
|
||||||
SPEEDTEST_CMD="speedtest --accept-license --accept-gdpr --simple"
|
|
||||||
elif check_command speedtest-cli; then
|
|
||||||
SPEEDTEST_CMD="speedtest-cli --simple"
|
|
||||||
elif [ -f /usr/local/bin/speedtest ]; then
|
|
||||||
SPEEDTEST_CMD="/usr/local/bin/speedtest --accept-license --accept-gdpr --simple"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$SPEEDTEST_CMD" ]; then
|
|
||||||
echo -e "${BLUE}使用命令: $SPEEDTEST_CMD${NC}"
|
|
||||||
|
|
||||||
# 设置超时,防止卡住
|
|
||||||
timeout 60 bash -c "$SPEEDTEST_CMD" 2>/dev/null
|
|
||||||
result=$?
|
|
||||||
|
|
||||||
if [ $result -eq 0 ]; then
|
|
||||||
echo -e "${GREEN}✅ speedtest测速成功${NC}"
|
|
||||||
elif [ $result -eq 124 ]; then
|
|
||||||
echo -e "${YELLOW}⚠️ speedtest测速超时${NC}"
|
|
||||||
backup_speed_test
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}⚠️ speedtest测速失败,错误码: $result${NC}"
|
|
||||||
backup_speed_test
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}⚠️ 未找到speedtest命令${NC}"
|
|
||||||
backup_speed_test
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 显示系统信息
|
# 显示系统信息
|
||||||
show_system_info() {
|
show_system_info() {
|
||||||
echo -e "${PURPLE}"
|
echo -e "${PURPLE}"
|
||||||
echo "=================================================="
|
echo "=================================================="
|
||||||
echo " 🌈 精准网络测速脚本 v3.0"
|
echo " 🌈 终极网络测速脚本 v4.0"
|
||||||
echo " 增强版 - 多方法测速 | 自动修复 | 备用方案"
|
echo " 专治各种网络测速失败问题"
|
||||||
echo " 支持: Ubuntu/Debian/CentOS/RHEL"
|
echo " 支持: Ubuntu/Debian/CentOS/RHEL"
|
||||||
echo "=================================================="
|
echo "=================================================="
|
||||||
echo -e "${NC}"
|
echo -e "${NC}"
|
||||||
@@ -363,34 +370,16 @@ show_usage() {
|
|||||||
echo -e "${GREEN}选项:${NC}"
|
echo -e "${GREEN}选项:${NC}"
|
||||||
echo -e " -h, --help 显示此帮助信息"
|
echo -e " -h, --help 显示此帮助信息"
|
||||||
echo -e " -v, --version 显示版本信息"
|
echo -e " -v, --version 显示版本信息"
|
||||||
echo -e " -f, --force 强制重新安装speedtest"
|
echo -e " -f, --fix 强制修复speedtest安装"
|
||||||
echo -e ""
|
echo -e ""
|
||||||
echo -e "${GREEN}功能:${NC}"
|
echo -e "${GREEN}功能:${NC}"
|
||||||
echo -e " ✅ 系统环境检测"
|
echo -e " ✅ 系统环境检测"
|
||||||
echo -e " ✅ 自动安装依赖工具"
|
echo -e " ✅ 自动安装依赖工具"
|
||||||
echo -e " ✅ 网络连通性测试"
|
echo -e " ✅ 网络连通性测试"
|
||||||
echo -e " ✅ 多节点延迟测试"
|
echo -e " ✅ 多节点延迟测试"
|
||||||
echo -e " ✅ Speedtest网速测试 (多方法)"
|
echo -e " ✅ 终极speedtest安装"
|
||||||
echo -e " ✅ 备用测速方案"
|
echo -e " ✅ 增强版网络测速"
|
||||||
echo -e " ✅ 自动修复安装问题"
|
|
||||||
echo -e ""
|
echo -e ""
|
||||||
echo -e "${GREEN}示例:${NC}"
|
|
||||||
echo -e " $0 # 运行完整测试"
|
|
||||||
echo -e " $0 --force # 强制重新安装speedtest"
|
|
||||||
echo -e " $0 --help # 显示帮助"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 显示版本信息
|
|
||||||
show_version() {
|
|
||||||
echo -e "${GREEN}精准网络测速脚本 v3.0${NC}"
|
|
||||||
echo -e "增强版 - 多方法测速 | 自动修复 | 备用方案"
|
|
||||||
}
|
|
||||||
|
|
||||||
# 强制重新安装speedtest
|
|
||||||
force_reinstall_speedtest() {
|
|
||||||
echo -e "${YELLOW}🔄 强制重新安装speedtest...${NC}"
|
|
||||||
clean_speedtest
|
|
||||||
install_speedtest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 主函数
|
# 主函数
|
||||||
@@ -402,38 +391,32 @@ main() {
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
show_version
|
echo -e "${GREEN}终极网络测速脚本 v4.0${NC}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-f|--force)
|
-f|--fix)
|
||||||
FORCE_REINSTALL=true
|
echo -e "${YELLOW}🛠️ 强制修复模式...${NC}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# 正常执行
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
show_system_info
|
show_system_info
|
||||||
install_tools
|
install_tools
|
||||||
echo ""
|
echo ""
|
||||||
|
install_speedtest_ultimate
|
||||||
if [ "$FORCE_REINSTALL" = true ]; then
|
|
||||||
force_reinstall_speedtest
|
|
||||||
else
|
|
||||||
install_speedtest
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
test_connectivity
|
test_connectivity
|
||||||
echo ""
|
echo ""
|
||||||
test_latency
|
test_latency
|
||||||
echo ""
|
echo ""
|
||||||
test_speed
|
simple_speedtest
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo -e "${PURPLE}==================================================${NC}"
|
echo -e "${PURPLE}==================================================${NC}"
|
||||||
echo -e "${PURPLE} 测试完成 🌟${NC}"
|
echo -e "${PURPLE} 测试完成 🌟${NC}"
|
||||||
echo -e "${PURPLE}==================================================${NC}"
|
echo -e "${PURPLE}==================================================${NC}"
|
||||||
|
echo -e "${BLUE}💡 提示: 如果测速不理想,可尝试: $0 --fix${NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 设置陷阱,确保脚本退出时重置颜色
|
# 设置陷阱,确保脚本退出时重置颜色
|
||||||
|
|||||||
Reference in New Issue
Block a user