Files
download/panel/auto_update.sh
耗子 a65d23f05b
Some checks failed
Generate Checksums / checksums (push) Has been cancelled
feat: 移除协议
2025-08-22 06:19:40 +08:00

41 lines
1.3 KiB (Stored with Git LFS)
Bash

#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
source <(curl -f -s --connect-timeout 10 --retry 3 https://dl.cdn.haozi.net/panel/public.sh)
if [ $? -ne 0 ]; then
echo "下载 public.sh 失败,请检查网络或稍后重试。"
echo "Download public.sh failed, please check the network or try again later."
exit 1
fi
if [ ${OS} == "unknown" ]; then
error "该系统不支持安装面板(The system does not support installing the panel)"
fi
old_version=$(panel-cli setting get version)
old_version=${old_version#v}
panel_path="${setup_path}/panel"
# 大于
function version_gt() { test "$(echo -e "$1\n$2" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
# 小于
function version_lt() { test "$(echo -e "$1\n$2" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
# 大于等于
function version_ge() { test "$(echo -e "$1\n$2" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
# 小于等于
function version_le() { test "$(echo -e "$1\n$2" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
# 判断版本号是否合法
version_pattern="^[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)[0-9]*)?$"
if [[ ! $old_version =~ $version_pattern ]]; then
error "面板版本号不合法(The panel version number is invalid)"
fi
echo $HR
# TODO
echo $HR
echo "更新结束"
echo "Update finished"