From 6dba9c25b6cafc94a3bca3e7170e599b6be10e68 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:47:23 +0800 Subject: [PATCH 01/74] update --- plugins/nezha/info.json | 6 +- plugins/nezha/install.sh | 11 +- plugins/nezha/versions/2.2.6/install.sh | 132 ++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 11 deletions(-) create mode 100755 plugins/nezha/versions/2.2.6/install.sh diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index afb4e6990..a355a27db 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -1,17 +1,17 @@ { "sort": 7, - "ps": "哪吒监控面板/改造版", + "ps": "哪吒监控面板&&改造版", "name": "nezha", "title": "哪吒监控", "shell": "install.sh", - "versions":["0.15.2"], + "versions":["0.15.2","2.2.6"], "tip": "soft", "checks": "server/nezha", "path": "server/nezha", "display": 1, "author": "midoks", "date": "2023-06-26", - "home": "https://github.com/midoks/nezha", + "home": "https://github.com/nezhahq/nezha", "doc1": "https://nezha.wiki/", "type": 0, "pid": "5" diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh index 0a007b9a4..a559beba8 100755 --- a/plugins/nezha/install.sh +++ b/plugins/nezha/install.sh @@ -2,6 +2,9 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH +# systemctl status nezha-dashboard +# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 + curPath=`pwd` rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") @@ -30,12 +33,4 @@ if [ "${action}" == "uninstall" ];then rm -rf /lib/systemd/system/nezha.service systemctl daemon-reload fi - - if [ -f /usr/lib/systemd/system/nezha-agent.service ] || [ -f /lib/systemd/system/nezha-agent.service ] ;then - systemctl stop nezha-agent - systemctl disable nezha-agent - rm -rf /usr/lib/systemd/system/nezha-agent.service - rm -rf /lib/systemd/system/nezha-agent.service - systemctl daemon-reload - fi fi diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh new file mode 100755 index 000000000..a5ae8ea65 --- /dev/null +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -0,0 +1,132 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +VERSION=2.2.6 + +# bash install.sh install 2.2.6 +# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 + +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + + +ARCH="amd64" + +get_arch() { + TMP_ARCH=`arch` + if [ "$TMP_ARCH" == "x86_64" ];then + ARCH="amd64" + elif [ "$TMP_ARCH" == "aarch64" ];then + ARCH="arm64" + else + echo $ARCH + fi +} + +load_vars() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + TARGET_DIR="$serverPath/nezha/dashboard" + + ## China_IP + if [[ -z "${CN}" ]]; then + if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then + CN=true + fi + fi + + if [[ -z "${CN}" ]]; then + GITHUB_RAW_URL="raw.githubusercontent.com/midoks/nezha/main" + GITHUB_URL="github.com" + else + GITHUB_RAW_URL="cdn.jsdelivr.net/gh/midoks/nezha@main" + GITHUB_URL="dn-dao-github-mirror.daocloud.io" + fi + + echo $GITHUB_RAW_URL + echo $GITHUB_URL +} + +# download file +download_file() { + url="${1}" + destination="${2}" + + printf "Fetching ${url} \n\n" + + if test -x "$(command -v curl)"; then + code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}") + elif test -x "$(command -v wget)"; then + code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1) + else + printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n" + exit 1 + fi + + if [ "${code}" != 200 ]; then + printf "\e[1;31mRequest failed with code %s\e[0m\n" $code + exit 1 + else + printf "\n\e[1;33mDownload succeeded\e[0m\n" + fi +} + + +Install_dashborad(){ + echo '正在安装哪吒监控...' + mkdir -p $serverPath/source + + if [ ! -f $TARGET_DIR/nezha ];then + + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip" + + DOWNLOAD_FILE="$(mktemp).zip" + download_file $DOWNLOAD_URL $DOWNLOAD_FILE + + if [ ! -d $TARGET_DIR ]; then + mkdir -p $TARGET_DIR + fi + + unzip $DOWNLOAD_FILE -d $TARGET_DIR + rm -rf $DOWNLOAD_FILE + fi + +} + +Install_App() +{ + load_vars + get_arch + + Install_dashborad + + if [ -d $serverPath/nezha ];then + echo "$VERSION" > $serverPath/nezha/version.pl + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg + fi + echo 'install successful' +} + +Uninstall_App() +{ + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall_agent + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent + rm -rf $serverPath/nezha + echo "install fail" +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi From 358a021ba67e3c9f0e7200faf8dc06300a774fcb Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:47:54 +0800 Subject: [PATCH 02/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index a5ae8ea65..53e94dcb9 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -117,7 +117,6 @@ Install_App() Uninstall_App() { cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall_agent cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent rm -rf $serverPath/nezha From 33a4a799c50a469b8810af3b403b665d51363052 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:48:46 +0800 Subject: [PATCH 03/74] Update index.py --- plugins/nezha/index.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index d79ad4bc2..646fbf8a2 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -272,21 +272,6 @@ class App: mw.execShell('systemctl disable nezha') return 'ok' - def initd_status_agent(self): - cmd = 'systemctl status nezha-agent | grep loaded | grep "enabled;"' - data = mw.execShell(cmd) - if data[0] == '': - return 'fail' - return 'ok' - - def initd_install_agent(self): - mw.execShell('systemctl enable nezha-agent') - return 'ok' - - def initd_uninstall_agent(self): - mw.execShell('systemctl disable nezha-agent') - return 'ok' - def conf(self): return self.getServerDir() + '/dashboard/data/config.yaml' From d8519bc1c36d79407d40b54b3d17a1668f15ee07 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:49:08 +0800 Subject: [PATCH 04/74] update --- plugins/nezha/init.d/nezha-agent.service.tpl | 30 ------- plugins/nezha/init.d/nezha-agent.tpl | 90 -------------------- 2 files changed, 120 deletions(-) delete mode 100644 plugins/nezha/init.d/nezha-agent.service.tpl delete mode 100644 plugins/nezha/init.d/nezha-agent.tpl diff --git a/plugins/nezha/init.d/nezha-agent.service.tpl b/plugins/nezha/init.d/nezha-agent.service.tpl deleted file mode 100644 index 4d36207c8..000000000 --- a/plugins/nezha/init.d/nezha-agent.service.tpl +++ /dev/null @@ -1,30 +0,0 @@ -[Unit] -Description=Nezha Agent -After=syslog.target -#After=network.target -#After=nezha-dashboard.service - -[Service] -# Modify these two values and uncomment them if you have -# repos with lots of files and get an HTTP error 500 because -# of that -### -#LimitMEMLOCK=infinity -#LimitNOFILE=65535 -Type=simple -User=root -Group=root -WorkingDirectory={$SERVER_PATH}/nezha/agent/ -ExecStart={$SERVER_PATH}/nezha/agent/nezha-agent -s {$APP_HOST} -p {$APP_SECRET} -Restart=always -#Environment=DEBUG=true - -# Some distributions may not support these hardening directives. If you cannot start the service due -# to an unknown option, comment out the ones not supported by your version of systemd. -#ProtectSystem=full -#PrivateDevices=yes -#PrivateTmp=yes -#NoNewPrivileges=true - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/plugins/nezha/init.d/nezha-agent.tpl b/plugins/nezha/init.d/nezha-agent.tpl deleted file mode 100644 index d6dd23fd9..000000000 --- a/plugins/nezha/init.d/nezha-agent.tpl +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# chkconfig: 2345 55 25 -# description: Nezha Agent Service - -### BEGIN INIT INFO -# Provides: Nezha Agent -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: starts Nezha Agent -# Description: starts the Nezha Agent -### END INIT INFO - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin - -if [ -f /etc/init.d/functions ];then - . /etc/init.d/functions -fi - -if [ -f /etc/rc.d/init.d/functions ];then - . /etc/rc.d/init.d/functions -fi - -SERVICENAME=nezha-agent -LOG_PATH={$SERVER_PATH}/nezha/logs -APP_PATH={$SERVER_PATH}/nezha/agent -APP_HOST={$APP_HOST} -APP_SECRET={$APP_SECRET} - - -app_start(){ - isStart=`ps -ef|grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}'` - if [ "$isStart" == '' ];then - echo -e "Starting ${SERVICENAME}... \c" - cd $APP_PATH - exec nohup ${APP_PATH}/${SERVICENAME} -d -s ${APP_HOST} -p ${APP_SECRET} >> ${LOG_PATH}/${SERVICENAME}.log 2>&1 & - isStart="" - while [[ "$isStart" == "" ]]; - do - echo -e ".\c" - sleep 0.5 - isStart=$(ps -ef|grep "${SERVICENAME}" |grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}') - let n+=1 - if [ $n -gt 15 ];then - break; - fi - done - if [ "$isStart" == '' ];then - echo -e "\033[31mError: ${SERVICENAME} service startup failed.\033[0m" - return; - fi - echo -e "\033[32mdone\033[0m" - else - echo "Starting ${SERVICENAME}(pid $(echo $isStart)) already running" - fi -} - -app_stop(){ - pids=`ps -ef | grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" |awk '{print $2}'` - arr=($pids) - echo -e "Stopping ${SERVICENAME}... \c" - for p in ${arr[@]} - do - # echo "$p" - kill -9 $p - done - echo -e "\033[32mdone\033[0m" -} - -app_status(){ - isStart=`ps -ef | grep "${SERVICENAME}" | grep -v grep | grep -v python | grep -v "/bin/bash" | awk '{print $2}'` - if [ "$isStart" == '' ];then - echo -e "${SERVICENAME} not running" - else - echo -e "${SERVICENAME}(pid $(echo $isStart)) already running" - fi -} - -case "$1" in - 'start') app_start;; - 'stop') app_stop;; - 'status') app_status;; - 'reload') - app_stop - app_start;; - 'restart') - app_stop - app_start;; -esac \ No newline at end of file From 3da0c5b2b61dc21fbafeb6c864de3065d907eea0 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:52:55 +0800 Subject: [PATCH 05/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 26 +++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 53e94dcb9..6d4665afc 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -35,23 +35,15 @@ load_vars() { OS=$(uname | tr '[:upper:]' '[:lower:]') TARGET_DIR="$serverPath/nezha/dashboard" - ## China_IP - if [[ -z "${CN}" ]]; then - if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then - CN=true - fi - fi + # China_IP + # if [[ -z "${CN}" ]]; then + # if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then + # CN=true + # fi + # fi - if [[ -z "${CN}" ]]; then - GITHUB_RAW_URL="raw.githubusercontent.com/midoks/nezha/main" - GITHUB_URL="github.com" - else - GITHUB_RAW_URL="cdn.jsdelivr.net/gh/midoks/nezha@main" - GITHUB_URL="dn-dao-github-mirror.daocloud.io" - fi - - echo $GITHUB_RAW_URL - echo $GITHUB_URL + GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main" + GITHUB_URL="github.com" } # download file @@ -85,7 +77,7 @@ Install_dashborad(){ if [ ! -f $TARGET_DIR/nezha ];then - DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip" + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/dashboard-${OS}-${ARCH}.zip" DOWNLOAD_FILE="$(mktemp).zip" download_file $DOWNLOAD_URL $DOWNLOAD_FILE From 0fca0d54f847b4d45075d3a931285bc0b3a29112 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:53:08 +0800 Subject: [PATCH 06/74] Update info.json --- plugins/nezha/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index a355a27db..1e7af64a8 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -4,7 +4,7 @@ "name": "nezha", "title": "哪吒监控", "shell": "install.sh", - "versions":["0.15.2","2.2.6"], + "versions":["2.2.6"], "tip": "soft", "checks": "server/nezha", "path": "server/nezha", From 0b5c53ef7e3111eb0b180d2604803757cecd6d15 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 12:55:34 +0800 Subject: [PATCH 07/74] Update index.html --- plugins/nezha/index.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/nezha/index.html b/plugins/nezha/index.html index f2eb9c9ea..775b7797b 100755 --- a/plugins/nezha/index.html +++ b/plugins/nezha/index.html @@ -6,9 +6,6 @@

面板自启动

面板配置

面板配置文件

-

AGENT服务

-

AGENT自启动

-

AGENT配置

说明

From 2c73577798bc1647cc617d3b2db46d604b541d91 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:08:33 +0800 Subject: [PATCH 08/74] Update nezha.js --- plugins/nezha/js/nezha.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index b6add248d..84b434bec 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -176,8 +176,6 @@ var nezha = { readme:function (){ var readme = '
    '; readme += '
  • 安装时不会自动启动。
  • '; - readme += '
  • 哪吒面板是改造版,用户名和密码登录【面板配置】,不依赖github/gitee/gitlab。
  • '; - readme += '
  • Agent需要先手动填写正确信息。
  • '; readme += '
'; $('.soft-man-con').html(readme); } From 4153ea743157a8c9a8a59159e81c43bf7da8617a Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:16:32 +0800 Subject: [PATCH 09/74] update --- plugins/nezha/info.json | 2 +- plugins/nezha/versions/2.2.6/install.sh | 49 ++++++++++++--- .../versions/{0.15.2 => latest}/install.sh | 60 ++++--------------- 3 files changed, 55 insertions(+), 56 deletions(-) rename plugins/nezha/versions/{0.15.2 => latest}/install.sh (65%) diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index 1e7af64a8..65aebf784 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -4,7 +4,7 @@ "name": "nezha", "title": "哪吒监控", "shell": "install.sh", - "versions":["2.2.6"], + "versions":["2.2.6","latest"], "tip": "soft", "checks": "server/nezha", "path": "server/nezha", diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 6d4665afc..9b2c39193 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -20,15 +20,48 @@ OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F ARCH="amd64" +geo_check() { + api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace" + ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" + set -- "$api_list" + for url in $api_list; do + text="$(curl -A "$ua" -m 10 -s "$url")" + endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')" + if echo "$text" | grep -qw 'CN'; then + isCN=true + break + elif echo "$url" | grep -q "$endpoint"; then + break + fi + done +} + get_arch() { - TMP_ARCH=`arch` - if [ "$TMP_ARCH" == "x86_64" ];then - ARCH="amd64" - elif [ "$TMP_ARCH" == "aarch64" ];then - ARCH="arm64" - else - echo $ARCH - fi + uname=$(uname -m) + case "$uname" in + amd64|x86_64) + ARCH="amd64" + ;; + i386|i686) + ARCH="386" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *arm*) + ARCH="arm" + ;; + s390x) + ARCH="s390x" + ;; + riscv64) + ARCH="riscv64" + ;; + *) + err "未知架构:$ARCH" + exit 1 + ;; + esac } load_vars() { diff --git a/plugins/nezha/versions/0.15.2/install.sh b/plugins/nezha/versions/latest/install.sh similarity index 65% rename from plugins/nezha/versions/0.15.2/install.sh rename to plugins/nezha/versions/latest/install.sh index 4ed401a67..6d4665afc 100755 --- a/plugins/nezha/versions/0.15.2/install.sh +++ b/plugins/nezha/versions/latest/install.sh @@ -7,11 +7,11 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") -VERSION=0.15.2 +VERSION=2.2.6 -# bash install.sh install 0.15.2 -# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 0.15.2 -# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 0.15.2 +# bash install.sh install 2.2.6 +# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` @@ -35,24 +35,15 @@ load_vars() { OS=$(uname | tr '[:upper:]' '[:lower:]') TARGET_DIR="$serverPath/nezha/dashboard" - - ## China_IP - if [[ -z "${CN}" ]]; then - if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then - CN=true - fi - fi + # China_IP + # if [[ -z "${CN}" ]]; then + # if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then + # CN=true + # fi + # fi - if [[ -z "${CN}" ]]; then - GITHUB_RAW_URL="raw.githubusercontent.com/midoks/nezha/main" - GITHUB_URL="github.com" - else - GITHUB_RAW_URL="cdn.jsdelivr.net/gh/midoks/nezha@main" - GITHUB_URL="dn-dao-github-mirror.daocloud.io" - fi - - echo $GITHUB_RAW_URL - echo $GITHUB_URL + GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main" + GITHUB_URL="github.com" } # download file @@ -86,7 +77,7 @@ Install_dashborad(){ if [ ! -f $TARGET_DIR/nezha ];then - DOWNLOAD_URL="https://${GITHUB_URL}/midoks/nezha/releases/download/v${VERSION}/nezha-${OS}-${ARCH}.zip" + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/dashboard-${OS}-${ARCH}.zip" DOWNLOAD_FILE="$(mktemp).zip" download_file $DOWNLOAD_URL $DOWNLOAD_FILE @@ -101,36 +92,12 @@ Install_dashborad(){ } -Install_agent(){ - echo -e "正在下载监控端" - mkdir -p $serverPath/source - - version=v0.15.1 - - AGENT_TARGET_DIR="$serverPath/nezha/agent" - - DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_${OS}_${ARCH}.zip" - DOWNLOAD_FILE="$(mktemp).zip" - - if [ ! -f $AGENT_TARGET_DIR/nezha-agent ];then - download_file $DOWNLOAD_URL $DOWNLOAD_FILE - - if [ ! -d $AGENT_TARGET_DIR ]; then - mkdir -p $AGENT_TARGET_DIR - fi - - unzip $DOWNLOAD_FILE -d $AGENT_TARGET_DIR - rm -rf $DOWNLOAD_FILE - fi -} - Install_App() { load_vars get_arch Install_dashborad - Install_agent if [ -d $serverPath/nezha ];then echo "$VERSION" > $serverPath/nezha/version.pl @@ -142,7 +109,6 @@ Install_App() Uninstall_App() { cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall_agent cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent rm -rf $serverPath/nezha From f59c8ea53396dfbf91bfb871b363f449706b2c2d Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:17:26 +0800 Subject: [PATCH 10/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 9b2c39193..f511b618b 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -143,7 +143,6 @@ Uninstall_App() { cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent rm -rf $serverPath/nezha echo "install fail" } From 10afc0a2d5b6303b783659635dc6c319452fa768 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:19:13 +0800 Subject: [PATCH 11/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index f511b618b..bd2a8c8a8 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -120,7 +120,13 @@ Install_dashborad(){ fi unzip $DOWNLOAD_FILE -d $TARGET_DIR + + + echo $TARGET_DIR + rm -rf $DOWNLOAD_FILE + + fi } From f23e27202723d970dce77aa5d67bdb37ce2b159f Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:27:25 +0800 Subject: [PATCH 12/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index bd2a8c8a8..765da937a 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -7,6 +7,9 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +nezhaDir=${serverPath}/source/nezha + + VERSION=2.2.6 # bash install.sh install 2.2.6 @@ -107,12 +110,12 @@ download_file() { Install_dashborad(){ echo '正在安装哪吒监控...' mkdir -p $serverPath/source + filename="dashboard-${OS}-${ARCH}.zip" if [ ! -f $TARGET_DIR/nezha ];then - DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/dashboard-${OS}-${ARCH}.zip" - DOWNLOAD_FILE="$(mktemp).zip" + DOWNLOAD_FILE="$nezhaDir/$filename" download_file $DOWNLOAD_URL $DOWNLOAD_FILE if [ ! -d $TARGET_DIR ]; then @@ -122,7 +125,7 @@ Install_dashborad(){ unzip $DOWNLOAD_FILE -d $TARGET_DIR - echo $TARGET_DIR + echo "TARGET_DIR:"$TARGET_DIR rm -rf $DOWNLOAD_FILE From 37da947b9031fa08af5aabb8c58e4804057d8b0f Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:31:09 +0800 Subject: [PATCH 13/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 765da937a..0eea737b4 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -67,6 +67,22 @@ get_arch() { esac } +check_init() { + init=$(readlink /sbin/init) + case "$init" in + *systemd*) + INIT=systemd + ;; + *openrc-init*|*busybox*) + INIT=openrc + ;; + *) + err "Unknown init" + exit 1 + ;; + esac +} + load_vars() { OS=$(uname | tr '[:upper:]' '[:lower:]') TARGET_DIR="$serverPath/nezha/dashboard" @@ -123,10 +139,10 @@ Install_dashborad(){ fi unzip $DOWNLOAD_FILE -d $TARGET_DIR - - echo "TARGET_DIR:"$TARGET_DIR + cd $TARGET_DIR && dashboard-linux-${ARCH} app + rm -rf $DOWNLOAD_FILE @@ -138,6 +154,7 @@ Install_App() { load_vars get_arch + check_init Install_dashborad From 56a78d174d38b7e6cc913ce241964a2bdf845740 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:31:25 +0800 Subject: [PATCH 14/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 0eea737b4..a1f94974a 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -141,7 +141,7 @@ Install_dashborad(){ unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR - cd $TARGET_DIR && dashboard-linux-${ARCH} app + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app rm -rf $DOWNLOAD_FILE From 90ae21fb8b3d4667dfa871b371e74a51d16b9688 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:43:14 +0800 Subject: [PATCH 15/74] Update nezha.service.tpl --- plugins/nezha/init.d/nezha.service.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/init.d/nezha.service.tpl b/plugins/nezha/init.d/nezha.service.tpl index 0752b3eb5..baa47a978 100644 --- a/plugins/nezha/init.d/nezha.service.tpl +++ b/plugins/nezha/init.d/nezha.service.tpl @@ -15,7 +15,7 @@ Type=simple #User=root #Group=root WorkingDirectory={$SERVER_PATH}/nezha/dashboard/ -ExecStart={$SERVER_PATH}/nezha/dashboard/nezha web +ExecStart={$SERVER_PATH}/nezha/dashboard/app Restart=always #Environment=DEBUG=true From 7987564401f6a98db9aeffc7fd7974c3a8f3ce9a Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:45:08 +0800 Subject: [PATCH 16/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index a1f94974a..3c6879053 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -138,10 +138,13 @@ Install_dashborad(){ mkdir -p $TARGET_DIR fi + unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR - cd $TARGET_DIR && mv dashboard-linux-${ARCH} app + if [ ! -f $TARGET_DIR/app ];then + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app + fi rm -rf $DOWNLOAD_FILE From fed9f458d1292161917c5f81cf78b1ed841f7277 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:49:41 +0800 Subject: [PATCH 17/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 3c6879053..7d7b190b5 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -129,7 +129,7 @@ Install_dashborad(){ filename="dashboard-${OS}-${ARCH}.zip" if [ ! -f $TARGET_DIR/nezha ];then - DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/dashboard-${OS}-${ARCH}.zip" + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}" DOWNLOAD_FILE="$nezhaDir/$filename" download_file $DOWNLOAD_URL $DOWNLOAD_FILE From 59951470549625a99359ae3c4e66543cea49516e Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 13:59:22 +0800 Subject: [PATCH 18/74] Update index.py --- plugins/nezha/index.py | 133 +++-------------------------------------- 1 file changed, 7 insertions(+), 126 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 646fbf8a2..bfc4b0aeb 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -81,22 +81,16 @@ class App: path = self.getPluginDir() + "/init.d/nezha.tpl" return path - def getInitdAgentConfTpl(self): - path = self.getPluginDir() + "/init.d/nezha-agent.tpl" - return path - def getHomeDir(self): if mw.isAppleSystem(): - user = mw.execShell( - "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() return '/Users/' + user else: return '/root' def getRunUser(self): if mw.isAppleSystem(): - user = mw.execShell( - "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() return user else: return 'root' @@ -109,13 +103,6 @@ class App: return "stop" return 'start' - def status_agent(self): - cmd = "ps -ef | grep nezha-agent | grep -v grep | grep -v python | awk '{print $2}'" - data = mw.execShell(cmd) - if data[0] == '': - return 'stop' - return 'start' - def contentReplace(self, content): service_path = mw.getServerDir() @@ -146,8 +133,8 @@ class App: # systemd systemDir = mw.systemdCfgDir() - systemService = systemDir + '/nezha.service' - systemServiceTpl = self.getPluginDir() + '/init.d/nezha.service.tpl' + systemService = systemDir + '/nezha-dashboard.service' + systemServiceTpl = self.getPluginDir() + '/init.d/nezha-dashboard.service.tpl' if os.path.exists(systemDir) and not os.path.exists(systemService): service_path = mw.getServerDir() se_content = mw.readFile(systemServiceTpl) @@ -166,37 +153,8 @@ class App: return content - def initDAgent(self): - file_tpl = self.getInitdAgentConfTpl() - - initD_path = self.getServerDir() + '/init.d' - if not os.path.exists(initD_path): - os.mkdir(initD_path) - - file_agent_bin = initD_path + '/nezha-agent' - - content = mw.readFile(file_tpl) - content = self.contentReplace(content) - content = self.contentAgentReplace(content) - mw.writeFile(file_agent_bin, content) - mw.execShell('chmod +x ' + file_agent_bin) - - # systemd - sysDir = mw.systemdCfgDir() - sysService = sysDir + '/nezha-agent.service' - sysServiceTpl = self.getPluginDir() + '/init.d/nezha-agent.service.tpl' - service_path = mw.getServerDir() - content = mw.readFile(sysServiceTpl) - content = self.contentReplace(content) - content = self.contentAgentReplace(content) - mw.writeFile(sysService, content) - mw.execShell('systemctl daemon-reload') - - return file_agent_bin - def init_cfg(self): self.initDreplace() - self.initDAgent() def imOp(self, method): @@ -227,19 +185,6 @@ class App: return self.imOp('reload') def agOp(self, method): - file = self.initDAgent() - - path = self.__agent_cfg - if not os.path.exists(path): - return '请先设置Agent配置!' - - if not mw.isAppleSystem(): - cmd = 'systemctl {} {}'.format(method, 'nezha-agent') - data = mw.execShell(cmd) - if data[1] == '': - return 'ok' - return 'fail' - data = mw.execShell(file + ' ' + method) if data[1] == '': return 'ok' @@ -258,87 +203,23 @@ class App: return self.agentOp('reload') def initd_status(self): - cmd = 'systemctl status nezha | grep loaded | grep "enabled;"' + cmd = 'systemctl status nezha-dashboard | grep loaded | grep "enabled;"' data = mw.execShell(cmd) if data[0] == '': return 'fail' return 'ok' def initd_install(self): - mw.execShell('systemctl enable nezha') + mw.execShell('systemctl enable nezha-dashboard') return 'ok' def initd_uninstall(self): - mw.execShell('systemctl disable nezha') + mw.execShell('systemctl disable nezha-dashboard') return 'ok' def conf(self): return self.getServerDir() + '/dashboard/data/config.yaml' - def nezha_cfg(self): - path = self.__cfg - if not os.path.exists(path): - d = {} - cmd_un = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -u ""' - mw.execShell(cmd_un) - td = mw.execShell(cmd_un) - d['username'] = td[0].strip() - - pwd = mw.getRandomString(16) - cmd_pwd = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -u "" -p ' + pwd - td = mw.execShell(cmd_pwd) - d['password'] = pwd - - mw.writeFile(path, mw.enDoubleCrypt('nezha', mw.getJson(d))) - - info = mw.readFile(path) - info = mw.deDoubleCrypt('nezha', info) - - info = json.loads(info) - return mw.returnJson(True, 'ok', info) - - def nezha_save_cfg(self): - args = self.getArgs() - data = self.checkArgs(args, ['username', 'password']) - if not data[0]: - return data[1] - path = self.__cfg - - cmd = 'cd ' + self.getServerDir() + '/dashboard && ./nezha conf -su "' + \ - args['username'] + '" -p ' + args['password'] - # print(cmd) - t = mw.execShell(cmd) - # print(t) - mw.writeFile(path, mw.enDoubleCrypt('nezha', mw.getJson(args))) - return mw.returnJson(True, '修改成功!') - - def get_agent_cfg(self): - path = self.__agent_cfg - info = mw.readFile(path) - info = mw.deDoubleCrypt('agent', info) - info = json.loads(info) - return info - - def agent_cfg(self): - path = self.__agent_cfg - if not os.path.exists(path): - d = {} - d['host'] = '127.0.0.1:5555' - d['secret'] = 'secret' - mw.writeFile(path, mw.enDoubleCrypt('agent', mw.getJson(d))) - - info = self.get_agent_cfg() - return mw.returnJson(True, 'ok', info) - - def agent_save_cfg(self): - args = self.getArgs() - data = self.checkArgs(args, ['host', 'secret']) - if not data[0]: - return data[1] - path = self.__agent_cfg - mw.writeFile(path, mw.enDoubleCrypt('agent', mw.getJson(args))) - return mw.returnJson(True, '修改成功!') - def run_log(self): return self.getServerDir() + '/logs/nezha.log' From fb53354956f4e08d6a1c32115123ff4a60d3fd74 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:03:54 +0800 Subject: [PATCH 19/74] Update index.py --- plugins/nezha/index.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index bfc4b0aeb..8b259f656 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -64,7 +64,7 @@ class App: return "Release failed {}".format(e) def openPort(self): - for i in ["9527", "5555"]: + for i in ["8008", "5555"]: self.__release_port(i) return True @@ -96,21 +96,18 @@ class App: return 'root' def status(self): - cmd = "ps -ef|grep " + self.getPluginName() + \ - " |grep -v grep | grep -v nezha-agent | grep -v python | awk '{print $2}'" + cmd = "ps -ef|grep nezha-dashboard |grep -v grep | grep -v python | awk '{print $2}'" data = mw.execShell(cmd) if data[0] == '': return "stop" return 'start' def contentReplace(self, content): - service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getFatherDir()) content = content.replace('{$SERVER_PATH}', service_path) content = content.replace('{$RUN_USER}', self.getRunUser()) content = content.replace('{$HOME_DIR}', self.getHomeDir()) - return content def initDreplace(self): @@ -157,7 +154,6 @@ class App: self.initDreplace() def imOp(self, method): - file = self.initDreplace() if not mw.isAppleSystem(): From 48706d01f9d3e37dade4466c1ff352714d2e4801 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:04:21 +0800 Subject: [PATCH 20/74] Update index.py --- plugins/nezha/index.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 8b259f656..ce3ad2fe2 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -106,8 +106,6 @@ class App: service_path = mw.getServerDir() content = content.replace('{$ROOT_PATH}', mw.getFatherDir()) content = content.replace('{$SERVER_PATH}', service_path) - content = content.replace('{$RUN_USER}', self.getRunUser()) - content = content.replace('{$HOME_DIR}', self.getHomeDir()) return content def initDreplace(self): From b7f671d1d562366dfe83a3b8924c1756c7bdf730 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:04:45 +0800 Subject: [PATCH 21/74] update --- .../init.d/{nezha.service.tpl => nezha-dashboard.service.tpl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/nezha/init.d/{nezha.service.tpl => nezha-dashboard.service.tpl} (100%) diff --git a/plugins/nezha/init.d/nezha.service.tpl b/plugins/nezha/init.d/nezha-dashboard.service.tpl similarity index 100% rename from plugins/nezha/init.d/nezha.service.tpl rename to plugins/nezha/init.d/nezha-dashboard.service.tpl From 762e88cc44b81e63c8bfdc88b80e0552084826fb Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:05:03 +0800 Subject: [PATCH 22/74] Update index.py --- plugins/nezha/index.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index ce3ad2fe2..3b289b4a3 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -139,15 +139,6 @@ class App: return file_bin - def contentAgentReplace(self, content): - path = self.__agent_cfg - if os.path.exists(path): - data = self.get_agent_cfg() - content = content.replace('{$APP_HOST}', data['host']) - content = content.replace('{$APP_SECRET}', data['secret']) - - return content - def init_cfg(self): self.initDreplace() From c6a060fde522adb767bababe94a788c9dd1b635d Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:09:51 +0800 Subject: [PATCH 23/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 7d7b190b5..e5b5adfac 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -125,7 +125,7 @@ download_file() { Install_dashborad(){ echo '正在安装哪吒监控...' - mkdir -p $serverPath/source + mkdir -p $nezhaDir filename="dashboard-${OS}-${ARCH}.zip" if [ ! -f $TARGET_DIR/nezha ];then From c704aa08172928fc1973cf0f79bc21480b5687b5 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:10:03 +0800 Subject: [PATCH 24/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index e5b5adfac..dd626f476 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -8,8 +8,6 @@ rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") nezhaDir=${serverPath}/source/nezha - - VERSION=2.2.6 # bash install.sh install 2.2.6 @@ -19,8 +17,6 @@ VERSION=2.2.6 bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - - ARCH="amd64" geo_check() { From 548d87e3398b4d5821392618929f54d81e620e29 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:12:14 +0800 Subject: [PATCH 25/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index dd626f476..6fe3a28d2 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -128,7 +128,10 @@ Install_dashborad(){ DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}" DOWNLOAD_FILE="$nezhaDir/$filename" - download_file $DOWNLOAD_URL $DOWNLOAD_FILE + + if [ ! -f $DOWNLOAD_FILE ];then + download_file $DOWNLOAD_URL $DOWNLOAD_FILE + fi if [ ! -d $TARGET_DIR ]; then mkdir -p $TARGET_DIR From a0be16c0fa1a323f0a8c9dd486b329c5e2a480f5 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:12:24 +0800 Subject: [PATCH 26/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 6fe3a28d2..ba77218c6 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -137,7 +137,6 @@ Install_dashborad(){ mkdir -p $TARGET_DIR fi - unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR @@ -146,10 +145,7 @@ Install_dashborad(){ fi rm -rf $DOWNLOAD_FILE - - fi - } Install_App() From a02ef2575bc4239394d9a4bc31bc3f49c1bb1518 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:21:10 +0800 Subject: [PATCH 27/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index ba77218c6..2d8ff3821 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -141,7 +141,7 @@ Install_dashborad(){ echo "TARGET_DIR:"$TARGET_DIR if [ ! -f $TARGET_DIR/app ];then - cd $TARGET_DIR && mv dashboard-linux-${ARCH} app + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi rm -rf $DOWNLOAD_FILE @@ -160,6 +160,7 @@ Install_App() echo "$VERSION" > $serverPath/nezha/version.pl cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg fi + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start echo 'install successful' } From aa8535d51337feb7b80488312ecb3591073016c7 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:22:40 +0800 Subject: [PATCH 28/74] update --- plugins/nezha/index.py | 4 ++-- plugins/nezha/install.sh | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 3b289b4a3..01bf7c4fb 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -96,7 +96,7 @@ class App: return 'root' def status(self): - cmd = "ps -ef|grep nezha-dashboard |grep -v grep | grep -v python | awk '{print $2}'" + cmd = "ps -ef|grep dashboard/app |grep -v grep | grep -v python | awk '{print $2}'" data = mw.execShell(cmd) if data[0] == '': return "stop" @@ -146,7 +146,7 @@ class App: file = self.initDreplace() if not mw.isAppleSystem(): - cmd = 'systemctl {} {}'.format(method, self.getPluginName()) + cmd = 'systemctl {} {}'.format(method, "nezha-dashboard") data = mw.execShell(cmd) if data[1] == '': return 'ok' diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh index a559beba8..bd78fc40e 100755 --- a/plugins/nezha/install.sh +++ b/plugins/nezha/install.sh @@ -2,9 +2,13 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH +# systemctl start nezha-dashboard # systemctl status nezha-dashboard + # cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 +# cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py start + curPath=`pwd` rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") From 564ba30f913f3e8ee339d246c41c125db2cd5a6b Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:23:48 +0800 Subject: [PATCH 29/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 2d8ff3821..672cd17e2 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -161,6 +161,7 @@ Install_App() cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg fi cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install echo 'install successful' } From 8235a88ecca3adaa871fc47c58591095dd062028 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:27:32 +0800 Subject: [PATCH 30/74] Update nezha.js --- plugins/nezha/js/nezha.js | 47 ++------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 84b434bec..732b27d21 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -129,53 +129,10 @@ var nezha = { } }); }, - - agent_save_cfg:function(version){ - var host = $("input[name='host']").val(); - var secret = $("input[name='secret']").val(); - - this.send({ - tips:'正在设置中...', - data:{'host':host,'secret':secret}, - method:'agent_save_cfg', - success:function(rdata){ - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); - } - }); - }, - - agent_cfg:function(version){ - this.send({ - tips:'正在获取中...', - method:'agent_cfg', - success:function(data){ - var d = data.data; - var value = '

\ - 地址\ - \ - ,如1.1.1.1:5444\ -

'; - - value += '

\ - 密钥\ - \ - ,密钥\ -

'; - var conf = '
\ - ' + value + '\ -
\ - \ - \ -
\ -
' - $(".soft-man-con").html(conf); - } - }); - }, - readme:function (){ var readme = '
    '; - readme += '
  • 安装时不会自动启动。
  • '; + readme += '
  • 默认用户和密码(admin:admin)
  • '; + readme += '
  • 安装后,立即修改
  • '; readme += '
'; $('.soft-man-con').html(readme); } From 99b77d347a9e31b81ebcb347b630d5e293265ffb Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:30:08 +0800 Subject: [PATCH 31/74] update --- plugins/nezha/index.html | 3 +-- plugins/nezha/js/nezha.js | 44 --------------------------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/plugins/nezha/index.html b/plugins/nezha/index.html index 775b7797b..251804ceb 100755 --- a/plugins/nezha/index.html +++ b/plugins/nezha/index.html @@ -4,8 +4,7 @@

面板服务

面板自启动

-

面板配置

-

面板配置文件

+

配置文件

说明

diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 732b27d21..32680d55b 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -82,53 +82,9 @@ var nezha = { } },'json'); }, - repeatPwd:function (a, id) { $("#"+id).val(randomStrPwd(a)) }, - - save_cfg:function(version){ - var username = $("input[name='username']").val(); - var password = $("input[name='password']").val(); - - this.send({ - tips:'正在设置中...', - data:{'username':username,'password':password}, - method:'nezha_save_cfg', - success:function(rdata){ - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); - } - }); - }, - - cfg:function(version){ - this.send({ - tips:'正在获取中...', - method:'nezha_cfg', - success:function(data){ - var d = data.data; - var value = '

\ - 用户名\ - \ - ,\ -

'; - - value += '

\ - 密码\ - \ - ,\ -

'; - var conf = '
\ - ' + value + '\ -
\ - \ - \ -
\ -
' - $(".soft-man-con").html(conf); - } - }); - }, readme:function (){ var readme = '
    '; readme += '
  • 默认用户和密码(admin:admin)
  • '; From 0b99a4ae745f87450702674448a42722f839b6e8 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:35:51 +0800 Subject: [PATCH 32/74] update --- plugins/nezha/index.py | 17 +++++++++++++++++ plugins/nezha/info.json | 1 + plugins/nezha/install.sh | 1 + 3 files changed, 19 insertions(+) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 01bf7c4fb..2d023cc2c 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -81,6 +81,10 @@ class App: path = self.getPluginDir() + "/init.d/nezha.tpl" return path + def getDataDir(self): + data = self.getServerDir()+"/dashboard/data/sqlite.db" + return data + def getHomeDir(self): if mw.isAppleSystem(): user = mw.execShell("who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() @@ -202,6 +206,19 @@ class App: mw.execShell('systemctl disable nezha-dashboard') return 'ok' + def uninstall_pre_inspection(self): + data_dir = self.getDataDir() + if os.path.exists(data_dir): + self.stop(version) + + if mw.isDebugMode(): + return 'ok' + + from utils.plugin import plugin as MwPlugin + MwPlugin.instance().removeIndex(self.getPluginName(), version) + + return "请手动删除NEZHA[{}]
    rm -rf {}".format(version, self.getServerDir()) + def conf(self): return self.getServerDir() + '/dashboard/data/config.yaml' diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index 65aebf784..5ea998cfd 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -8,6 +8,7 @@ "tip": "soft", "checks": "server/nezha", "path": "server/nezha", + "uninstall_pre_inspection":true, "display": 1, "author": "midoks", "date": "2023-06-26", diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh index bd78fc40e..9404a1040 100755 --- a/plugins/nezha/install.sh +++ b/plugins/nezha/install.sh @@ -8,6 +8,7 @@ export PATH # cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 # cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py start +# cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py status curPath=`pwd` rootPath=$(dirname "$curPath") From 3a8b799df6019ff7f144103b8b565db12597c5c8 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:39:29 +0800 Subject: [PATCH 33/74] Update index.py --- plugins/nezha/index.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 2d023cc2c..a59835bda 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -206,11 +206,15 @@ class App: mw.execShell('systemctl disable nezha-dashboard') return 'ok' + def getVersion(self): + ver_file = self.getServerDir()+"/version.pl" + return mw.readFile(version) + def uninstall_pre_inspection(self): + version = self.getVersion() data_dir = self.getDataDir() if os.path.exists(data_dir): - self.stop(version) - + self.stop() if mw.isDebugMode(): return 'ok' From dbba5db9f7cc184bfda5778c9868e5958498025e Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:40:06 +0800 Subject: [PATCH 34/74] Update info.json --- plugins/nezha/info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index 5ea998cfd..962a9e1e5 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -1,6 +1,6 @@ { "sort": 7, - "ps": "哪吒监控面板&&改造版", + "ps": "哪吒监控面板", "name": "nezha", "title": "哪吒监控", "shell": "install.sh", From f00dc248bd85e6d028998c6cfca7a002f20712f7 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:40:16 +0800 Subject: [PATCH 35/74] Update install.sh --- plugins/nezha/versions/latest/install.sh | 90 +++++++++++++++++++----- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/plugins/nezha/versions/latest/install.sh b/plugins/nezha/versions/latest/install.sh index 6d4665afc..672cd17e2 100755 --- a/plugins/nezha/versions/latest/install.sh +++ b/plugins/nezha/versions/latest/install.sh @@ -7,6 +7,7 @@ rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +nezhaDir=${serverPath}/source/nezha VERSION=2.2.6 # bash install.sh install 2.2.6 @@ -16,19 +17,66 @@ VERSION=2.2.6 bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` - - ARCH="amd64" +geo_check() { + api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace" + ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" + set -- "$api_list" + for url in $api_list; do + text="$(curl -A "$ua" -m 10 -s "$url")" + endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')" + if echo "$text" | grep -qw 'CN'; then + isCN=true + break + elif echo "$url" | grep -q "$endpoint"; then + break + fi + done +} + get_arch() { - TMP_ARCH=`arch` - if [ "$TMP_ARCH" == "x86_64" ];then - ARCH="amd64" - elif [ "$TMP_ARCH" == "aarch64" ];then - ARCH="arm64" - else - echo $ARCH - fi + uname=$(uname -m) + case "$uname" in + amd64|x86_64) + ARCH="amd64" + ;; + i386|i686) + ARCH="386" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *arm*) + ARCH="arm" + ;; + s390x) + ARCH="s390x" + ;; + riscv64) + ARCH="riscv64" + ;; + *) + err "未知架构:$ARCH" + exit 1 + ;; + esac +} + +check_init() { + init=$(readlink /sbin/init) + case "$init" in + *systemd*) + INIT=systemd + ;; + *openrc-init*|*busybox*) + INIT=openrc + ;; + *) + err "Unknown init" + exit 1 + ;; + esac } load_vars() { @@ -73,29 +121,38 @@ download_file() { Install_dashborad(){ echo '正在安装哪吒监控...' - mkdir -p $serverPath/source + mkdir -p $nezhaDir + filename="dashboard-${OS}-${ARCH}.zip" if [ ! -f $TARGET_DIR/nezha ];then + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}" - DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/dashboard-${OS}-${ARCH}.zip" + DOWNLOAD_FILE="$nezhaDir/$filename" - DOWNLOAD_FILE="$(mktemp).zip" - download_file $DOWNLOAD_URL $DOWNLOAD_FILE + if [ ! -f $DOWNLOAD_FILE ];then + download_file $DOWNLOAD_URL $DOWNLOAD_FILE + fi if [ ! -d $TARGET_DIR ]; then mkdir -p $TARGET_DIR fi unzip $DOWNLOAD_FILE -d $TARGET_DIR + echo "TARGET_DIR:"$TARGET_DIR + + if [ ! -f $TARGET_DIR/app ];then + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app + fi + rm -rf $DOWNLOAD_FILE fi - } Install_App() { load_vars get_arch + check_init Install_dashborad @@ -103,6 +160,8 @@ Install_App() echo "$VERSION" > $serverPath/nezha/version.pl cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg fi + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install echo 'install successful' } @@ -110,7 +169,6 @@ Uninstall_App() { cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop_agent rm -rf $serverPath/nezha echo "install fail" } From 66b5f322d91a1e257a932c64a48499cf980e16c6 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:41:00 +0800 Subject: [PATCH 36/74] Update index.py --- plugins/nezha/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index a59835bda..a53f94951 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -208,7 +208,7 @@ class App: def getVersion(self): ver_file = self.getServerDir()+"/version.pl" - return mw.readFile(version) + return mw.readFile(ver_file) def uninstall_pre_inspection(self): version = self.getVersion() From 180cb84b2c78285dae108c6fcf263beaed170c3d Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:42:14 +0800 Subject: [PATCH 37/74] Update index.py --- plugins/nezha/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index a53f94951..48b4cb8da 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -208,7 +208,7 @@ class App: def getVersion(self): ver_file = self.getServerDir()+"/version.pl" - return mw.readFile(ver_file) + return mw.readFile(ver_file).strip() def uninstall_pre_inspection(self): version = self.getVersion() From 431295cec9a15a87378aeceb6f12c6e16f3d81b9 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:42:54 +0800 Subject: [PATCH 38/74] update --- plugins/nezha/index.py | 3 --- plugins/nezha/versions/2.2.6/install.sh | 1 - 2 files changed, 4 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 48b4cb8da..4c38bc753 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -143,9 +143,6 @@ class App: return file_bin - def init_cfg(self): - self.initDreplace() - def imOp(self, method): file = self.initDreplace() diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 672cd17e2..975f8f889 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -158,7 +158,6 @@ Install_App() if [ -d $serverPath/nezha ];then echo "$VERSION" > $serverPath/nezha/version.pl - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg fi cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install From c21ddb5c639f3a218024d98118a2e2cf09754830 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 14:43:12 +0800 Subject: [PATCH 39/74] Update install.sh --- plugins/nezha/versions/2.2.6/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/versions/2.2.6/install.sh b/plugins/nezha/versions/2.2.6/install.sh index 975f8f889..ebd3ce7e4 100755 --- a/plugins/nezha/versions/2.2.6/install.sh +++ b/plugins/nezha/versions/2.2.6/install.sh @@ -169,7 +169,7 @@ Uninstall_App() cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop rm -rf $serverPath/nezha - echo "install fail" + echo "uninstall successful" } action=$1 From 6e4bf9da3e3f2779f1293e2bdbfa3079d96c32b1 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 15:02:39 +0800 Subject: [PATCH 40/74] Update nezha.js --- plugins/nezha/js/nezha.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 32680d55b..107e0aedc 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -87,8 +87,7 @@ var nezha = { }, readme:function (){ var readme = '
      '; - readme += '
    • 默认用户和密码(admin:admin)
    • '; - readme += '
    • 安装后,立即修改
    • '; + readme += '
    • 默认用户和密码(admin:admin),务必在第一时间修改
    • '; readme += '
    '; $('.soft-man-con').html(readme); } From 5bb20a01de71329b35dec6310f48e686752711e4 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 15:16:01 +0800 Subject: [PATCH 41/74] update --- plugins/nezha/install.sh | 1 + plugins/nezha/js/nezha.js | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh index 9404a1040..8fa7779b2 100755 --- a/plugins/nezha/install.sh +++ b/plugins/nezha/install.sh @@ -6,6 +6,7 @@ export PATH # systemctl status nezha-dashboard # cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.6 +# sqlite3 /www/server/nezha/dashboard/data/sqlite.db "DELETE FROM users;" # cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py start # cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py status diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 107e0aedc..9aae443c3 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -88,6 +88,7 @@ var nezha = { readme:function (){ var readme = '
      '; readme += '
    • 默认用户和密码(admin:admin),务必在第一时间修改
    • '; + readme += '
    • 经测试,修改(admin)密码后,需清空cookie,才能正常登录
    • '; readme += '
    '; $('.soft-man-con').html(readme); } From c8589d750c43433468f34d855a3d1d1bf38c87b1 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 15:30:42 +0800 Subject: [PATCH 42/74] Update info.json --- plugins/nezha/info.json | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index 962a9e1e5..574b57ed3 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -8,6 +8,7 @@ "tip": "soft", "checks": "server/nezha", "path": "server/nezha", + "coexist": false, "uninstall_pre_inspection":true, "display": 1, "author": "midoks", From 9e8c736cb40988604496847e8f720eb82b97d5eb Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 15:31:31 +0800 Subject: [PATCH 43/74] Update install.sh --- plugins/nezha/versions/latest/install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/nezha/versions/latest/install.sh b/plugins/nezha/versions/latest/install.sh index 672cd17e2..ebd3ce7e4 100755 --- a/plugins/nezha/versions/latest/install.sh +++ b/plugins/nezha/versions/latest/install.sh @@ -158,7 +158,6 @@ Install_App() if [ -d $serverPath/nezha ];then echo "$VERSION" > $serverPath/nezha/version.pl - cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py init_cfg fi cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install @@ -170,7 +169,7 @@ Uninstall_App() cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop rm -rf $serverPath/nezha - echo "install fail" + echo "uninstall successful" } action=$1 From 701f172276d956abe70b9cd91370efcea98d6eb6 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 15:56:05 +0800 Subject: [PATCH 44/74] Update plugin.py --- web/utils/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/utils/plugin.py b/web/utils/plugin.py index e37f58689..c346a8aea 100644 --- a/web/utils/plugin.py +++ b/web/utils/plugin.py @@ -667,7 +667,9 @@ class plugin(object): self.__plugin_status_data[k] = True else: self.__plugin_status_data[k] = False + # print(self.__plugin_status_data) thisdb.setOption(self.__plugin_status_cachekey, json.dumps(self.__plugin_status_data)) + # print(thisdb.getOption(self.__plugin_status_cachekey)) return True # 多线程检查插件状态 From c3f019d4ffaf22a4c03210ea4a899a09c150cf87 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:00:40 +0800 Subject: [PATCH 45/74] Update plugin.py --- web/utils/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web/utils/plugin.py b/web/utils/plugin.py index c346a8aea..19cf5878d 100644 --- a/web/utils/plugin.py +++ b/web/utils/plugin.py @@ -669,6 +669,7 @@ class plugin(object): self.__plugin_status_data[k] = False # print(self.__plugin_status_data) thisdb.setOption(self.__plugin_status_cachekey, json.dumps(self.__plugin_status_data)) + thisdb.getOption(self.__plugin_status_cachekey) # print(thisdb.getOption(self.__plugin_status_cachekey)) return True From b5fab1fb10210c600172bcc69dc5176d335a4c81 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:03:41 +0800 Subject: [PATCH 46/74] Update plugin.py --- web/utils/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/utils/plugin.py b/web/utils/plugin.py index 19cf5878d..949b28e9c 100644 --- a/web/utils/plugin.py +++ b/web/utils/plugin.py @@ -668,8 +668,8 @@ class plugin(object): else: self.__plugin_status_data[k] = False # print(self.__plugin_status_data) + mw.writeFileLog(json.dumps(self.__plugin_status_data)) thisdb.setOption(self.__plugin_status_cachekey, json.dumps(self.__plugin_status_data)) - thisdb.getOption(self.__plugin_status_cachekey) # print(thisdb.getOption(self.__plugin_status_cachekey)) return True From ef8080b4205c362573c042566ab8b6d73bc0b93c Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:05:57 +0800 Subject: [PATCH 47/74] Update index.py --- plugins/nezha/index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 4c38bc753..f638a531b 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -1,4 +1,5 @@ -# coding:utf-8 +#!/usr/bin/env python +# coding=utf-8 import sys import io From 3e0e84a4f6dfb2de2760e2b6b242277dc8d3fd12 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:09:53 +0800 Subject: [PATCH 48/74] Update index.py --- plugins/mongodb/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index a35fdd001..05cbe2420 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -154,8 +154,8 @@ def checkArgs(data, ck=[]): return (True, mw.returnJson(True, 'ok')) def status(): - data = mw.execShell( - "ps -ef|grep mongod |grep -v mongosh|grep -v grep | grep -v /Applications | grep -v python | grep -v mdserver-web | awk '{print $2}'") + cmd = "ps -ef|grep mongod |grep -v mongosh|grep -v grep | grep -v /Applications | grep -v python | grep -v mdserver-web | awk '{print $2}'" + data = mw.execShell(cmd) if data[0] == '': return 'stop' return 'start' From f0f9dcf4deebdda76818e9863300350b92ed9c74 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:32:59 +0800 Subject: [PATCH 49/74] Update index.py --- plugins/nezha/index.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index f638a531b..51f2025b9 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -65,7 +65,7 @@ class App: return "Release failed {}".format(e) def openPort(self): - for i in ["8008", "5555"]: + for i in ["8008"]: self.__release_port(i) return True @@ -101,8 +101,9 @@ class App: return 'root' def status(self): - cmd = "ps -ef|grep dashboard/app |grep -v grep | grep -v python | awk '{print $2}'" + cmd = "ps -ef|grep nezha/dashboard |grep -v grep | grep -v python | awk '{print $2}'" data = mw.execShell(cmd) + # mw.writeFileLog("data[0]:"+data[0]) if data[0] == '': return "stop" return 'start' From cac468f454a6e9a96dc060e081db02aec5293086 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:33:54 +0800 Subject: [PATCH 50/74] Update plugin.py --- web/utils/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/utils/plugin.py b/web/utils/plugin.py index 949b28e9c..1d2541d13 100644 --- a/web/utils/plugin.py +++ b/web/utils/plugin.py @@ -668,7 +668,7 @@ class plugin(object): else: self.__plugin_status_data[k] = False # print(self.__plugin_status_data) - mw.writeFileLog(json.dumps(self.__plugin_status_data)) + # mw.writeFileLog(json.dumps(self.__plugin_status_data)) thisdb.setOption(self.__plugin_status_cachekey, json.dumps(self.__plugin_status_data)) # print(thisdb.getOption(self.__plugin_status_cachekey)) return True From 5ed9470d83ea9d782a09fe6fc71c4678cc0528fe Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:53:26 +0800 Subject: [PATCH 51/74] update --- plugins/nezha/index.html | 1 + plugins/nezha/js/nezha.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/plugins/nezha/index.html b/plugins/nezha/index.html index 251804ceb..d4d8e642c 100755 --- a/plugins/nezha/index.html +++ b/plugins/nezha/index.html @@ -5,6 +5,7 @@

    面板服务

    面板自启动

    配置文件

    +

    维护功能

    说明

diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 9aae443c3..837d5e4f5 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -85,6 +85,28 @@ var nezha = { repeatPwd:function (a, id) { $("#"+id).val(randomStrPwd(a)) }, + + otherFunc:function(){ + var con = '

\ + \ + \ +

'; + $(".soft-man-con").html(con); + }, + cronAddCheck: function(){ + nezha.postCallback({ + method: "cron_add_check", + success:function(data){ + console.log(data); + } + }); + }, + cronDelCheck:function(){ + orPost('cron_del_check', {}, function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + }); + }, readme:function (){ var readme = '
    '; readme += '
  • 默认用户和密码(admin:admin),务必在第一时间修改
  • '; From 0ad933c5ad25fdfe8dec4278af6dc710f10e2aa4 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:55:33 +0800 Subject: [PATCH 52/74] Update nezha.js --- plugins/nezha/js/nezha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 837d5e4f5..42d5ac02f 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -88,7 +88,7 @@ var nezha = { otherFunc:function(){ var con = '

    \ - \ + \ \

    '; $(".soft-man-con").html(con); From 8f79a4ab86ec4074fc8203842f0545309ca765cc Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:59:23 +0800 Subject: [PATCH 53/74] update --- plugins/nezha/index.py | 11 ++++ plugins/nezha/tool_task.py | 124 +++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 plugins/nezha/tool_task.py diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 51f2025b9..952e5e262 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -228,6 +228,17 @@ class App: def run_log(self): return self.getServerDir() + '/logs/nezha.log' + def cron_add_check(self): + try: + import tool_task + tool_task.createBgTask() + return mw.returnJson(True, '添加检查任务成功') + except Exception as e: + return mw.returnJson(False, '添加检查任务失败:'+str(e)) + + def cron_del_check(self): + return 'ok' + if __name__ == "__main__": func = sys.argv[1] diff --git a/plugins/nezha/tool_task.py b/plugins/nezha/tool_task.py new file mode 100644 index 000000000..183cc8e2e --- /dev/null +++ b/plugins/nezha/tool_task.py @@ -0,0 +1,124 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import json + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw +from utils.crontab import crontab as MwCrontab + + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +def getPluginName(): + return 'nezha' + + +def getPluginDir(): + return mw.getPluginDir() + '/' + getPluginName() + + +def getServerDir(): + return mw.getServerDir() + '/' + getPluginName() + + +def getTaskConf(): + conf = getServerDir() + "/task_config.json" + return conf + + +def getConfigData(): + conf = getTaskConf() + if os.path.exists(conf): + return json.loads(mw.readFile(getTaskConf())) + return { + "task_id": -1, + "period": "day-n", + "where1": "7", + "hour": "0", + "minute": "0", + } + + +def createBgTask(): + removeBgTask() + createBgTaskByName(getPluginName()) + + +def createBgTaskByName(name): + args = getConfigData() + _name = "[NEZHA]自动更新任务" + res = mw.M("crontab").field("id, name").where("name=?", (_name,)).find() + if res: + return True + + if "task_id" in args and args["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (args["task_id"],)).find() + if res and res["id"] == args["task_id"]: + print("计划任务已经存在!") + return True + + mw_dir = mw.getPanelDir() + cmd = ''' +mw_dir=%s +rname=%s +plugin_path=%s +script_path=%s +''' % (mw_dir, name, getServerDir(), getPluginDir()) + cmd += 'echo "bash $script_path/update.sh"' + "\n" + cmd += 'cd $mw_dir && bash $script_path/update.sh' + "\n" + + params = { + 'name': _name, + 'type': args['period'], + 'week': "", + 'where1': args['where1'], + 'hour': args['hour'], + 'minute': args['minute'], + 'save': "", + 'backup_to': "", + 'stype': "toShell", + 'sname': '', + 'sbody': cmd, + 'url_address': '', + } + + task_id = MwCrontab.instance().add(params) + if task_id > 0: + args["task_id"] = task_id + args["name"] = name + mw.writeFile(getTaskConf(), json.dumps(args)) + + +def removeBgTask(): + cfg = getConfigData() + if "task_id" in cfg and cfg["task_id"] > 0: + res = mw.M("crontab").field("id, name").where( + "id=?", (cfg["task_id"],)).find() + if res and res["id"] == cfg["task_id"]: + data = MwCrontab.instance().delete(cfg["task_id"]) + if data["status"]: + cfg["task_id"] = -1 + mw.writeFile(getTaskConf(), json.dumps(cfg)) + return True + return False + + +if __name__ == "__main__": + if len(sys.argv) > 1: + action = sys.argv[1] + if action == "remove": + removeBgTask() + elif action == "add": + createBgTask() From bf29cb1a4d455eb574df71c5ba2ba4833993a1dd Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 16:59:49 +0800 Subject: [PATCH 54/74] Update index.py --- plugins/nezha/index.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 952e5e262..46cd7f7bb 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -237,7 +237,12 @@ class App: return mw.returnJson(False, '添加检查任务失败:'+str(e)) def cron_del_check(self): - return 'ok' + try: + import tool_task + tool_task.removeBgTask() + return mw.returnJson(True, '删除检查任务成功') + except Exception as e: + return mw.returnJson(False, '删除检查任务失败:'+str(e)) if __name__ == "__main__": From 41630ef01ab5c0a3d8ade97999347f03555a6e68 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:03:46 +0800 Subject: [PATCH 55/74] Update install.sh --- plugins/nezha/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh index 8fa7779b2..222757075 100755 --- a/plugins/nezha/install.sh +++ b/plugins/nezha/install.sh @@ -10,6 +10,7 @@ export PATH # cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py start # cd /www/server/mdserver-web && source bin/activate && python3 plugins/nezha/index.py status +# python3 plugins/nezha/index.py cron_add_check curPath=`pwd` rootPath=$(dirname "$curPath") From 3de7928be77a1c0e56022045dd326cdad716e788 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:05:30 +0800 Subject: [PATCH 56/74] Update nezha.js --- plugins/nezha/js/nezha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 42d5ac02f..806a6eb0f 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -94,7 +94,7 @@ var nezha = { $(".soft-man-con").html(con); }, cronAddCheck: function(){ - nezha.postCallback({ + nezha.send({ method: "cron_add_check", success:function(data){ console.log(data); From bce9de1494c7c1d8a419923a3e8a993ed4b0954d Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:05:57 +0800 Subject: [PATCH 57/74] Update nezha.js --- plugins/nezha/js/nezha.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 806a6eb0f..5080317f7 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -95,6 +95,7 @@ var nezha = { }, cronAddCheck: function(){ nezha.send({ + tips:"请求中...", method: "cron_add_check", success:function(data){ console.log(data); From 69b96aa5fa8f3847c19565b3cf1d064491ac0213 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:08:16 +0800 Subject: [PATCH 58/74] Create update.sh --- plugins/nezha/update.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 plugins/nezha/update.sh diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh new file mode 100644 index 000000000..fddbb8d21 --- /dev/null +++ b/plugins/nezha/update.sh @@ -0,0 +1,5 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +echo "ok" \ No newline at end of file From 5e565c06a088e5e470369429c407e34b7e4b9c76 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:09:22 +0800 Subject: [PATCH 59/74] Update nezha.js --- plugins/nezha/js/nezha.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 5080317f7..6ccbb4be3 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -88,8 +88,8 @@ var nezha = { otherFunc:function(){ var con = '

    \ - \ - \ + \ + \

    '; $(".soft-man-con").html(con); }, From a0989ea833c15872a1fb3bc5d48bea4b281b5917 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:12:09 +0800 Subject: [PATCH 60/74] Update nezha.js --- plugins/nezha/js/nezha.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/plugins/nezha/js/nezha.js b/plugins/nezha/js/nezha.js index 6ccbb4be3..25dc1297c 100755 --- a/plugins/nezha/js/nezha.js +++ b/plugins/nezha/js/nezha.js @@ -31,14 +31,6 @@ var nezha = { } var ret_data = $.parseJSON(res.data); - console.log("send:",ret_data); - // if (!ret_data.status){ - // layer.msg(ret_data.msg,{icon:2,time:2000}); - // return; - // } - - // console.log("send2:",ret_data); - if(typeof(callback) == 'function'){ callback(ret_data); } @@ -97,15 +89,18 @@ var nezha = { nezha.send({ tips:"请求中...", method: "cron_add_check", - success:function(data){ - console.log(data); + success:function(rdata){ + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); } }); }, cronDelCheck:function(){ - orPost('cron_del_check', {}, function(data){ - var rdata = $.parseJSON(data.data); - layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + nezha.send({ + tips:"请求中...", + method: "cron_del_check", + success:function(rdata){ + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + } }); }, readme:function (){ From 5fb998c2214c7c06dc70d6b5a8713a83fa449749 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:15:18 +0800 Subject: [PATCH 61/74] update --- plugins/nezha/info.json | 2 +- plugins/nezha/versions/2.2.5/install.sh | 179 ++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 1 deletion(-) create mode 100755 plugins/nezha/versions/2.2.5/install.sh diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json index 574b57ed3..9625c5928 100755 --- a/plugins/nezha/info.json +++ b/plugins/nezha/info.json @@ -4,7 +4,7 @@ "name": "nezha", "title": "哪吒监控", "shell": "install.sh", - "versions":["2.2.6","latest"], + "versions":["2.2.5","2.2.6","latest"], "tip": "soft", "checks": "server/nezha", "path": "server/nezha", diff --git a/plugins/nezha/versions/2.2.5/install.sh b/plugins/nezha/versions/2.2.5/install.sh new file mode 100755 index 000000000..cbb976dac --- /dev/null +++ b/plugins/nezha/versions/2.2.5/install.sh @@ -0,0 +1,179 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +curPath=`pwd` +rootPath=$(dirname "$curPath") +rootPath=$(dirname "$rootPath") +serverPath=$(dirname "$rootPath") + +nezhaDir=${serverPath}/source/nezha +VERSION=2.2.5 + +# cd /www/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.5 +# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/nezha && bash install.sh install 2.2.5 + +bash ${rootPath}/scripts/getos.sh +OSNAME=`cat ${rootPath}/data/osname.pl` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` +ARCH="amd64" + +geo_check() { + api_list="https://blog.cloudflare.com/cdn-cgi/trace https://developers.cloudflare.com/cdn-cgi/trace" + ua="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" + set -- "$api_list" + for url in $api_list; do + text="$(curl -A "$ua" -m 10 -s "$url")" + endpoint="$(echo "$text" | sed -n 's/.*h=\([^ ]*\).*/\1/p')" + if echo "$text" | grep -qw 'CN'; then + isCN=true + break + elif echo "$url" | grep -q "$endpoint"; then + break + fi + done +} + +get_arch() { + uname=$(uname -m) + case "$uname" in + amd64|x86_64) + ARCH="amd64" + ;; + i386|i686) + ARCH="386" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *arm*) + ARCH="arm" + ;; + s390x) + ARCH="s390x" + ;; + riscv64) + ARCH="riscv64" + ;; + *) + err "未知架构:$ARCH" + exit 1 + ;; + esac +} + +check_init() { + init=$(readlink /sbin/init) + case "$init" in + *systemd*) + INIT=systemd + ;; + *openrc-init*|*busybox*) + INIT=openrc + ;; + *) + err "Unknown init" + exit 1 + ;; + esac +} + +load_vars() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + TARGET_DIR="$serverPath/nezha/dashboard" + + # China_IP + # if [[ -z "${CN}" ]]; then + # if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then + # CN=true + # fi + # fi + + GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/nezha/main" + GITHUB_URL="github.com" +} + +# download file +download_file() { + url="${1}" + destination="${2}" + + printf "Fetching ${url} \n\n" + + if test -x "$(command -v curl)"; then + code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}") + elif test -x "$(command -v wget)"; then + code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1) + else + printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n" + exit 1 + fi + + if [ "${code}" != 200 ]; then + printf "\e[1;31mRequest failed with code %s\e[0m\n" $code + exit 1 + else + printf "\n\e[1;33mDownload succeeded\e[0m\n" + fi +} + + +Install_dashborad(){ + echo '正在安装哪吒监控...' + mkdir -p $nezhaDir + filename="dashboard-${OS}-${ARCH}.zip" + + if [ ! -f $TARGET_DIR/nezha ];then + DOWNLOAD_URL="https://${GITHUB_URL}/nezhahq/nezha/releases/download/v${VERSION}/${filename}" + + DOWNLOAD_FILE="$nezhaDir/$filename" + + if [ ! -f $DOWNLOAD_FILE ];then + download_file $DOWNLOAD_URL $DOWNLOAD_FILE + fi + + if [ ! -d $TARGET_DIR ]; then + mkdir -p $TARGET_DIR + fi + + unzip $DOWNLOAD_FILE -d $TARGET_DIR + echo "TARGET_DIR:"$TARGET_DIR + + if [ ! -f $TARGET_DIR/app ];then + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app + fi + + rm -rf $DOWNLOAD_FILE + fi +} + +Install_App() +{ + load_vars + get_arch + check_init + + Install_dashborad + + if [ -d $serverPath/nezha ];then + echo "$VERSION" > $serverPath/nezha/version.pl + fi + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_install + echo 'install successful' +} + +Uninstall_App() +{ + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py initd_uninstall + cd ${rootPath} && python3 ${rootPath}/plugins/nezha/index.py stop + rm -rf $serverPath/nezha + echo "uninstall successful" +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi From c52e707421018da0aa91e1fabd5f040c639e5a5b Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:21:11 +0800 Subject: [PATCH 62/74] Update update.sh --- plugins/nezha/update.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index fddbb8d21..8550f9db1 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -2,4 +2,9 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH +# cd /www/server/mdserver-web && bash plugins/nezha/update.sh + +curPath=`pwd` +echo $curPath + echo "ok" \ No newline at end of file From 3c6f3c50c45c81a26188b305e0d515344c9b04fc Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:28:40 +0800 Subject: [PATCH 63/74] Update update.sh --- plugins/nezha/update.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 8550f9db1..1380ad197 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -7,4 +7,14 @@ export PATH curPath=`pwd` echo $curPath +REPO="nezhahq/nezha" +LATEST_VERSION=$(curl -sL "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name') +echo "最新版本是: $LATEST_VERSION" +NUMBER_LATEST_VERSION=${LATEST_VERSION:1} +echo "最新[NUMBER]是: $NUMBER_LATEST_VERSION" + +INSTALL_VERSION=`cat /www/server/nezha/version.pl` +echo "安装的版本: $INSTALL_VERSION" + + echo "ok" \ No newline at end of file From 6acb39013385df95882fe8a4f841d4aebeeb4014 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:30:59 +0800 Subject: [PATCH 64/74] Update update.sh --- plugins/nezha/update.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 1380ad197..c4db8cf9b 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -3,10 +3,12 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # cd /www/server/mdserver-web && bash plugins/nezha/update.sh - curPath=`pwd` +serverPath=$(dirname "$curPath") echo $curPath +nezhaDir=${serverPath}/source/nezha + REPO="nezhahq/nezha" LATEST_VERSION=$(curl -sL "https://api.github.com/repos/$REPO/releases/latest" | jq -r '.tag_name') echo "最新版本是: $LATEST_VERSION" From d434dce5686ea9b16aac2bcf90afe233e95d24a9 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:40:21 +0800 Subject: [PATCH 65/74] Update update.sh --- plugins/nezha/update.sh | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index c4db8cf9b..150fdd500 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -18,5 +18,85 @@ echo "最新[NUMBER]是: $NUMBER_LATEST_VERSION" INSTALL_VERSION=`cat /www/server/nezha/version.pl` echo "安装的版本: $INSTALL_VERSION" +if [ "$INSTALL_VERSION" == "$NUMBER_LATEST_VERSION" ];then + echo "已经是最新!!!" + exit +fi +get_arch() { + uname=$(uname -m) + case "$uname" in + amd64|x86_64) + ARCH="amd64" + ;; + i386|i686) + ARCH="386" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *arm*) + ARCH="arm" + ;; + s390x) + ARCH="s390x" + ;; + riscv64) + ARCH="riscv64" + ;; + *) + err "未知架构:$ARCH" + exit 1 + ;; + esac +} +get_arch + +download_file() { + url="${1}" + destination="${2}" + + printf "Fetching ${url} \n\n" + + if test -x "$(command -v curl)"; then + code=$(curl --connect-timeout 15 -w '%{http_code}' -L "${url}" -o "${destination}") + elif test -x "$(command -v wget)"; then + code=$(wget -t2 -T15 -O "${destination}" --server-response "${url}" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1) + else + printf "\e[1;31mNeither curl nor wget was available to perform http requests.\e[0m\n" + exit 1 + fi + + if [ "${code}" != 200 ]; then + printf "\e[1;31mRequest failed with code %s\e[0m\n" $code + exit 1 + else + printf "\n\e[1;33mDownload succeeded\e[0m\n" + fi +} + +TARGET_DIR="$serverPath/nezha/dashboard" +filename="dashboard-linux-${ARCH}.zip" +DOWNLOAD_URL="https://github.com/nezhahq/nezha/releases/download/v${NUMBER_LATEST_VERSION}/${filename}" + + +DOWNLOAD_FILE="$nezhaDir/$filename" +if [ ! -f $DOWNLOAD_FILE ];then + download_file $DOWNLOAD_URL $DOWNLOAD_FILE +fi + +if [ ! -d $TARGET_DIR ]; then + mkdir -p $TARGET_DIR +fi + +unzip $DOWNLOAD_FILE -d $TARGET_DIR +echo "TARGET_DIR:"$TARGET_DIR + +if [ ! -f $TARGET_DIR/app ];then + cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app +fi + +echo $DOWNLOAD_URL + +rm -rf $DOWNLOAD_FILE echo "ok" \ No newline at end of file From b39a936fa4dfe3e89455d973c373dd28a9815bbe Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:41:12 +0800 Subject: [PATCH 66/74] Update update.sh --- plugins/nezha/update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 150fdd500..d40b034e6 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -93,6 +93,7 @@ unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR if [ ! -f $TARGET_DIR/app ];then + cd $TARGET_DIR && rm -rf app cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi From 666ebeef0da67f962b72062288105716a98b250e Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:43:53 +0800 Subject: [PATCH 67/74] Update update.sh --- plugins/nezha/update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index d40b034e6..548dfb0cb 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -94,6 +94,7 @@ echo "TARGET_DIR:"$TARGET_DIR if [ ! -f $TARGET_DIR/app ];then cd $TARGET_DIR && rm -rf app + cd $TARGET_DIR && rm -rf dashboard-linux-${ARCH} cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi From ecaa0e99c59ce59f8d4a1bc46dcf56cd88ba050b Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:45:38 +0800 Subject: [PATCH 68/74] Update update.sh --- plugins/nezha/update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 548dfb0cb..0b60aeb4a 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -92,9 +92,9 @@ fi unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR +cd $TARGET_DIR && rm -rf app +cd $TARGET_DIR && rm -rf dashboard-linux-${ARCH} if [ ! -f $TARGET_DIR/app ];then - cd $TARGET_DIR && rm -rf app - cd $TARGET_DIR && rm -rf dashboard-linux-${ARCH} cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi From 1ac541d16e6a2a778e4bea930a28d937ec5cf512 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:48:47 +0800 Subject: [PATCH 69/74] Update update.sh --- plugins/nezha/update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 0b60aeb4a..c7bb6174a 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -89,11 +89,10 @@ if [ ! -d $TARGET_DIR ]; then mkdir -p $TARGET_DIR fi -unzip $DOWNLOAD_FILE -d $TARGET_DIR -echo "TARGET_DIR:"$TARGET_DIR - cd $TARGET_DIR && rm -rf app cd $TARGET_DIR && rm -rf dashboard-linux-${ARCH} +unzip $DOWNLOAD_FILE -d $TARGET_DIR +echo "TARGET_DIR:"$TARGET_DIR if [ ! -f $TARGET_DIR/app ];then cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi From 038bb31ec3132cd66d3d57cba61439b76de49da5 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:48:58 +0800 Subject: [PATCH 70/74] Update update.sh --- plugins/nezha/update.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index c7bb6174a..a5f956392 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -90,7 +90,6 @@ if [ ! -d $TARGET_DIR ]; then fi cd $TARGET_DIR && rm -rf app -cd $TARGET_DIR && rm -rf dashboard-linux-${ARCH} unzip $DOWNLOAD_FILE -d $TARGET_DIR echo "TARGET_DIR:"$TARGET_DIR if [ ! -f $TARGET_DIR/app ];then From 984599c56feed4b15f08f0166096b7119ff54ae9 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:50:22 +0800 Subject: [PATCH 71/74] Update update.sh --- plugins/nezha/update.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index a5f956392..a3b1e90aa 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -97,6 +97,4 @@ if [ ! -f $TARGET_DIR/app ];then fi echo $DOWNLOAD_URL - -rm -rf $DOWNLOAD_FILE echo "ok" \ No newline at end of file From c1f69ea1c79c98e79b33c520a65c4712f18568a1 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:51:11 +0800 Subject: [PATCH 72/74] Update update.sh --- plugins/nezha/update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index a3b1e90aa..7d9452818 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -96,5 +96,6 @@ if [ ! -f $TARGET_DIR/app ];then cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi +systemctl enable nezha-dashboard echo $DOWNLOAD_URL echo "ok" \ No newline at end of file From 6e61a535ca53cceecca399e736f7cee47adb1c2e Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:54:37 +0800 Subject: [PATCH 73/74] Update update.sh --- plugins/nezha/update.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 7d9452818..1ccde78d7 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -96,6 +96,10 @@ if [ ! -f $TARGET_DIR/app ];then cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app fi -systemctl enable nezha-dashboard +systemctl restart nezha-dashboard echo $DOWNLOAD_URL + +if [ -f /www/server/nezha ];then + echo "$NUMBER_LATEST_VERSION" > /www/server/nezha/version.pl +fi echo "ok" \ No newline at end of file From c72c1bc889dfcd94b058ed072a9b6b1c6190eb97 Mon Sep 17 00:00:00 2001 From: dami Date: Mon, 22 Jun 2026 17:59:31 +0800 Subject: [PATCH 74/74] Update update.sh --- plugins/nezha/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh index 1ccde78d7..b7997c490 100644 --- a/plugins/nezha/update.sh +++ b/plugins/nezha/update.sh @@ -99,7 +99,7 @@ fi systemctl restart nezha-dashboard echo $DOWNLOAD_URL -if [ -f /www/server/nezha ];then +if [ -d /www/server/nezha ];then echo "$NUMBER_LATEST_VERSION" > /www/server/nezha/version.pl fi echo "ok" \ No newline at end of file