diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml index 6940ccd..b81645e 100644 --- a/.github/workflows/dashboard.yml +++ b/.github/workflows/dashboard.yml @@ -42,11 +42,13 @@ jobs: - name: Purge jsdelivr cache run: | curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/install.sh + curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/fetch.sh curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/nezha-agent.service curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/docker-compose.yaml curl -s https://purge.jsdelivr.net/gh/${{ github.repository_owner }}/nezha@master/script/config.yaml LOWER_USERNAME=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/install.sh + curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/fetch.sh curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/nezha-agent.service curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/docker-compose.yaml curl -s https://purge.jsdelivr.net/gh/$LOWER_USERNAME/nezha@master/script/config.yaml diff --git a/README.md b/README.md index d38bff2..27476de 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@


-    +   

:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

@@ -21,15 +21,20 @@ **推荐配置:** 安装前准备 _两个域名_,一个可以 **接入 CDN** 作为 _公开访问_,比如 (status.nai.ba);另外一个解析到面板服务器作为 Agent 连接 Dashboard 使用,**不能接入 CDN** 直接暴露面板主机 IP,比如(randomdashboard.nai.ba)。 ```shell -curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh -./nezha.sh +curl -sSL https://raw.githubusercontent.com/naiba/nezha/master/script/fetch.sh | sh +/opt/nezha/nezha.sh ``` 国内镜像加速: ```shell -curl -L https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh && chmod +x nezha.sh -CN=true ./nezha.sh +curl -sSL https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/fetch.sh | CN=true sh +CN=true /opt/nezha/nezha.sh +``` + +再次运行仅需: +``` +/opt/nezha/nezha.sh ``` _\* 使用 WatchTower 可以自动更新面板,Windows 终端可以使用 nssm 配置自启动(见尾部教程)_ diff --git a/script/fetch.sh b/script/fetch.sh new file mode 100644 index 0000000..ca2f5df --- /dev/null +++ b/script/fetch.sh @@ -0,0 +1,9 @@ +if [[ -z "${CN}" ]]; then + GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master" +else + GITHUB_RAW_URL="cdn.jsdelivr.net/gh/naiba/nezha@master" +fi +mkdir -p /opt/nezha +chmod 777 /opt/nezha +curl -sSL https://${GITHUB_RAW_URL}/script/install.sh -o /opt/nezha/nezha.sh +chmod +x /opt/nezha/nezha.sh \ No newline at end of file diff --git a/script/install.sh b/script/install.sh index fc76ed5..e0c1b9c 100755 --- a/script/install.sh +++ b/script/install.sh @@ -98,10 +98,10 @@ update_script () { mkdir -p $NZ_BASE_PATH chmod 777 -R $NZ_BASE_PATH - curl -sL https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o /tmp/nezha.sh + curl -sL https://${GITHUB_RAW_URL}/script/install.sh -o /tmp/nezha.sh new_version=$(cat /tmp/nezha.sh | grep "NZ_VERSION" | head -n 1 | awk -F "=" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') if [ ! -n "$new_version" ]; then - echo -e "脚本获取失败,请检查本机能否链接 https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh" + echo -e "脚本获取失败,请检查本机能否链接 https://${GITHUB_RAW_URL}/script/install.sh" return 1 fi echo -e "当前最新版本为: ${new_version}"