Compare commits

...

12 Commits

Author SHA1 Message Date
Jensfrank
c6babfd3e6
Delete nodeloc_vps_autotest_yabs.sh 2024-08-19 16:32:06 +08:00
Jensfrank
edd2b3d091
Delete nodeloc_vps_autotest_trace.sh 2024-08-19 16:31:58 +08:00
Jensfrank
6eefbd1240
Delete nodeloc_vps_autotest_speed.sh 2024-08-19 16:31:16 +08:00
Jensfrank
7e888989b6
Delete nodeloc_vps_autotest_response.sh 2024-08-19 16:31:08 +08:00
Jensfrank
77b5a56949
Delete nodeloc_vps_autotest_media.sh 2024-08-19 16:30:59 +08:00
Jensfrank
ae1691cb7a
Delete nodeloc_vps_autotest_ip.sh 2024-08-19 16:30:51 +08:00
Jensfrank
13c8f3c215
Delete nodeloc_vps_autotest_fusion.sh 2024-08-19 16:30:38 +08:00
Jensfrank
c51dd8b551
Update README.md 2024-08-19 15:50:18 +08:00
Jensfrank
820c94b27f
Update version.sh 2024-08-19 15:50:01 +08:00
Jensfrank
292a642821
Update Nlbench.sh 2024-08-19 15:49:27 +08:00
Jensfrank
b11b633b23
Update Nlbench.sh 2024-08-19 15:48:51 +08:00
Jensfrank
c3686314ee
Update Nlbench_beta.sh 2024-08-19 15:46:08 +08:00
11 changed files with 145 additions and 1243 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# 定义版本 # 定义版本
CURRENT_VERSION="2024-08-13 v1.1.2" # 最新版本号 CURRENT_VERSION="2024-08-19 v1.1.3" # 最新版本号
SCRIPT_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/Nlbench.sh" SCRIPT_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/Nlbench.sh"
VERSION_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh" VERSION_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh"
@ -100,78 +100,77 @@ check_root() {
fi fi
} }
# 检测操作系统类型和版本 # 检测操作系统
detect_os() { detect_os() {
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
os_type=$ID os_type=$ID
os_version=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then elif type lsb_release >/dev/null 2>&1; then
os_type=$(lsb_release -si) os_type=$(lsb_release -si)
os_version=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release . /etc/lsb-release
os_type=$DISTRIB_ID os_type=$DISTRIB_ID
os_version=$DISTRIB_RELEASE elif [ -f /etc/debian_version ]; then
elif [ -f /etc/redhat-release ]; then os_type="debian"
os_type=$(cat /etc/redhat-release | cut -d ' ' -f 1) elif [ -f /etc/fedora-release ]; then
os_version=$(cat /etc/redhat-release | sed 's/.*release \([0-9\.]*\).*/\1/') os_type="fedora"
elif [ -f /etc/gentoo-release ]; then elif [ -f /etc/centos-release ]; then
os_type="gentoo" os_type="centos"
os_version=$(cat /etc/gentoo-release | cut -d ' ' -f 5)
else else
os_type=$(uname -s) os_type=$(uname -s)
os_version=$(uname -r)
fi fi
os_type=$(echo "$os_type" | tr '[:upper:]' '[:lower:]') os_type=$(echo $os_type | tr '[:upper:]' '[:lower:]')
echo -e "${YELLOW}检测到的系统: $os_type $os_version${NC}" echo "检测到的操作系统: $os_type"
} }
# 更新系统 # 更新系统
update_system() { update_system() {
detect_os || return 1 detect_os
if [ $? -ne 0 ]; then
echo -e "${RED}无法检测操作系统。${NC}"
return 1
fi
case "${os_type,,}" in case "${os_type,,}" in
ubuntu|debian|linuxmint|elementary|pop) ubuntu|debian|linuxmint|elementary|pop)
update_cmd="apt-get update" update_cmd="apt-get update"
upgrade_cmd="apt-get upgrade -y" upgrade_cmd="apt-get upgrade -y"
install_cmd="apt-get install -y" clean_cmd="apt-get autoremove -y"
;; ;;
centos|rhel|fedora|rocky|almalinux|openeuler) centos|rhel|fedora|rocky|almalinux|openeuler)
if command -v dnf &>/dev/null; then if command -v dnf &>/dev/null; then
update_cmd="dnf check-update" update_cmd="dnf check-update"
upgrade_cmd="dnf upgrade -y" upgrade_cmd="dnf upgrade -y"
install_cmd="dnf install -y" clean_cmd="dnf autoremove -y"
else else
update_cmd="yum check-update" update_cmd="yum check-update"
upgrade_cmd="yum upgrade -y" upgrade_cmd="yum upgrade -y"
install_cmd="yum install -y" clean_cmd="yum autoremove -y"
fi fi
;; ;;
opensuse*|sles) opensuse*|sles)
update_cmd="zypper refresh" update_cmd="zypper refresh"
upgrade_cmd="zypper update -y" upgrade_cmd="zypper dup -y"
install_cmd="zypper install -y" clean_cmd="zypper clean -a"
;; ;;
arch|manjaro) arch|manjaro)
update_cmd="pacman -Sy" update_cmd="pacman -Sy"
upgrade_cmd="pacman -Su --noconfirm" upgrade_cmd="pacman -Syu --noconfirm"
install_cmd="pacman -S --noconfirm" clean_cmd="pacman -Sc --noconfirm"
;; ;;
alpine) alpine)
update_cmd="apk update" update_cmd="apk update"
upgrade_cmd="apk upgrade" upgrade_cmd="apk upgrade"
install_cmd="apk add" clean_cmd="apk cache clean"
;; ;;
gentoo) gentoo)
update_cmd="emerge --sync" update_cmd="emerge --sync"
upgrade_cmd="emerge -uDN @world" upgrade_cmd="emerge -uDN @world"
install_cmd="emerge" clean_cmd="emerge --depclean"
;; ;;
cloudlinux) cloudlinux)
update_cmd="yum check-update" update_cmd="yum check-update"
upgrade_cmd="yum upgrade -y" upgrade_cmd="yum upgrade -y"
install_cmd="yum install -y" clean_cmd="yum clean all"
;; ;;
*) *)
echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}" echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}"
@ -180,37 +179,69 @@ update_system() {
esac esac
echo -e "${YELLOW}正在更新系统...${NC}" echo -e "${YELLOW}正在更新系统...${NC}"
sudo $update_cmd && sudo $upgrade_cmd sudo $update_cmd
if [ $? -eq 0 ]; then
if [ $? -ne 0 ]; then sudo $upgrade_cmd
echo -e "${RED}系统更新失败。${NC}" if [ $? -eq 0 ]; then
return 1
fi
echo -e "${GREEN}系统更新完成。${NC}" echo -e "${GREEN}系统更新完成。${NC}"
echo -e "${YELLOW}正在清理系统...${NC}"
sudo $clean_cmd
echo -e "${GREEN}系统清理完成。${NC}"
# 检查是否需要重启 # 检查是否需要重启
if [ -f /var/run/reboot-required ]; then if [ -f /var/run/reboot-required ]; then
echo -e "${YELLOW}系统更新需要重启才能完成。请在方便时重启系统。${NC}" echo -e "${YELLOW}系统更新需要重启才能完成。请在方便时重启系统。${NC}"
fi fi
return 0 return 0
fi
fi
echo -e "${RED}系统更新失败。${NC}"
return 1
} }
# 更新系统并安装依赖 # 定义支持的操作系统类型
SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux")
# 安装依赖
install_dependencies() { install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}" echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 确保 os_type 已定义
if [ -z "$os_type" ]; then
detect_os
fi
# 更新系统 # 更新系统
update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}" update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}"
# 安装依赖 # 安装依赖
local dependencies=("curl" "wget" "iperf3" "bc") local dependencies=("curl" "wget" "iperf3" "bc")
# 检查是否为支持的操作系统
if [[ ! " ${SUPPORTED_OS[@]} " =~ " ${os_type} " ]]; then
echo -e "${RED}不支持的操作系统: $os_type${NC}"
return 1
fi
case "${os_type,,}" in case "${os_type,,}" in
gentoo) gentoo)
install_cmd="emerge"
for dep in "${dependencies[@]}"; do for dep in "${dependencies[@]}"; do
if ! emerge -p $dep &>/dev/null; then if ! emerge -p $dep &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}" echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo emerge $dep; then if ! sudo $install_cmd $dep; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
alpine)
install_cmd="apk add"
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi fi
else else

View File

@ -100,78 +100,77 @@ check_root() {
fi fi
} }
# 检测操作系统类型和版本 # 检测操作系统
detect_os() { detect_os() {
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
. /etc/os-release . /etc/os-release
os_type=$ID os_type=$ID
os_version=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then elif type lsb_release >/dev/null 2>&1; then
os_type=$(lsb_release -si) os_type=$(lsb_release -si)
os_version=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then elif [ -f /etc/lsb-release ]; then
. /etc/lsb-release . /etc/lsb-release
os_type=$DISTRIB_ID os_type=$DISTRIB_ID
os_version=$DISTRIB_RELEASE elif [ -f /etc/debian_version ]; then
elif [ -f /etc/redhat-release ]; then os_type="debian"
os_type=$(cat /etc/redhat-release | cut -d ' ' -f 1) elif [ -f /etc/fedora-release ]; then
os_version=$(cat /etc/redhat-release | sed 's/.*release \([0-9\.]*\).*/\1/') os_type="fedora"
elif [ -f /etc/gentoo-release ]; then elif [ -f /etc/centos-release ]; then
os_type="gentoo" os_type="centos"
os_version=$(cat /etc/gentoo-release | cut -d ' ' -f 5)
else else
os_type=$(uname -s) os_type=$(uname -s)
os_version=$(uname -r)
fi fi
os_type=$(echo "$os_type" | tr '[:upper:]' '[:lower:]') os_type=$(echo $os_type | tr '[:upper:]' '[:lower:]')
echo -e "${YELLOW}检测到的系统: $os_type $os_version${NC}" echo "检测到的操作系统: $os_type"
} }
# 更新系统 # 更新系统
update_system() { update_system() {
detect_os || return 1 detect_os
if [ $? -ne 0 ]; then
echo -e "${RED}无法检测操作系统。${NC}"
return 1
fi
case "${os_type,,}" in case "${os_type,,}" in
ubuntu|debian|linuxmint|elementary|pop) ubuntu|debian|linuxmint|elementary|pop)
update_cmd="apt-get update" update_cmd="apt-get update"
upgrade_cmd="apt-get upgrade -y" upgrade_cmd="apt-get upgrade -y"
install_cmd="apt-get install -y" clean_cmd="apt-get autoremove -y"
;; ;;
centos|rhel|fedora|rocky|almalinux|openeuler) centos|rhel|fedora|rocky|almalinux|openeuler)
if command -v dnf &>/dev/null; then if command -v dnf &>/dev/null; then
update_cmd="dnf check-update" update_cmd="dnf check-update"
upgrade_cmd="dnf upgrade -y" upgrade_cmd="dnf upgrade -y"
install_cmd="dnf install -y" clean_cmd="dnf autoremove -y"
else else
update_cmd="yum check-update" update_cmd="yum check-update"
upgrade_cmd="yum upgrade -y" upgrade_cmd="yum upgrade -y"
install_cmd="yum install -y" clean_cmd="yum autoremove -y"
fi fi
;; ;;
opensuse*|sles) opensuse*|sles)
update_cmd="zypper refresh" update_cmd="zypper refresh"
upgrade_cmd="zypper update -y" upgrade_cmd="zypper dup -y"
install_cmd="zypper install -y" clean_cmd="zypper clean -a"
;; ;;
arch|manjaro) arch|manjaro)
update_cmd="pacman -Sy" update_cmd="pacman -Sy"
upgrade_cmd="pacman -Su --noconfirm" upgrade_cmd="pacman -Syu --noconfirm"
install_cmd="pacman -S --noconfirm" clean_cmd="pacman -Sc --noconfirm"
;; ;;
alpine) alpine)
update_cmd="apk update" update_cmd="apk update"
upgrade_cmd="apk upgrade" upgrade_cmd="apk upgrade"
install_cmd="apk add" clean_cmd="apk cache clean"
;; ;;
gentoo) gentoo)
update_cmd="emerge --sync" update_cmd="emerge --sync"
upgrade_cmd="emerge -uDN @world" upgrade_cmd="emerge -uDN @world"
install_cmd="emerge" clean_cmd="emerge --depclean"
;; ;;
cloudlinux) cloudlinux)
update_cmd="yum check-update" update_cmd="yum check-update"
upgrade_cmd="yum upgrade -y" upgrade_cmd="yum upgrade -y"
install_cmd="yum install -y" clean_cmd="yum clean all"
;; ;;
*) *)
echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}" echo -e "${RED}不支持的 Linux 发行版: $os_type${NC}"
@ -180,37 +179,69 @@ update_system() {
esac esac
echo -e "${YELLOW}正在更新系统...${NC}" echo -e "${YELLOW}正在更新系统...${NC}"
sudo $update_cmd && sudo $upgrade_cmd sudo $update_cmd
if [ $? -eq 0 ]; then
if [ $? -ne 0 ]; then sudo $upgrade_cmd
echo -e "${RED}系统更新失败。${NC}" if [ $? -eq 0 ]; then
return 1
fi
echo -e "${GREEN}系统更新完成。${NC}" echo -e "${GREEN}系统更新完成。${NC}"
echo -e "${YELLOW}正在清理系统...${NC}"
sudo $clean_cmd
echo -e "${GREEN}系统清理完成。${NC}"
# 检查是否需要重启 # 检查是否需要重启
if [ -f /var/run/reboot-required ]; then if [ -f /var/run/reboot-required ]; then
echo -e "${YELLOW}系统更新需要重启才能完成。请在方便时重启系统。${NC}" echo -e "${YELLOW}系统更新需要重启才能完成。请在方便时重启系统。${NC}"
fi fi
return 0 return 0
fi
fi
echo -e "${RED}系统更新失败。${NC}"
return 1
} }
# 更新系统并安装依赖 # 定义支持的操作系统类型
SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux")
# 安装依赖
install_dependencies() { install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}" echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 确保 os_type 已定义
if [ -z "$os_type" ]; then
detect_os
fi
# 更新系统 # 更新系统
update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}" update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}"
# 安装依赖 # 安装依赖
local dependencies=("curl" "wget" "iperf3") local dependencies=("curl" "wget" "iperf3")
# 检查是否为支持的操作系统
if [[ ! " ${SUPPORTED_OS[@]} " =~ " ${os_type} " ]]; then
echo -e "${RED}不支持的操作系统: $os_type${NC}"
return 1
fi
case "${os_type,,}" in case "${os_type,,}" in
gentoo) gentoo)
install_cmd="emerge"
for dep in "${dependencies[@]}"; do for dep in "${dependencies[@]}"; do
if ! emerge -p $dep &>/dev/null; then if ! emerge -p $dep &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}" echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo emerge $dep; then if ! sudo $install_cmd $dep; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
alpine)
install_cmd="apk add"
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}" echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi fi
else else

View File

@ -2,7 +2,7 @@
这是NodeLoc提供给各位用户的主机聚合测评脚本可一键自动对主机进行Yabs、融合怪、IP质量、流媒体解锁三网测速iperf3回程路由等测评测评结束后将会保存结果为MarkDown文件方便快速上传至NodeLoc论坛。 这是NodeLoc提供给各位用户的主机聚合测评脚本可一键自动对主机进行Yabs、融合怪、IP质量、流媒体解锁三网测速iperf3回程路由等测评测评结束后将会保存结果为MarkDown文件方便快速上传至NodeLoc论坛。
**版本:** 2024-08-13 v1.1.2 **版本:** 2024-08-19 v1.1.3
**Github地址** https://github.com/everett7623/nodeloc_vps_test **Github地址** https://github.com/everett7623/nodeloc_vps_test

View File

@ -1,161 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "融合怪"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除融合怪板块板块ANSI转义码
fusion_process_output() {
local input="$1"
# 使用更全面的 sed 命令去除所有 ANSI 转义码
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g' | awk '/A Bench Script/{f=1} f; /短链/{f=0}'
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# 融合怪
echo -e "运行${YELLOW}融合怪...${NC}"
fusion_result=$(run_and_capture "curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && echo '1' | bash ecs.sh")
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理融合怪结果
local processed_fusion_result
processed_fusion_result=$(fusion_process_output "$fusion_result")
result="[tabs]
[tab=\"融合怪\"]
\`\`\`
$processed_fusion_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,171 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "IP质量"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除IP质量板块ANSI转义码并截取
ip_process_output() {
local input="$1"
local start_line=$(echo "$input" | grep -n '正在检测黑名单数据库' | tail -n 1 | cut -d ':' -f 1)
start_line=$((start_line + 1)) # 移动到下一行
local end_line=$(echo "$input" | grep -n '按回车键返回主菜单' | head -n 1 | cut -d ':' -f 1)
if [ -n "$start_line" ] && [ -n "$end_line" ]; then
tail -n +"$start_line" <<< "$input" | head -n $(($end_line - $start_line)) | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
elif [ -n "$start_line" ]; then
tail -n +"$start_line" <<< "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
else
echo "未找到合适的日志内容。"
fi
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# IP质量
echo -e "运行${YELLOW}IP质量测试...${NC}"
ip_quality_result=$(run_and_capture "bash <(curl -Ls IP.Check.Place)")
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理IP质量结果
local processed_ip_result
processed_ip_result=$(ip_process_output "$ip_quality_result")
result="[tabs]
[tab=\"IP质量\"]
\`\`\`
########################################################################
$processed_ip_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,182 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 检测VPS地理位置
detect_region() {
local country
country=$(curl -s ipinfo.io/country)
case $country in
"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" ;; # 跨国平台
esac
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "流媒体解锁"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除流媒体板块ANSI转义码并截取
streaming_process_output() {
local input="$1"
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g' | awk '/项目地址/{f=1} f; /检测脚本当天运行次数/{f=0}'
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# 流媒体解锁
echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
local region
region=$(detect_region)
streaming_result=$(run_and_capture "echo '$region' | bash <(curl -L -s media.ispvps.com)")
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理流媒体解锁结果
local processed_streaming_result
processed_streaming_result=$(streaming_process_output "$streaming_result")
result="[tabs]
[tab=\"流媒体\"]
\`\`\`
$processed_streaming_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,160 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "响应测试"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除响应板块ANSI转义码
response_process_output() {
local input="$1"
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g'
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# 响应测试
echo -e "运行${YELLOW}响应测试...${NC}"
response_result=$(run_and_capture "bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh)")
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理响应测试结果
local processed_response_result
processed_response_result=$(response_process_output "$response_result")
result="[tabs]
[tab=\"响应\"]
\`\`\`
$processed_response_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,175 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "多线程测试(调试中)"
echo "单线程测试(调试中)"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除三网测速板块板块ANSI转义码并截取
speedtest_process_output() {
local input="$1"
# 去除 ANSI 转义码并提取所需的测试结果
echo "$input" | sed 's/\x1B\[[0-9;]*[JKmsu]//g' | awk '
BEGIN { print_flag = 0 }
/------------------------ 多功能 自更新 测速脚本 ------------------------/ { print_flag = 1 }
print_flag && !/测试进行中/ { print }
/------------------------ 测试结束 ------------------------/ { print_flag = 0 }
'
}
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# 三网测速
echo -e "运行${YELLOW}三网测速(多线程/单线程)...${NC}"
echo -e "默认选择1${YELLOW}大陆三网+教育网 IPv4多线程/单线程)测试...${NC}"
speedtest_multi_result=$(echo '1' | bash <(curl -sL bash.icu/speedtest))
speedtest_single_result=$(echo '2' | bash <(curl -sL bash.icu/speedtest))
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理三网测速结果
local processed_speedtest_multi_result=$(speedtest_process_output "$speedtest_multi_result")
local processed_speedtest_single_result=$(speedtest_process_output "$speedtest_single_result")
result="[tabs]
[tab=\"多线程测速\"]
\`\`\`
$processed_speedtest_multi_result
\`\`\`
[/tab]
[tab=\"单线程测速\"]
\`\`\`
$processed_speedtest_single_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s -r -p "按任意键退出..."
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,159 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "一键脚本将测试以下项目:"
echo "回程路由"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 在每个命令执行后保存结果
run_and_capture() {
local command_output
command_output=$(eval "$1" 2>&1)
test_results+=("$command_output")
echo "$command_output"
}
# 去除回程路由板块板块ANSI转义码并截取
autotrace_process_output() {
local input="$1"
# 使用更全面的 sed 命令去除所有 ANSI 转义码
echo "$input" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g' | awk '/No:1\/9 Traceroute to 中国/{f=1} f; /\[信息\] 已删除 Nexttrace 文件/{f=0}'
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
# AutoTrace三网回程路由
echo -e "运行${YELLOW}AutoTrace三网回程路由...${NC}"
autotrace_result=$(run_and_capture "wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && echo '1' | bash AutoTrace.sh")
# 格式化结果
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
format_results
}
# 格式化结果为 Markdown
format_results() {
# 处理回程路由结果
local processed_autotrace_result=$(autotrace_process_output "$autotrace_result")
result="[tabs]
[tab=\"回程路由\"]
\`\`\`
$processed_autotrace_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -1,153 +0,0 @@
#!/bin/bash
# 定义版本
VERSION="1.0.0"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
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
}
# 调用函数获取统计数据
sum_run_times
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "脚本将测试以下项目:"
echo "Yabs"
echo ""
echo -e "${RED}按任意键开始测试...${NC}"
read -n 1 -s
clear
}
# 定义一个数组来存储每个命令的输出
declare -a test_results
# 运行所有测试
run_all_tests() {
echo -e "${RED}开始测试,测试时间较长,请耐心等待...${NC}"
echo -e "运行${YELLOW}YABS...${NC}"
# 使用 script 命令运行 YABS 并捕获输出
script -q -c "wget -qO- yabs.sh | bash" /dev/null | tee /tmp/yabs_output
# 从输出中移除最后一行(通常是 "按回车键返回主菜单..."
sed '$d' /tmp/yabs_output > /tmp/yabs_final_output
# 读取处理后的输出
yabs_result=$(cat /tmp/yabs_final_output)
# 删除临时文件
rm /tmp/yabs_output /tmp/yabs_final_output
# 格式化结果
format_results
}
# 格式化结果为 Markdown
format_results() {
local processed_yabs_result=$(echo "$yabs_result" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g')
result="[tabs]
[tab=\"YABS\"]
\`\`\`
$processed_yabs_result
\`\`\`
[/tab]
[/tabs]"
echo "$result" > results.md
echo -e "${YELLOW}结果已保存到 results.md 文件中。${NC}"
}
# 主函数
main() {
install_dependencies
show_welcome
run_all_tests
echo -e "${YELLOW}所有测试完成可到results.md复制到Nodeloc使用。${NC}"
read -n 1 -s
echo "最终测试结果如下:" >&2
cat results.md >&2
}
main

View File

@ -15,3 +15,4 @@
# 2024-07-31 v1.1.0 - 去除yabs的gb6测试替换iperf3服务端vps # 2024-07-31 v1.1.0 - 去除yabs的gb6测试替换iperf3服务端vps
# 2024-08-08 v1.1.1 - 去除回程路由的ip等信息。 # 2024-08-08 v1.1.1 - 去除回程路由的ip等信息。
# 2024-08-13 v1.1.2 - 优化tab标签。 # 2024-08-13 v1.1.2 - 优化tab标签。
# 2024-08-19 v1.1.3 - 优化系统更新代码。