mirror of
https://github.com/everett7623/nodeloc_vps_test.git
synced 2024-12-28 17:25:20 +00:00
Update Nlbench_beta.sh
This commit is contained in:
parent
1faf1bf016
commit
3b14f8be1a
@ -53,10 +53,11 @@ install_dependencies() {
|
||||
|
||||
# 更新脚本
|
||||
update_scripts() {
|
||||
VERSION="2024-07-05 v1.0.0" # 最新版本号
|
||||
CURRENT_VERSION="2024-07-05 v1.0.0" # 当前版本号
|
||||
SCRIPT_URL="https://raw.githubusercontent.com/everett7623/main/Nlbench_beta.sh"
|
||||
VERSION_URL="https://raw.githubusercontent.com/everett7623/main/version.sh"
|
||||
|
||||
# 获取远程版本号
|
||||
REMOTE_VERSION=$(curl -s $VERSION_URL)
|
||||
if [ -z "$REMOTE_VERSION" ]; then
|
||||
echo -e "${RED}无法获取远程版本信息。请检查您的网络连接。${NC}"
|
||||
@ -64,28 +65,23 @@ update_scripts() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$REMOTE_VERSION" != "$VERSION" ]; then
|
||||
echo -e "${BLUE}发现新版本 $REMOTE_VERSION,当前版本 $VERSION${NC}"
|
||||
# 对比版本号
|
||||
if [ "$REMOTE_VERSION" != "$CURRENT_VERSION" ]; then
|
||||
echo -e "${BLUE}发现新版本 $REMOTE_VERSION,当前版本 $CURRENT_VERSION${NC}"
|
||||
echo -e "${BLUE}正在更新...${NC}"
|
||||
|
||||
# 下载新的脚本文件
|
||||
if curl -s -o /tmp/Nlbench_beta.sh $SCRIPT_URL; then
|
||||
NEW_VERSION=$(grep '^VERSION=' /tmp/Nlbench_beta.sh | cut -d'"' -f2)
|
||||
sed -i "s/^VERSION=.*/VERSION=\"$NEW_VERSION\"/" "$0"
|
||||
sed -i "s/^CURRENT_VERSION=.*/CURRENT_VERSION=\"$NEW_VERSION\"/" "$0"
|
||||
|
||||
if mv /tmp/vps_scripts.sh "$0"; then
|
||||
# 替换脚本文件
|
||||
if mv /tmp/Nlbench_beta.sh "$0"; then
|
||||
chmod +x "$0"
|
||||
echo -e "${GREEN}脚本更新成功!新版本: $NEW_VERSION${NC}"
|
||||
echo -e "${YELLOW}请等待 3 秒...${NC}"
|
||||
sleep 3
|
||||
echo -e "${YELLOW}是否重新启动脚本以应用更新?(Y/n)${NC}"
|
||||
read -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
|
||||
exec bash "$0"
|
||||
else
|
||||
echo -e "${YELLOW}请手动重启脚本以应用更新。${NC}"
|
||||
sleep 2
|
||||
fi
|
||||
exec bash "$0"
|
||||
else
|
||||
echo -e "${RED}无法替换脚本文件。请检查权限。${NC}"
|
||||
sleep 2
|
||||
@ -97,7 +93,7 @@ update_scripts() {
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}脚本已是最新版本 $VERSION。${NC}"
|
||||
echo -e "${GREEN}脚本已是最新版本 $CURRENT_VERSION。${NC}"
|
||||
sleep 2
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user