借用jsdelivr获取版本号

This commit is contained in:
Erope 2021-07-06 21:50:49 +08:00
parent 7710748d2c
commit ccc33d628a

View File

@ -134,7 +134,7 @@ install_dashboard() {
echo -e "> 安装面板"
if [[ $(uname -m | grep 'arm') != "" ]]; then
if [[ $(uname -m | grep 'arm\|aarch') != "" ]]; then
echo "面板目前不支持在 arm 环境下安装"
exit 1
fi
@ -182,10 +182,14 @@ install_agent() {
echo -e "正在获取监控Agent版本号"
local version=$(curl -sL "https://api.github.com/repos/naiba/nezha/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
local version=$(curl -m 10 -sL "https://api.github.com/repos/naiba/nezha/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
if [ ! -n "$version" ]; then
version=$(curl -m 10 -sL "https://cdn.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g')
fi
if [ ! -n "$version" ]; then
echo -e "获取版本号失败,请检查本机能否链接 https://api.github.com/repos/naiba/nezha/releases/latest"
return 0
else
echo -e "当前最新版本为: ${version}"
fi