nodeloc_vps_test/Nlbench.sh

567 lines
20 KiB
Bash
Raw Normal View History

2024-06-26 07:12:48 +00:00
#!/bin/bash
2024-06-26 07:32:43 +00:00
# 定义版本
2024-07-17 17:02:12 +00:00
CURRENT_VERSION="2024-07-18 v1.0.4"
2024-06-26 07:32:43 +00:00
2024-06-26 07:12:48 +00:00
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
2024-07-17 16:23:34 +00:00
# 定义渐变颜色数组
colors=(
'\033[38;2;0;255;0m' # 绿色
'\033[38;2;64;255;0m'
'\033[38;2;128;255;0m'
'\033[38;2;192;255;0m'
'\033[38;2;255;255;0m' # 黄色
)
2024-07-17 17:02:12 +00:00
# 检查更新
check_update() {
echo "正在检查更新..."
# 从GitHub获取最新版本号
2024-07-17 17:04:57 +00:00
latest_version=$(curl -s https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh | tr -d '\n\r')
2024-07-17 17:02:12 +00:00
if [ -z "$latest_version" ]; then
echo "无法获取最新版本信息。"
return
fi
2024-07-17 17:04:57 +00:00
# 比较版本号
2024-07-17 17:02:12 +00:00
if [ "$CURRENT_VERSION" != "$latest_version" ]; then
echo "发现新版本: $latest_version"
echo "当前版本: $CURRENT_VERSION"
read -p "是否更新到最新版本? (y/n): " choice
case "$choice" in
y|Y )
echo "正在更新..."
if curl -o "$0.tmp" https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/NLbench.sh && mv "$0.tmp" "$0"; then
echo "更新完成。请重新运行脚本。"
exit 0
else
echo "更新失败。"
rm -f "$0.tmp"
fi
;;
* )
echo "继续使用当前版本。"
;;
esac
else
echo "当前已是最新版本。"
fi
}
# 显示更新日志
show_changelog() {
clear
echo "脚本更新日志"
echo "-------------------------"
echo "2024-07-05 v1.0.0"
echo "初始化版本,包含基础功能和菜单选择,一键测试或者手动多选测试。"
echo "-------------------------"
echo "2024-07-05 v1.0.1"
echo "修复bug回程路由ipv6测试占不支持。"
echo "-------------------------"
echo "2024-07-05 v1.0.2"
echo "修复若干bug。"
echo "-------------------------"
echo "2024-07-05 v1.0.3"
echo "修复若干bug精简代码。"
echo "-------------------------"
echo "2024-07-05 v1.0.4"
echo "去除yabs的iperf3和gb6单独增加gb5测试优化更新脚本代码"
echo "-------------------------"
read -p "按任意键返回主菜单..."
}
2024-06-26 07:29:50 +00:00
# 检查 root 权限并获取 sudo 权限
2024-07-17 16:23:34 +00:00
check_root() {
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
}
# 检测操作系统类型和版本
detect_os() {
if [ -f /etc/os-release ]; then
. /etc/os-release
os_type=$ID
os_version=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
os_type=$(lsb_release -si)
os_version=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release
os_type=$DISTRIB_ID
os_version=$DISTRIB_RELEASE
else
echo -e "${RED}无法检测操作系统类型和版本。${NC}"
return 1
fi
echo -e "${YELLOW}检测到的系统: $os_type $os_version${NC}"
}
# 更新系统
update_system() {
detect_os || return 1
# 根据操作系统类型选择更新命令
case "${os_type,,}" in
ubuntu|debian|linuxmint|elementary|pop)
update_cmd="apt-get update"
upgrade_cmd="apt-get upgrade -y"
install_cmd="apt-get install -y"
;;
fedora|centos|rhel|ol|rocky|almalinux)
if [ "${os_version%%.*}" -ge 22 ] || [ "${os_version%%.*}" -ge 8 ]; then
update_cmd="dnf check-update"
upgrade_cmd="dnf upgrade -y"
install_cmd="dnf install -y"
else
update_cmd="yum check-update"
upgrade_cmd="yum upgrade -y"
install_cmd="yum install -y"
fi
;;
opensuse*|sles)
update_cmd="zypper refresh"
upgrade_cmd="zypper update -y"
install_cmd="zypper install -y"
;;
arch|manjaro)
update_cmd="pacman -Sy"
upgrade_cmd="pacman -Su --noconfirm"
install_cmd="pacman -S --noconfirm"
;;
alpine)
update_cmd="apk update"
upgrade_cmd="apk upgrade"
install_cmd="apk add"
;;
*)
echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}"
return 1
;;
esac
echo -e "${YELLOW}正在更新系统...${NC}"
sudo $update_cmd && sudo $upgrade_cmd
if [ $? -ne 0 ]; then
echo -e "${RED}系统更新失败。${NC}"
return 1
2024-06-26 07:29:50 +00:00
fi
2024-07-17 16:23:34 +00:00
echo -e "${GREEN}系统更新完成。${NC}"
# 检查是否需要重启
if [ -f /var/run/reboot-required ]; then
echo -e "${YELLOW}系统更新需要重启才能完成。请在方便时重启系统。${NC}"
fi
return 0
}
2024-06-26 07:29:50 +00:00
2024-07-12 15:46:41 +00:00
# 更新系统并安装依赖
2024-06-26 07:12:48 +00:00
install_dependencies() {
2024-06-26 12:34:32 +00:00
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
2024-06-26 07:12:48 +00:00
2024-07-12 15:46:41 +00:00
# 更新系统
2024-07-17 16:23:34 +00:00
update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}"
2024-06-26 07:12:48 +00:00
# 安装依赖
2024-07-17 16:23:34 +00:00
local dependencies=("curl" "wget" "iperf3")
2024-06-26 07:12:48 +00:00
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
2024-07-17 16:23:34 +00:00
if ! sudo $install_cmd "$dep"; then
2024-06-26 07:12:48 +00:00
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
2024-06-26 12:46:29 +00:00
clear
2024-06-26 07:12:48 +00:00
}
2024-07-05 06:34:22 +00:00
2024-07-05 06:46:23 +00:00
# 获取IP地址和ISP信息
ip_address_and_isp() {
2024-07-03 11:45:01 +00:00
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)
if [ -z "$ipv4_address" ]; then
ipv4_address=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -n1)
fi
ipv6_address=$(curl -s --max-time 5 ipv6.ip.sb)
if [ -z "$ipv6_address" ]; then
ipv6_address=$(ip -6 addr show | grep -oP '(?<=inet6\s)[\da-f:]+' | grep -v '^::1' | grep -v '^fe80' | head -n1)
fi
2024-07-05 06:46:23 +00:00
# 获取ISP信息
isp_info=$(curl -s ipinfo.io/org)
# 检查是否为WARP或Cloudflare
is_warp=false
if echo "$isp_info" | grep -iq "cloudflare\|warp\|1.1.1.1"; then
is_warp=true
fi
# 判断使用IPv6还是IPv4
use_ipv6=false
if [ "$is_warp" = true ] || [ -z "$ipv4_address" ]; then
use_ipv6=true
fi
echo "IPv4: $ipv4_address"
echo "IPv6: $ipv6_address"
echo "ISP: $isp_info"
echo "Is WARP: $is_warp"
echo "Use IPv6: $use_ipv6"
2024-07-03 11:45:01 +00:00
}
2024-06-26 12:37:52 +00:00
# 检测VPS地理位置
2024-06-26 12:34:32 +00:00
detect_region() {
local country
country=$(curl -s ipinfo.io/country)
case $country in
2024-06-26 12:37:52 +00:00
"TW") echo "1" ;; # 台湾
"HK") echo "2" ;; # 香港
"JP") echo "3" ;; # 日本
"US" | "CA") echo "4" ;; # 北美
"BR" | "AR" | "CL") echo "5" ;; # 南美
"GB" | "DE" | "FR" | "NL" | "SE" | "NO" | "FI" | "DK" | "IT" | "ES" | "CH" | "AT" | "BE" | "IE" | "PT" | "GR" | "PL" | "CZ" | "HU" | "RO" | "BG" | "HR" | "SI" | "SK" | "LT" | "LV" | "EE") echo "6" ;; # 欧洲
"AU" | "NZ") echo "7" ;; # 大洋洲
"KR") echo "8" ;; # 韩国
"SG" | "MY" | "TH" | "ID" | "PH" | "VN") echo "9" ;; # 东南亚
"IN") echo "10" ;; # 印度
"ZA" | "NG" | "EG" | "KE" | "MA" | "TN" | "GH" | "CI" | "SN" | "UG" | "ET" | "MZ" | "ZM" | "ZW" | "BW" | "MW" | "NA" | "RW" | "SD" | "DJ" | "CM" | "AO") echo "11" ;; # 非洲
*) echo "0" ;; # 跨国平台
2024-06-26 12:34:32 +00:00
esac
}
2024-07-04 09:17:33 +00:00
# 服务器 VPS 信息
2024-07-04 08:55:52 +00:00
AUXILIARY_VPS="205.185.119.208"
IPERF_PORT=5201
2024-07-04 09:12:07 +00:00
TEST_DURATION=30
2024-07-04 05:00:30 +00:00
2024-07-04 08:55:52 +00:00
run_iperf3_test() {
2024-07-04 09:17:33 +00:00
echo -e "${GREEN}服务端VPS位于美国拉斯维加斯${NC}"
echo -e "${GREEN}连接到服务端进行iperf3测试。。。${NC}"
2024-07-06 18:03:31 +00:00
if iperf3 -c $AUXILIARY_VPS -p $IPERF_PORT -t $TEST_DURATION; then
2024-07-04 09:15:15 +00:00
echo -e "${YELLOW}iperf3 测试完成${NC}"
2024-07-04 08:55:52 +00:00
else
2024-07-04 09:20:08 +00:00
echo -e "${RED}iperf3 测试失败${NC}"
2024-07-04 08:55:52 +00:00
fi
2024-07-04 05:00:30 +00:00
}
2024-06-26 12:21:13 +00:00
# 统计使用次数
sum_run_times() {
2024-07-06 17:35:19 +00:00
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Feverett7623%2Fnodeloc_vps_test%2Fblob%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
2024-06-26 12:21:13 +00:00
if [[ -n "$COUNT" ]]; then
daily_count=$(cut -d " " -f1 <<< "$COUNT")
total_count=$(cut -d " " -f3 <<< "$COUNT")
else
echo "Failed to fetch usage counts."
daily_count=0
total_count=0
fi
2024-06-26 07:12:48 +00:00
}
2024-06-26 12:34:32 +00:00
2024-07-03 11:45:01 +00:00
# 执行单个脚本并输出结果到文件
run_script() {
local script_number=$1
local output_file=$2
local temp_file=$(mktemp)
2024-07-05 06:46:23 +00:00
# 调用ip_address_and_isp函数获取IP地址和ISP信息
ip_address_and_isp
2024-07-03 11:45:01 +00:00
case $script_number in
# YABS
1)
echo -e "运行${YELLOW}YABS...${NC}"
2024-07-17 16:23:34 +00:00
curl -sL yabs.sh | bash -s -- -i -5 | tee "$temp_file"
2024-07-03 11:45:01 +00:00
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\./\.\.\.\n/g' "$temp_file"
sed -i '/\.\.\./d' "$temp_file"
sed -i '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_yabs"
;;
2024-07-17 16:23:34 +00:00
# Geekbench5
2024-07-03 11:45:01 +00:00
2)
2024-07-17 16:23:34 +00:00
echo -e "运行${YELLOW}Geekbench 5...${NC}"
bash <(curl -sL gb5.top) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\x1B\[.*?[mGKH]//g' "$temp_file"
sed -i 's/\r//' "$temp_file"
sed -i '/^$/d' "$temp_file"
sed -i -n '/当前时间:/,${p}' "$temp_file"
cp "$temp_file" "${output_file}_gb5"
;;
# 融合怪
3)
2024-07-03 11:45:01 +00:00
echo -e "运行${YELLOW}融合怪...${NC}"
2024-07-04 03:44:06 +00:00
curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh -m 1 <<< "y" | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\.\.\.\./\.\.\.\.\.\.\n/g' "$temp_file"
2024-07-05 06:46:23 +00:00
sed -i '1,/\.\.\.\.\.\./d' "$temp_file"
2024-07-05 07:53:43 +00:00
sed -i -n '/--------------------- A Bench Script By spiritlhl ----------------------/,${s/^.*\(--------------------- A Bench Script By spiritlhl ----------------------\)/\1/;p}' "$temp_file"
2024-07-03 15:39:50 +00:00
cp "$temp_file" "${output_file}_fusion"
2024-07-03 11:45:01 +00:00
;;
# IP质量
2024-07-17 16:23:34 +00:00
4)
2024-07-03 11:45:01 +00:00
echo -e "运行${YELLOW}IP质量测试...${NC}"
bash <(curl -Ls IP.Check.Place) | tee "$temp_file"
2024-07-04 09:56:43 +00:00
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
2024-07-04 14:45:54 +00:00
sed -i -r 's/(⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)/\n/g' "$temp_file"
2024-07-12 00:18:29 +00:00
sed -i -r '/正在检测/d' "$temp_file"
2024-07-04 14:45:54 +00:00
sed -i -n '/########################################################################/,${s/^.*\(########################################################################\)/\1/;p}' "$temp_file"
2024-07-04 09:56:43 +00:00
cp "$temp_file" "${output_file}_ip_quality"
2024-07-03 11:45:01 +00:00
;;
# 流媒体解锁
2024-07-17 16:23:34 +00:00
5)
2024-07-03 11:45:01 +00:00
echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
local region=$(detect_region)
2024-07-04 09:49:51 +00:00
bash <(curl -L -s media.ispvps.com) <<< "$region" | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
2024-07-04 14:45:54 +00:00
sed -i -n '/流媒体平台及游戏区域限制测试/,$p' "$temp_file"
sed -i '1d' "$temp_file"
sed -i '/^$/d' "$temp_file"
2024-07-04 09:49:51 +00:00
cp "$temp_file" "${output_file}_streaming"
2024-07-03 11:45:01 +00:00
;;
# 响应测试
2024-07-17 16:23:34 +00:00
6)
2024-07-03 11:45:01 +00:00
echo -e "运行${YELLOW}响应测试...${NC}"
2024-07-04 09:56:43 +00:00
bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
cp "$temp_file" "${output_file}_response"
2024-07-03 11:45:01 +00:00
;;
# 多线程测速
2024-07-17 16:23:34 +00:00
7)
2024-07-05 06:46:23 +00:00
echo -e "运行${YELLOW}多线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL bash.icu/speedtest) <<< "3" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
else
2024-07-05 06:46:23 +00:00
echo "使用IPv4测试选项"
bash <(curl -sL bash.icu/speedtest) <<< "1" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
fi
2024-07-03 11:45:01 +00:00
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
sed -i -r 's/(⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)/\n/g' "$temp_file"
sed -i -r '/测试进行中/d' "$temp_file"
2024-07-03 15:17:53 +00:00
cp "$temp_file" "${output_file}_multi_thread"
2024-07-03 11:45:01 +00:00
;;
# 单线程测速
2024-07-17 16:23:34 +00:00
8)
2024-07-05 06:46:23 +00:00
echo -e "运行${YELLOW}单线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL bash.icu/speedtest) <<< "17" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
else
2024-07-05 06:46:23 +00:00
echo "使用IPv4测试选项"
bash <(curl -sL bash.icu/speedtest) <<< "2" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
fi
2024-07-05 06:46:23 +00:00
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
sed -i -r 's/(⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)/\n/g' "$temp_file"
sed -i -r '/测试进行中/d' "$temp_file"
cp "$temp_file" "${output_file}_single_thread"
2024-07-03 11:45:01 +00:00
;;
2024-07-04 05:00:30 +00:00
# iperf3测试
2024-07-17 16:23:34 +00:00
9)
2024-07-04 05:00:30 +00:00
echo -e "运行${YELLOW}iperf3测试...${NC}"
run_iperf3_test | tee "$temp_file"
2024-07-04 09:33:20 +00:00
sed -i -e 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
2024-07-04 09:25:23 +00:00
sed -i -r '1,/\[ ID\] /d' "$temp_file"
2024-07-05 07:47:05 +00:00
sed -i '/^$/d' "$temp_file"
2024-07-04 06:35:32 +00:00
cp "$temp_file" "${output_file}_iperf3"
2024-07-04 05:00:30 +00:00
;;
2024-07-05 06:46:23 +00:00
# 回程路由
2024-07-17 16:23:34 +00:00
10)
2024-07-04 06:06:09 +00:00
echo -e "运行${YELLOW}回程路由测试...${NC}"
2024-07-05 06:46:23 +00:00
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "4" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
else
2024-07-05 06:46:23 +00:00
echo "使用IPv4测试选项"
wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "1" | tee "$temp_file"
2024-07-05 04:08:48 +00:00
fi
2024-07-04 09:56:43 +00:00
sed -i -e 's/\x1B\[[0-9;]*[JKmsu]//g' -e '/测试项/,+9d' -e '/信息/d' -e '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_route"
2024-07-04 06:06:09 +00:00
;;
2024-07-03 11:45:01 +00:00
esac
rm "$temp_file"
echo -e "${GREEN}测试完成。${NC}"
}
# 生成最终的 Markdown 输出
generate_markdown_output() {
local base_output_file=$1
local final_output_file="${base_output_file}.md"
2024-07-17 16:23:34 +00:00
local sections=("YABS" "Geekbench5" "融合怪" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "iperf3" "回程路由")
local file_suffixes=("yabs" "gb5" "fusion" "ip_quality" "streaming" "response" "multi_thread" "single_thread" "iperf3" "route")
2024-07-03 11:45:01 +00:00
echo "[tabs]" > "$final_output_file"
2024-07-11 17:26:31 +00:00
for i in "${!sections[@]}"; do
section="${sections[$i]}"
suffix="${file_suffixes[$i]}"
echo "[tab=\"$section\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_${suffix}" ]; then
cat "${base_output_file}_${suffix}" >> "$final_output_file"
rm "${base_output_file}_${suffix}"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
done
2024-07-03 11:45:01 +00:00
2024-07-11 17:26:31 +00:00
# Adding remaining empty tabs
local empty_tabs=("去程路由" "Ping.pe" "哪吒 ICMP" "其他")
for tab in "${empty_tabs[@]}"; do
echo "[tab=\"$tab\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
done
2024-07-03 11:45:01 +00:00
echo "[/tabs]" >> "$final_output_file"
echo "所有测试完成,结果已保存在 $final_output_file 中。"
read -p "按回车键继续..."
clear
}
# 执行全部脚本
run_all_scripts() {
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
echo "开始执行全部测试脚本..."
2024-07-17 16:23:34 +00:00
for i in {1..10}; do
2024-07-03 11:45:01 +00:00
run_script $i "$base_output_file"
done
generate_markdown_output "$base_output_file"
clear
}
# 执行选定的脚本
run_selected_scripts() {
clear
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
2024-07-05 04:08:48 +00:00
echo -e "${YELLOW}Nodeloc VPS 自动测试脚本 $VERSION${NC}"
2024-07-03 11:45:01 +00:00
echo "1. Yabs"
2024-07-17 16:23:34 +00:00
echo "2. Geekbench5"
echo "3. 融合怪"
echo "4. IP质量"
echo "5. 流媒体解锁"
echo "6. 响应测试"
echo "7. 多线程测试"
echo "8. 单线程测试"
echo "9. iperf3"
echo "10. 回程路由"
2024-07-03 11:45:01 +00:00
echo "0. 返回"
2024-07-04 14:45:54 +00:00
while true; do
read -p "请输入要执行的脚本编号用英文逗号分隔例如1,2,3):" script_numbers
2024-07-17 16:23:34 +00:00
if [[ "$script_numbers" =~ ^(0|10|[1-9])(,(0|10|[1-9]))*$ ]]; then
2024-07-04 14:45:54 +00:00
break
else
2024-07-17 16:23:34 +00:00
echo -e "${RED}无效输入请输入0-10之间的数字用英文逗号分隔。${NC}"
2024-07-04 14:45:54 +00:00
fi
done
2024-07-03 11:45:01 +00:00
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
2024-07-04 14:45:54 +00:00
if [ "$script_numbers" == "0" ]; then
2024-07-03 11:45:01 +00:00
clear
show_welcome
else
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
generate_markdown_output "$base_output_file"
fi
}
# 主菜单
main_menu() {
2024-07-17 16:23:34 +00:00
echo -e "${GREEN}测试项目:${NC}Yabsgeekbench5融合怪IP质量流媒体解锁响应测试多线程测试单线程测试iperf3回程路由。"
2024-07-03 11:45:01 +00:00
echo -e "${YELLOW}1. 执行所有测试脚本${NC}"
echo -e "${YELLOW}2. 选择特定测试脚本${NC}"
echo -e "${YELLOW}0. 退出${NC}"
read -p "请选择操作 [0-2]: " choice
case $choice in
1)
run_all_scripts
;;
2)
run_selected_scripts
;;
0)
echo -e "${RED}感谢使用NodeLoc聚合测试脚本已退出脚本期待你的下次使用${NC}"
exit 0
;;
*)
echo -e "${RED}无效选择,请重新输入。${NC}"
sleep 3s
clear
show_welcome
;;
esac
}
2024-06-26 12:34:32 +00:00
# 输出欢迎信息
show_welcome() {
echo ""
2024-06-26 12:55:29 +00:00
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
2024-06-26 12:34:32 +00:00
echo ""
2024-07-17 16:39:49 +00:00
echo -e "${GREEN}Nodeloc聚合测试脚本 $CURRENT_VERSION ${NC}"
2024-07-04 04:32:04 +00:00
echo -e "${GREEN}GitHub地址: https://github.com/everett7623/nodeloc_vps_test${NC}"
echo -e "${GREEN}VPS选购: https://www.nodeloc.com/vps${NC}"
2024-06-26 12:34:32 +00:00
echo ""
2024-07-17 16:23:34 +00:00
echo -e "${colors[0]} _ _ ___ ____ _____ _ ___ ____ __ ______ ____ ${NC}"
echo -e "${colors[1]} | \ | |/ _ \| _ \| ____| | / _ \ / ___| \ \ / / _ \/ ___| ${NC}"
echo -e "${colors[2]} | \| | | | | | | | _| | | | | | | | \ \ / /| |_) \___ \ ${NC}"
echo -e "${colors[3]} | |\ | |_| | |_| | |___| |__| |_| | |___ \ V / | __/ ___) |${NC}"
echo -e "${colors[4]} |_| \_|\___/|____/|_____|_____\___/ \____| \_/ |_| |____/ ${NC}"
2024-06-26 12:34:32 +00:00
echo ""
echo "支持Ubuntu/Debian"
echo ""
2024-06-26 12:55:29 +00:00
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
2024-06-26 12:34:32 +00:00
echo ""
2024-06-26 12:55:29 +00:00
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
2024-06-26 12:34:32 +00:00
echo ""
2024-06-26 11:24:21 +00:00
}
2024-06-26 12:34:32 +00:00
2024-06-26 07:12:48 +00:00
# 主函数
main() {
2024-07-17 16:23:34 +00:00
2024-07-17 17:02:12 +00:00
# 检查更新
check_update
2024-07-17 16:23:34 +00:00
# 检查是不是root用户
check_root
2024-07-03 11:45:01 +00:00
# 检查并安装依赖
2024-06-26 07:12:48 +00:00
install_dependencies
2024-07-17 16:34:03 +00:00
# 调用函数获取统计数据
2024-07-03 11:45:01 +00:00
sum_run_times
# 主循环
while true; do
show_welcome
main_menu
done
2024-06-26 07:12:48 +00:00
}
2024-07-03 11:45:01 +00:00
# 运行主函数
2024-06-26 07:12:48 +00:00
main