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'
diff --git a/plugins/nezha/index.html b/plugins/nezha/index.html
index f2eb9c9ea..d4d8e642c 100755
--- a/plugins/nezha/index.html
+++ b/plugins/nezha/index.html
@@ -4,11 +4,8 @@
diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py
index d79ad4bc2..46cd7f7bb 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
@@ -64,7 +65,7 @@ class App:
return "Release failed {}".format(e)
def openPort(self):
- for i in ["9527", "5555"]:
+ for i in ["8008"]:
self.__release_port(i)
return True
@@ -81,49 +82,36 @@ 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 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()
+ 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'
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)
+ # mw.writeFileLog("data[0]:"+data[0])
if data[0] == '':
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()
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):
@@ -146,8 +134,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)
@@ -157,53 +145,11 @@ 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 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):
-
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'
@@ -227,19 +173,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,105 +191,59 @@ 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 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 getVersion(self):
+ ver_file = self.getServerDir()+"/version.pl"
+ return mw.readFile(ver_file).strip()
- def initd_install_agent(self):
- mw.execShell('systemctl enable nezha-agent')
- return 'ok'
+ def uninstall_pre_inspection(self):
+ version = self.getVersion()
+ data_dir = self.getDataDir()
+ if os.path.exists(data_dir):
+ self.stop()
+ if mw.isDebugMode():
+ return 'ok'
- def initd_uninstall_agent(self):
- mw.execShell('systemctl disable nezha-agent')
- 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'
- 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'
+ 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):
+ try:
+ import tool_task
+ tool_task.removeBgTask()
+ return mw.returnJson(True, '删除检查任务成功')
+ except Exception as e:
+ return mw.returnJson(False, '删除检查任务失败:'+str(e))
+
if __name__ == "__main__":
func = sys.argv[1]
diff --git a/plugins/nezha/info.json b/plugins/nezha/info.json
index afb4e6990..9625c5928 100755
--- a/plugins/nezha/info.json
+++ b/plugins/nezha/info.json
@@ -1,17 +1,19 @@
{
"sort": 7,
- "ps": "哪吒监控面板/改造版",
+ "ps": "哪吒监控面板",
"name": "nezha",
"title": "哪吒监控",
"shell": "install.sh",
- "versions":["0.15.2"],
+ "versions":["2.2.5","2.2.6","latest"],
"tip": "soft",
"checks": "server/nezha",
"path": "server/nezha",
+ "coexist": false,
+ "uninstall_pre_inspection":true,
"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/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
diff --git a/plugins/nezha/init.d/nezha.service.tpl b/plugins/nezha/init.d/nezha-dashboard.service.tpl
similarity index 93%
rename from plugins/nezha/init.d/nezha.service.tpl
rename to plugins/nezha/init.d/nezha-dashboard.service.tpl
index 0752b3eb5..baa47a978 100644
--- a/plugins/nezha/init.d/nezha.service.tpl
+++ b/plugins/nezha/init.d/nezha-dashboard.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
diff --git a/plugins/nezha/install.sh b/plugins/nezha/install.sh
index 0a007b9a4..222757075 100755
--- a/plugins/nezha/install.sh
+++ b/plugins/nezha/install.sh
@@ -2,6 +2,16 @@
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
+# 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
+# python3 plugins/nezha/index.py cron_add_check
+
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
@@ -30,12 +40,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/js/nezha.js b/plugins/nezha/js/nezha.js
index b6add248d..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);
}
@@ -82,102 +74,39 @@ 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',
+ otherFunc:function(){
+ var con = '
\
+ \
+ \
+
';
+ $(".soft-man-con").html(con);
+ },
+ cronAddCheck: function(){
+ nezha.send({
+ tips:"请求中...",
+ method: "cron_add_check",
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);
- }
- });
- },
-
- 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',
+ cronDelCheck:function(){
+ nezha.send({
+ tips:"请求中...",
+ method: "cron_del_check",
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 += '- 哪吒面板是改造版,用户名和密码登录【面板配置】,不依赖github/gitee/gitlab。
';
- readme += '- Agent需要先手动填写正确信息。
';
+ readme += '- 默认用户和密码(admin:admin),务必在第一时间修改
';
+ readme += '- 经测试,修改(admin)密码后,需清空cookie,才能正常登录
';
readme += '
';
$('.soft-man-con').html(readme);
}
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()
diff --git a/plugins/nezha/update.sh b/plugins/nezha/update.sh
new file mode 100644
index 000000000..b7997c490
--- /dev/null
+++ b/plugins/nezha/update.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+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"
+NUMBER_LATEST_VERSION=${LATEST_VERSION:1}
+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
+
+cd $TARGET_DIR && rm -rf app
+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
+
+systemctl restart nezha-dashboard
+echo $DOWNLOAD_URL
+
+if [ -d /www/server/nezha ];then
+ echo "$NUMBER_LATEST_VERSION" > /www/server/nezha/version.pl
+fi
+echo "ok"
\ No newline at end of file
diff --git a/plugins/nezha/versions/0.15.2/install.sh b/plugins/nezha/versions/2.2.5/install.sh
similarity index 50%
rename from plugins/nezha/versions/0.15.2/install.sh
rename to plugins/nezha/versions/2.2.5/install.sh
index 4ed401a67..cbb976dac 100755
--- a/plugins/nezha/versions/0.15.2/install.sh
+++ b/plugins/nezha/versions/2.2.5/install.sh
@@ -7,52 +7,90 @@ rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
-VERSION=0.15.2
+nezhaDir=${serverPath}/source/nezha
+VERSION=2.2.5
-# 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
+# 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() {
- 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() {
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
@@ -82,44 +120,29 @@ 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}/midoks/nezha/releases/download/v${VERSION}/nezha-${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
- rm -rf $DOWNLOAD_FILE
- fi
+ echo "TARGET_DIR:"$TARGET_DIR
-}
-
-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
+ if [ ! -f $TARGET_DIR/app ];then
+ cd $TARGET_DIR && mv dashboard-linux-${ARCH} app && chmod +x app
fi
-
- unzip $DOWNLOAD_FILE -d $AGENT_TARGET_DIR
+
rm -rf $DOWNLOAD_FILE
fi
}
@@ -128,25 +151,24 @@ Install_App()
{
load_vars
get_arch
+ check_init
Install_dashborad
- Install_agent
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
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"
+ echo "uninstall successful"
}
action=$1
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..ebd3ce7e4
--- /dev/null
+++ b/plugins/nezha/versions/2.2.6/install.sh
@@ -0,0 +1,180 @@
+#!/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.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"
+
+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
diff --git a/plugins/nezha/versions/latest/install.sh b/plugins/nezha/versions/latest/install.sh
new file mode 100755
index 000000000..ebd3ce7e4
--- /dev/null
+++ b/plugins/nezha/versions/latest/install.sh
@@ -0,0 +1,180 @@
+#!/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.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"
+
+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
diff --git a/web/utils/plugin.py b/web/utils/plugin.py
index e37f58689..1d2541d13 100644
--- a/web/utils/plugin.py
+++ b/web/utils/plugin.py
@@ -667,7 +667,10 @@ class plugin(object):
self.__plugin_status_data[k] = True
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))
+ # print(thisdb.getOption(self.__plugin_status_cachekey))
return True
# 多线程检查插件状态