mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-12-29 01:35:18 +00:00
Update Nlbench.sh
This commit is contained in:
parent
07ecfc8aff
commit
39c87d942a
32
Nlbench.sh
32
Nlbench.sh
@ -23,26 +23,22 @@ check_update() {
|
|||||||
echo "正在检查更新..."
|
echo "正在检查更新..."
|
||||||
|
|
||||||
# GitHub文件路径
|
# GitHub文件路径
|
||||||
version_file_url="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh"
|
|
||||||
script_file_url="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/NLbench.sh"
|
script_file_url="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/NLbench.sh"
|
||||||
|
|
||||||
# 检查版本文件是否存在
|
# 获取当前脚本路径
|
||||||
if ! curl --output /dev/null --silent --head --fail "$version_file_url"; then
|
script_path=$(readlink -f "$0")
|
||||||
echo "版本文件不存在或URL不正确: $version_file_url"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 获取最新版本号(去除注释和空行后提取最后一个版本号)
|
# 提取当前版本号(假设脚本中有声明CURRENT_VERSION)
|
||||||
latest_version=$(curl -s "$version_file_url" | grep -E "v[0-9]+\.[0-9]+\.[0-9]+" | tail -n 1 | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+")
|
current_version=$(grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+" "$script_path")
|
||||||
|
|
||||||
|
# 获取最新版本号
|
||||||
|
latest_version=$(curl -s "$script_file_url" | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+")
|
||||||
|
|
||||||
if [ -z "$latest_version" ]; then
|
if [ -z "$latest_version" ]; then
|
||||||
echo "无法获取最新版本信息。"
|
echo "无法获取最新版本信息。"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 提取当前版本号
|
|
||||||
current_version=$(echo "$CURRENT_VERSION" | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+")
|
|
||||||
|
|
||||||
# 比较版本号
|
# 比较版本号
|
||||||
if [ "$current_version" != "$latest_version" ]; then
|
if [ "$current_version" != "$latest_version" ]; then
|
||||||
echo "发现新版本: $latest_version"
|
echo "发现新版本: $latest_version"
|
||||||
@ -50,18 +46,18 @@ check_update() {
|
|||||||
echo "正在自动更新..."
|
echo "正在自动更新..."
|
||||||
|
|
||||||
# 下载新脚本
|
# 下载新脚本
|
||||||
curl -o "$0.tmp" "$script_file_url"
|
curl -o "$script_path.tmp" "$script_file_url"
|
||||||
|
|
||||||
# 检查下载内容是否正确
|
# 检查下载内容是否正确
|
||||||
if grep -q "#!/bin/bash" "$0.tmp"; then
|
if grep -q "#!/bin/bash" "$script_path.tmp"; then
|
||||||
mv "$0.tmp" "$0"
|
mv "$script_path.tmp" "$script_path"
|
||||||
chmod +x "$0" # 添加执行权限
|
chmod +x "$script_path" # 添加执行权限
|
||||||
echo "更新完成。重新启动脚本..."
|
echo "更新完成。重新启动脚本..."
|
||||||
exec "$0" "$@"
|
exec "$script_path" "$@"
|
||||||
else
|
else
|
||||||
echo "下载的脚本内容不正确。"
|
echo "下载的脚本内容不正确。"
|
||||||
cat "$0.tmp" # 输出下载的内容进行调试
|
cat "$script_path.tmp" # 输出下载的内容进行调试
|
||||||
rm -f "$0.tmp"
|
rm -f "$script_path.tmp"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "当前已是最新版本。"
|
echo "当前已是最新版本。"
|
||||||
|
Loading…
Reference in New Issue
Block a user