mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-12-28 17:25:20 +00:00
Update nodeloc_vps_autotest_ip.sh
This commit is contained in:
parent
2f993340d4
commit
75472bda91
@ -140,79 +140,17 @@ show_welcome() {
|
||||
touch /root/results.md
|
||||
chmod 777 /root/results.md
|
||||
|
||||
# 获取IP输出结果
|
||||
extract_ip_report() {
|
||||
echo "开始执行 IP 质量检测..." >&2
|
||||
|
||||
# 检查 curl 是否可用
|
||||
if ! command -v curl &> /dev/null; then
|
||||
echo "错误: curl 命令不可用" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 尝试下载脚本
|
||||
local curl_output
|
||||
curl_output=$(curl -Ls IP.Check.Place)
|
||||
local curl_exit_code=$?
|
||||
|
||||
echo "curl 退出码: $curl_exit_code" >&2
|
||||
echo "curl 输出长度: $(echo "$curl_output" | wc -c) 字节" >&2
|
||||
|
||||
if [ $curl_exit_code -ne 0 ] || [ -z "$curl_output" ]; then
|
||||
echo "错误: curl 命令失败或返回空输出" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 将下载的脚本保存到临时文件
|
||||
local temp_script=$(mktemp)
|
||||
echo "$curl_output" > "$temp_script"
|
||||
|
||||
# 执行下载的脚本
|
||||
local bash_output
|
||||
bash_output=$(bash "$temp_script" 2>&1)
|
||||
local bash_exit_code=$?
|
||||
|
||||
echo "bash 退出码: $bash_exit_code" >&2
|
||||
echo "bash 输出长度: $(echo "$bash_output" | wc -l) 行" >&2
|
||||
|
||||
# 清理临时文件
|
||||
rm -f "$temp_script"
|
||||
|
||||
if [ $bash_exit_code -ne 0 ] || [ -z "$bash_output" ]; then
|
||||
echo "错误: bash 执行失败或返回空输出" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 处理输出
|
||||
echo "$bash_output" | awk '
|
||||
BEGIN {flag=0; lines=0}
|
||||
/^########################################################################$/ {flag=1}
|
||||
flag && !/按回车键返回主菜单.../ {print; lines++}
|
||||
/按回车键返回主菜单.../ {flag=0}
|
||||
END {print "共输出 " lines " 行" > "/dev/stderr"}
|
||||
'
|
||||
}
|
||||
|
||||
# 运行测试
|
||||
run_all_tests() {
|
||||
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
|
||||
|
||||
# IP质量
|
||||
echo -e "运行${YELLOW}IP质量测试...${NC}"
|
||||
ip_quality_result=$(extract_ip_report 2>&1)
|
||||
extract_exit_code=$?
|
||||
|
||||
echo "extract_ip_report 退出码: $extract_exit_code" >&2
|
||||
echo "IP质量结果长度: $(echo "$ip_quality_result" | wc -l) 行" >&2
|
||||
|
||||
if [ $extract_exit_code -ne 0 ] || [ -z "$ip_quality_result" ]; then
|
||||
echo "extract_ip_report 函数失败或返回空结果" >&2
|
||||
ip_quality_result="无法获取 IP 质量报告。请检查网络连接或脚本执行权限。"
|
||||
fi
|
||||
|
||||
ip_quality_result=$(run_and_capture "bash <(curl -Ls IP.Check.Place)")
|
||||
|
||||
# 格式化结果
|
||||
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
|
||||
format_results "$ip_quality_result"
|
||||
format_results
|
||||
}
|
||||
|
||||
# 格式化输出结果
|
||||
|
Loading…
Reference in New Issue
Block a user