From ccb02f14a678b61d83bb6dd83167f7007e721eb7 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 11 Dec 2024 18:56:37 +0800 Subject: [PATCH] update --- plugins/webstats/index.py | 6 ++++++ plugins/webstats/info.json | 5 +++-- plugins/webstats/install.sh | 6 +++--- plugins/webstats/tool_task.py | 2 +- web/utils/plugin.py | 17 +++++++++++------ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index 11fbfe40e..26e164152 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -1398,6 +1398,10 @@ def installPreInspection(): return "请先安装OpenResty" return 'ok' +def uninstallPreInspection(): + stop() + return 'ok' + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -1412,6 +1416,8 @@ if __name__ == "__main__": print(reload()) elif func == 'install_pre_inspection': print(installPreInspection()) + elif func == 'uninstall_pre_inspection': + print(uninstallPreInspection()) elif func == 'run_info': print(runInfo()) elif func == 'get_global_conf': diff --git a/plugins/webstats/info.json b/plugins/webstats/info.json index 5623f449f..5d31a1cdc 100755 --- a/plugins/webstats/info.json +++ b/plugins/webstats/info.json @@ -16,10 +16,11 @@ "name": "webstats", "title": "网站统计", "shell": "install.sh", - "versions":["0.2.5"], + "versions":"0.2.5", "tip": "soft", "install_pre_inspection":true, - "checks": "server/webstats", + "uninstall_pre_inspection":true, + "checks": "server/webstats/version.pl", "path": "server/webstats", "display": 1, "author": "midoks", diff --git a/plugins/webstats/install.sh b/plugins/webstats/install.sh index cea3ccda9..bbf82e3fd 100755 --- a/plugins/webstats/install.sh +++ b/plugins/webstats/install.sh @@ -130,12 +130,12 @@ Install_App() if [ -f $serverPath/source/webstats/GeoLite2-City.mmdb ];then cp -rf $serverPath/source/webstats/GeoLite2-City.mmdb $serverPath/webstats/GeoLite2-City.mmdb fi - - echo "${VERSION}" > $serverPath/webstats/version.pl + cd $rootPath && python3 plugins/webstats/index.py start + echo "${VERSION}" > $serverPath/webstats/version.pl echo '网站统计安装完成' - + # delete install data if [ -d $serverPath/source/webstats/lsqlite3_fsl09y ];then rm -rf $serverPath/source/webstats/lsqlite3_fsl09y diff --git a/plugins/webstats/tool_task.py b/plugins/webstats/tool_task.py index e1c1af25d..95f923e28 100644 --- a/plugins/webstats/tool_task.py +++ b/plugins/webstats/tool_task.py @@ -93,7 +93,7 @@ def removeBgTask(): "id=?", (cfg["task_id"],)).find() if res and res["id"] == cfg["task_id"]: data = MwCrontab.instance().delete(cfg["task_id"]) - if data[0]: + if data['status']: # print(data[1]) cfg["task_id"] = -1 mw.writeFile(getTaskConf(), json.dumps(cfg)) diff --git a/web/utils/plugin.py b/web/utils/plugin.py index efae617f2..c52b518d0 100644 --- a/web/utils/plugin.py +++ b/web/utils/plugin.py @@ -481,11 +481,13 @@ class plugin(object): pInfo['setup'] = os.path.exists(pInfo['install_checks']) - if coexist and pInfo['setup']: pInfo['setup_version'] = info['versions'] - else: - pInfo['setup_version'] = self.getVersion(pInfo['install_checks']) + elif pInfo['setup']: + if os.path.isdir(pInfo['install_checks']): + pInfo['setup_version'] = self.getVersion(pInfo['install_checks']) + else: + pInfo['setup_version'] = mw.readFile(pInfo['install_checks']).strip() if 'install_pre_inspection' in info: pInfo['install_pre_inspection'] = info['install_pre_inspection'] @@ -792,7 +794,7 @@ class plugin(object): if 'coexist' in info and info['coexist']: name = info['title'] + '-'+ version if name in data: - del(data[name]) + del(data[name]) thisdb.setOption(self.__plugin_status_cachekey, json.dumps(data)) # shell/bash方式调用 @@ -801,6 +803,10 @@ class plugin(object): args = '', script = 'index', ): + + if mw.inArray(['start','stop','restart','reload','uninstall_pre_inspection','install','uninstall'], func): + self.runByCache(name, func, version) + path = self.__plugin_dir + '/' + name + '/' + script + '.py' if not os.path.exists(path): path = self.__plugin_dir + '/' + name + '/' + name + '.py' @@ -816,8 +822,7 @@ class plugin(object): py_cmd = 'cd ' + mw.getPanelDir() + " && "+ py_cmd data = mw.execShell(py_cmd) - if mw.inArray(['start','stop','restart','reload'], func): - self.runByCache(name, func, version) + # print(data) if mw.isDebugMode():