From 7eb6a3af01c12a2d043795c79bc77a8388c956c5 Mon Sep 17 00:00:00 2001 From: UUBulb <35923940+uubulb@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:56:09 +0800 Subject: [PATCH] fix wget not executed (#6) --- install.sh | 12 ++++++++---- install_en.sh | 12 ++++++++---- template.sh | 12 ++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index ec6c934..8e43ba5 100644 --- a/install.sh +++ b/install.sh @@ -523,6 +523,10 @@ modify_dashboard_config() { echo "正在下载服务文件" if [ "$os_alpine" != 1 ]; then _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1" + if ! eval "$_download"; then + err "文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}" + return 0 + fi else _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1" if ! eval "$_download"; then @@ -571,18 +575,18 @@ restart_and_update_docker() { restart_and_update_standalone() { _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 [ -z "$_version" ]; then - _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') - fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi + if [ -z "$_version" ]; then + _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') + fi if [ -z "$_version" ]; then - err "获取 Agent 版本号失败,请检查本机能否链接 https://api.github.com/repos/nezhahq/agent/releases/latest" + err "获取 Dashboard 版本号失败,请检查本机能否链接 https://api.github.com/repos/naiba/nezha/releases/latest" return 1 else echo "当前最新版本为: ${_version}" diff --git a/install_en.sh b/install_en.sh index d4f0325..09da9af 100644 --- a/install_en.sh +++ b/install_en.sh @@ -523,6 +523,10 @@ modify_dashboard_config() { echo "Downloading service file" if [ "$os_alpine" != 1 ]; then _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1" + if ! eval "$_download"; then + err "File failed to get, please check if the network can link ${GITHUB_RAW_URL}" + return 0 + fi else _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1" if ! eval "$_download"; then @@ -571,18 +575,18 @@ restart_and_update_docker() { restart_and_update_standalone() { _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 [ -z "$_version" ]; then - _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') - fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi + if [ -z "$_version" ]; then + _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') + fi if [ -z "$_version" ]; then - err "Fail to obtain Agent version, please check if the network can link https://api.github.com/repos/nezhahq/agent/releases/latest" + err "Fail to obtain Dashboard version, please check if the network can link https://api.github.com/repos/naiba/nezha/releases/latest" return 1 else echo "The current latest version is: ${_version}" diff --git a/template.sh b/template.sh index 891c454..d68cb09 100644 --- a/template.sh +++ b/template.sh @@ -523,6 +523,10 @@ modify_dashboard_config() { echo "{{.DownloadServiceScript}}" if [ "$os_alpine" != 1 ]; then _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1" + if ! eval "$_download"; then + err "{{.ErrorFetchFile}} ${GITHUB_RAW_URL}" + return 0 + fi else _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1" if ! eval "$_download"; then @@ -571,18 +575,18 @@ restart_and_update_docker() { restart_and_update_standalone() { _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 [ -z "$_version" ]; then - _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') - fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi if [ -z "$_version" ]; then _version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g') fi + if [ -z "$_version" ]; then + _version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/nezha/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}') + fi if [ -z "$_version" ]; then - err "{{printf .ErrorObtainVersion "Agent"}} https://api.github.com/repos/nezhahq/agent/releases/latest" + err "{{printf .ErrorObtainVersion "Dashboard"}} https://api.github.com/repos/naiba/nezha/releases/latest" return 1 else echo "{{.CurrentVersionInfo}} ${_version}"