From db6538b57c3fcad75d20ee08bdeaecf90ec7b5e5 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 22 Sep 2022 00:27:28 +0800 Subject: [PATCH 01/53] =?UTF-8?q?=E7=BD=91=E7=AB=99=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/config_api.py | 2 +- plugins/webstats/info.json | 2 +- plugins/webstats/js/setting.js | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index be5ae448a..980fab20e 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -15,7 +15,7 @@ from flask import request class config_api: - __version = '0.9.10' + __version = '0.9.10.1' def __init__(self): pass diff --git a/plugins/webstats/info.json b/plugins/webstats/info.json index 4ef7e3e01..b710aa1d4 100755 --- a/plugins/webstats/info.json +++ b/plugins/webstats/info.json @@ -1,6 +1,6 @@ { "sort": 7, - "ps": "[DEV]网站统计报表[此插件开发完成后,需要反馈问题,不当小白鼠,慎用!]", + "ps": "[DEV]网站统计报表[此插件-需要小白鼠反馈问题,慎用!]", "name": "webstats", "title": "网站统计", "shell": "install.sh", diff --git a/plugins/webstats/js/setting.js b/plugins/webstats/js/setting.js index d775379be..b1343fd46 100644 --- a/plugins/webstats/js/setting.js +++ b/plugins/webstats/js/setting.js @@ -244,6 +244,25 @@ wsPost('get_global_conf', '' ,{}, function(rdata){ wsGlobalSetting(); }); + + $('#setAll').click(function(){ + var args = "name=webstats&func=reload"; + layer.confirm('您真的要同步所有站点吗?', {icon:3,closeBtn: 2}, function() { + var e = layer.msg('正在同步,请稍候...', {icon: 16,time: 0}); + $.post("/plugins/run", args, function(g) { + layer.close(e); + if( g.status && g.data != 'ok' ) { + layer.msg(g.data, {icon: 2,time: 3000,shade: 0.3,shadeClose: true}); + } else { + layer.msg('同步成功!', {icon: 1,time: 0}); + } + },'json').error(function() { + layer.close(e); + layer.msg('操作异常!', {icon: 1}); + }); + }) + }); + }); /////////////////////////////////////////////// From c2ad19a4de7b879e1728254147763d63f77a4641 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 22 Sep 2022 09:50:18 +0800 Subject: [PATCH 02/53] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E8=A7=A3=E5=8E=8B?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/files_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class/core/files_api.py b/class/core/files_api.py index 63a73783c..6a98376eb 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -759,7 +759,7 @@ class files_api: tmps = mw.getRunDir() + '/tmp/panelExec.log' if stype == 'zip': os.system("cd " + path + " && unzip -d '" + dfile + - "' '" + sfile + "' > " + tmps + " 2>&1") + "' '" + sfile + "' > " + tmps + " 2>&1 &") else: sfiles = '' for sfile in sfile.split(','): @@ -767,7 +767,7 @@ class files_api: continue sfiles += " '" + sfile + "'" os.system("cd " + path + " && tar -zxvf " + sfiles + - " -C " + dfile + " > " + tmps + " 2>&1") + " -C " + dfile + " > " + tmps + " 2>&1 &") self.setFileAccept(dfile) mw.writeLog("文件管理", '文件解压成功!', (sfile, dfile)) return mw.returnJson(True, '文件解压成功!') From 0da43b6ccbfde833ecb4debe3376ce07e4d4cdc8 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 23 Sep 2022 16:10:24 +0800 Subject: [PATCH 03/53] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/firewall_api.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index d49138ed1..fd2008069 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -59,22 +59,30 @@ class firewall_api: # 添加放行端口 def addAcceptPortApi(self): - if not self.getFwStatus(): return mw.returnJson(False, '防火墙启动时,才能添加规则!') - import re - import time port = request.form.get('port', '').strip() ps = request.form.get('ps', '').strip() stype = request.form.get('type', '').strip() + data = self.addAcceptPortArgs(port, ps, stype) + return mw.getJson(data) + + # 添加放行端口 + def addAcceptPortArgs(self, port, ps, stype): + import re + import time + + if not self.getFwStatus(): + self.setFw(0) + rep = "^\d{1,5}(:\d{1,5})?$" if not re.search(rep, port): - return mw.returnJson(False, '端口范围不正确!') + return mw.returnData(False, '端口范围不正确!') if mw.M('firewall').where("port=?", (port,)).count() > 0: - return mw.returnJson(False, '您要放行的端口已存在,无需重复放行!') + return mw.returnData(False, '您要放行的端口已存在,无需重复放行!') msg = mw.getInfo('放行端口[{1}]成功', (port,)) mw.writeLog("防火墙管理", msg) @@ -83,7 +91,7 @@ class firewall_api: self.addAcceptPort(port) self.firewallReload() - return mw.returnJson(True, '添加放行(' + port + ')端口成功!') + return mw.returnData(True, '添加放行(' + port + ')端口成功!') # 删除IP屏蔽 def delDropAddressApi(self): @@ -290,6 +298,9 @@ class firewall_api: return mw.returnJson(True, '开发机不能设置!') status = request.form.get('status', '1') + return mw.getJson(self.setFw(status)) + + def setFw(self, status): if status == '1': if self.__isUfw: mw.execShell('/usr/sbin/ufw disable') @@ -313,7 +324,7 @@ class firewall_api: mw.execShell('/etc/init.d/iptables save') mw.execShell('/etc/init.d/iptables restart') - return mw.returnJson(True, '设置成功!') + return mw.returnData(True, '设置成功!') def delPanelLogsApi(self): mw.M('logs').where('id>?', (0,)).delete() From 4a66b76963e4d0b1867acf4fc899142a4a185f9b Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 23 Sep 2022 16:54:38 +0800 Subject: [PATCH 04/53] Update mw.py --- class/core/mw.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/class/core/mw.py b/class/core/mw.py index 5e87be762..efde194ed 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -406,6 +406,18 @@ def writeFile(filename, str): return False +def backFile(self, file, act=None): + """ + @name 备份配置文件 + @param file 需要备份的文件 + @param act 如果存在,则备份一份作为默认配置 + """ + file_type = "_bak" + if act: + file_type = "_def" + execShell("/usr/bin/cp -p {0} {1}".format(file, file + file_type)) + + def HttpGet(url, timeout=10): """ 发送GET请求 From cf863662e07fd6174502a1d21844fcdba36b2f84 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 23 Sep 2022 17:09:44 +0800 Subject: [PATCH 05/53] Update mw.py --- class/core/mw.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/class/core/mw.py b/class/core/mw.py index efde194ed..81d892da7 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -418,6 +418,18 @@ def backFile(self, file, act=None): execShell("/usr/bin/cp -p {0} {1}".format(file, file + file_type)) +def restoreFile(self, file, act=None): + """ + @name 还原配置文件 + @param file 需要还原的文件 + @param act 如果存在,则还原默认配置 + """ + file_type = "_bak" + if act: + file_type = "_def" + execShell("/usr/bin/cp -p {1} {0}".format(file, file + file_type)) + + def HttpGet(url, timeout=10): """ 发送GET请求 From 4d82835658541e878508ed89b1ee77fd97fbb2e0 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:09:19 +0800 Subject: [PATCH 06/53] =?UTF-8?q?mysql=20=20=E5=88=9D=E5=A7=8B=E5=8C=96=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=86=97=E4=BD=99=E8=B4=A6=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mysql/index.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index d4f9cf8ed..84eb5f41a 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -468,6 +468,18 @@ def initMysql8Pwd(): myconf + ' -uroot -p' + pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + hostname = mw.execShell('hostname')[0] + drop_hostname = "drop user ''@'" + hostname + "'" + + drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user ''@' + hostname + '";' + mw.execShell(drop_hostname) + + drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@' + hostname + '";' + mw.execShell(drop_root_hostname) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True From 4d83c44a73c0b56e5be4bc391bd4434d7a95dfd0 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:11:28 +0800 Subject: [PATCH 07/53] Update index.py --- plugins/mysql/index.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 84eb5f41a..be8c22062 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -426,6 +426,18 @@ def initMysqlPwd(): pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + hostname = mw.execShell('hostname')[0] + drop_hostname = "drop user ''@'" + hostname + "'" + + drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user ''@' + hostname + '";' + mw.execShell(drop_hostname) + + drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@' + hostname + '";' + mw.execShell(drop_root_hostname) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True From 84b0fbc8ef6618e6c2c040f82817923b0329ed38 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:41:52 +0800 Subject: [PATCH 08/53] Update index.py --- plugins/mysql/index.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index be8c22062..30dca4094 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -404,6 +404,7 @@ def initMysqlPwd(): time.sleep(5) serverdir = getServerDir() + myconf = serverdir + "/etc/my.cnf" pwd = mw.getRandomString(16) # cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd From c51e50f815efba7ad4112d1fa6c9975c2fc036f7 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:52:21 +0800 Subject: [PATCH 09/53] Update index.py --- plugins/mysql/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 30dca4094..e78f1d330 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -432,11 +432,11 @@ def initMysqlPwd(): drop_hostname = "drop user ''@'" + hostname + "'" drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ - myconf + ' -uroot -p' + pwd + ' -e "drop user ''@' + hostname + '";' + myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' mw.execShell(drop_hostname) drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ - myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@' + hostname + '";' + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@\'' + hostname + '\'";' mw.execShell(drop_root_hostname) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) From dcfaa1a6c999b252904557d52ee550be3343d491 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:52:37 +0800 Subject: [PATCH 10/53] Update index.py --- plugins/mysql/index.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index e78f1d330..e8a96d352 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -429,7 +429,6 @@ def initMysqlPwd(): # 删除冗余账户 hostname = mw.execShell('hostname')[0] - drop_hostname = "drop user ''@'" + hostname + "'" drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' From ecacb44df8a346224a2add5f64e5b13ef89249f9 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 13:54:48 +0800 Subject: [PATCH 11/53] Update index.py --- plugins/mysql/index.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index e8a96d352..3dda72f36 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -482,14 +482,13 @@ def initMysql8Pwd(): # 删除冗余账户 hostname = mw.execShell('hostname')[0] - drop_hostname = "drop user ''@'" + hostname + "'" drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ - myconf + ' -uroot -p' + pwd + ' -e "drop user ''@' + hostname + '";' + myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' mw.execShell(drop_hostname) drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ - myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@' + hostname + '";' + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@\'' + hostname + '\'";' mw.execShell(drop_root_hostname) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) From 8c410b272d22024100c62b0258ebb342decb0825 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 17:59:16 +0800 Subject: [PATCH 12/53] Update index.py --- plugins/mariadb/index.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 279e28813..8885a0ef4 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -363,6 +363,16 @@ def initMariaDbPwd(): pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + hostname = mw.execShell('hostname')[0] + drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' + mw.execShell(drop_hostname) + + drop_root_hostname = serverdir + '/bin/mysql --defaults-file=' + \ + myconf + ' -uroot -p' + pwd + ' -e "drop user \'root\'@\'' + hostname + '\'";' + mw.execShell(drop_root_hostname) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True From 7a8c83ee905dffb64d0feb7f51bfca9e3eb16982 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 25 Sep 2022 18:54:47 +0800 Subject: [PATCH 13/53] Update index.py --- plugins/mariadb/index.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 8885a0ef4..62112a5d7 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -343,6 +343,7 @@ def initMariaDbPwd(): time.sleep(5) serverdir = getServerDir() + myconf = serverdir + "/etc/my.cnf" pwd = mw.getRandomString(16) db_option = "-S " + serverdir + "/mysql.sock" From b593cc47086da5aa7a4490835422b7895d8ee494 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 17:04:32 +0800 Subject: [PATCH 14/53] init --- plugins/imail/LICENSE | 201 +++++++++++++++++++++++ plugins/imail/ico.png | Bin 0 -> 4184 bytes plugins/imail/index.html | 21 +++ plugins/imail/index.py | 126 ++++++++++++++ plugins/imail/info.json | 18 ++ plugins/imail/init.d/imail.service.tpl | 12 ++ plugins/imail/init.d/imail.tpl | 110 +++++++++++++ plugins/imail/install.sh | 25 +++ plugins/imail/js/imail.js | 95 +++++++++++ plugins/imail/versions/0.0.14/install.sh | 113 +++++++++++++ 10 files changed, 721 insertions(+) create mode 100644 plugins/imail/LICENSE create mode 100755 plugins/imail/ico.png create mode 100755 plugins/imail/index.html create mode 100755 plugins/imail/index.py create mode 100755 plugins/imail/info.json create mode 100644 plugins/imail/init.d/imail.service.tpl create mode 100644 plugins/imail/init.d/imail.tpl create mode 100755 plugins/imail/install.sh create mode 100755 plugins/imail/js/imail.js create mode 100755 plugins/imail/versions/0.0.14/install.sh diff --git a/plugins/imail/LICENSE b/plugins/imail/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/plugins/imail/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/plugins/imail/ico.png b/plugins/imail/ico.png new file mode 100755 index 0000000000000000000000000000000000000000..fd5d7fad16f9db45782ca31657cd58e52f0a7286 GIT binary patch literal 4184 zcmd5<3se(l77j%Ld1!rGS+_%IeeNVPlSw9tqCx@!3ZjDIYSGEeB#b1PI5R*16;Oo2 zy1Qz{cU62px)yQkS|4pHTCG~qsw?Y?;-gkwU2s>Fb#3iG0Rr^E(X*%LY;(@M?tkC+ z`|p2KoDe@Q$bX=}OePD8i8f9KPXt^;{d~avU{Tgw@aX1_3FX9L{`cnH;b4SCJ&bk zLdkInkb&bFNUhMo6pE`MLZ?7ADqN@g4TK@6R*7hps0v0kdK}SX7}Wfe18Y2O)=xG@ zHQNGTVe(W_bm*1J%*;$hrb@x_7A30F>68ej#4s3ez(ST?B%QEb2yM||WCV(59U{xw zAxR@?;?l)1IqqU;Z8j+`H@6^0W&q)4H#+1N60;nP zaxx=u={&_mW-xX!v{igE(;CHVhy!+yFim+3JJNZpJ9?T@GFHY0YzV+r)Z?ckl@mE3 zm2-GR+8OgKyW?x|PGrrUI47;NV`ZFdC#=#+J63?0j-6;puVfz7KyT!zbSaV;V+*Qi zj$&!O$5}mvYSkJXGs6U>qG5!@aac!E6pZ2sslwGbO5@rVZ83I1B<&OyD9j*?3C4981M5(XfVH$52iU}Ln#5Ysbbw3r$u$JCm()Cr8;(w>|k)f?5mW~w8W>S0 zqM&yWdYl-6X!QufX;ZV`HtYRacTW-zq8naFm4NrKjzP&1{5X%&saxCzt1S_)Ca6rwXBW|a;nO(4Nd zN;6X#si5t`R$+Qv*Ahz;o4}dHOp<59EnqjbG-5YGq>ca?3{vCOK||w6inU8^Vpxj- zDwVWb7;p+G<;uE{0G*%F-_q8XlTlf1TOJU&1_r@>d&ipD4nhBG=?P2gG>$4CuKni&LU%nX5;aGjb! zO)aVXMbzq*5s?f*Qm9T16DA6Qaax1IS`|sd6ppGG+^oTI8uY2o(bsM#{W8$^3cN{> zY;Db*qWty2_w(3$Wu;#4?E3#yN-51%O-)ew)Bf1>ZEV`hQBr#lL@?FpJL-k6i$+Nv z%m$um0oYK`;Cz4G{VBG9h?HAwWHigv9g{v`YKY}Bz9=S z&Cq6=1)AL?Fd|E@p4l9Hc&2;C4w^X+X7_==Em$m*c|VIWh9@R3ezYdd+9zp1;l_(6 z4g_pltmr>u`P67-f@1PDb*xpr`Q2XYR$Xq)AY<71?Tc^!asT)o+M07`?V0c0{$N7Jx%DdH zI-$Dp?8EhaC&!xB983-HD_u<>3Ww>xgV$nb1+MgY&{Ln4USqs#@|N7X@aW3E2@~%` z`(${X%T6?r;WJBPQHxifpY4DlE%}>I{R=K`>KYCyMngeB)+G4+M z`%1?D{k#ep9TD-7>5Aruk?GKYGb(a{zjbxcZ5uV>-pSzdm)Mg)*RFFHP6lUtUk-R@ zR!V+_P+XLuLM+gsZanqOHTLs^=F5o{jDGt6>Gf^Aq@f5A3`Bdn>Nix&B~w z{^hOVcaJ^&^o_$`5H_t3zx-ycYWX#K=*S*LdKWP}>0fXDzNS82bt(PWhI!8UD-SKm zIbZ#Kp$QsmT3_p$Qa@?W))z-=vlSoB3;d?n*Tp{fKJU?xvU5&>)@#Tr*Ve|eAGG8{ z-O7ptc5m&!hm_s*e`qZ{kRohMtb^v|#8o^Gyt5;s=697R)_uVbgku-g`MYYm&IlWR z(0AP2koZD1m|&h(F!NMF-pBm{PJb7DAiH+I=H6jq-jXiYQijg0%qzG(-c>sA!P%1Xq+6f- zZQ-us`jx>4oSXLN?yNhN{?+aqWtV;5oxZfR&)(^kbnR29&r5%37rgY(*B4&4Y`XI*gDhLq}~$Z4O?>_vm(%CX+D6K9qxf3jxb zTN%}V?Q(r|_2E<5{y|^4wg))M2km~lXqCmabzI@Ii7|Pb$0aRIOIu#!qujPAG<@3) zOK$#_s_?=Skw@+is1I^|)BAjF=|kaI$&%cX-1_>W1YeLFUrN zjf~kbzrWSmW!$JlrEEv#)vaE4cZ^Ni@chnjrR&76ojDsGs0Q9G47xNkY0rtxc=ASX zUGE^p)Toe}?xk5vR|Q_~U$)J6&W5S`s4fPd&l;x;`iGF%fFC-KmDKo*z(S}u9@_JX zU?^wvzMRO}!nFOW{sD)N%B#;^`|$l(wCX*Zq003s0Cwym3F4LD?R1Jnd*=X#sI X3+b8nanE?^zkf_*ym4>D?1eu9Gr#88 literal 0 HcmV?d00001 diff --git a/plugins/imail/index.html b/plugins/imail/index.html new file mode 100755 index 000000000..becb767d2 --- /dev/null +++ b/plugins/imail/index.html @@ -0,0 +1,21 @@ +
+
+
+

服务

+

自启动

+

配置文件

+

配置修改

+

用户列表

+

运行日志

+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/plugins/imail/index.py b/plugins/imail/index.py new file mode 100755 index 000000000..98e709df3 --- /dev/null +++ b/plugins/imail/index.py @@ -0,0 +1,126 @@ +# coding:utf-8 + +import sys +import io +import os +import time +import re +import socket +import json + +from datetime import datetime + +sys.path.append(os.getcwd() + "/class/core") +import mw + +app_debug = False +if mw.isAppleSystem(): + app_debug = True + + +class App: + __setupPath = '/www/server/imail' + + def __init__(self): + self.__setupPath = self.getServerDir() + + def getArgs(self): + args = sys.argv[3:] + tmp = {} + args_len = len(args) + + if args_len == 1: + t = args[0].strip('{').strip('}') + t = t.split(':') + tmp[t[0]] = t[1] + elif args_len > 1: + for i in range(len(args)): + t = args[i].split(':') + tmp[t[0]] = t[1] + + return tmp + + def getPluginName(self): + return 'mail' + + def getPluginDir(self): + return mw.getPluginDir() + '/' + self.getPluginName() + + def getServerDir(self): + return mw.getServerDir() + '/' + self.getPluginName() + + def status(self): + data = mw.execShell( + "ps -ef|grep " + self.getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") + if data[0] == '': + return 'stop' + return 'start' + + def initDreplace(self): + + file_tpl = self.getInitdConfTpl() + service_path = mw.getServerDir() + + initD_path = self.getServerDir() + '/init.d' + if not os.path.exists(initD_path): + os.mkdir(initD_path) + file_bin = initD_path + '/' + self.getPluginName() + + if not os.path.exists(file_bin): + content = mw.readFile(file_tpl) + content = contentReplace(content) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # systemd + # systemDir = mw.systemdCfgDir() + # systemService = systemDir + '/gogs.service' + # systemServiceTpl = getPluginDir() + '/init.d/gogs.service.tpl' + # if os.path.exists(systemDir) and not os.path.exists(systemService): + # service_path = mw.getServerDir() + # se_content = mw.readFile(systemServiceTpl) + # se_content = se_content.replace('{$SERVER_PATH}', service_path) + # mw.writeFile(systemService, se_content) + # mw.execShell('systemctl daemon-reload') + + # log_path = getServerDir() + '/log' + # if not os.path.exists(log_path): + # os.mkdir(log_path) + + return file_bin + + def imOp(self, method): + file = self.initDreplace() + + if not mw.isAppleSystem(): + data = mw.execShell('systemctl ' + method + ' imail') + if data[1] == '': + return 'ok' + return 'fail' + + data = mw.execShell(__SR + file + ' ' + method) + if data[1] == '': + return 'ok' + return data[0] + + def start(self): + return self.imOp('start') + + def stop(self): + return self.imOp('stop') + + def restart(self): + return self.imOp('restart') + + def reload(self): + return self.imOp('reload') + + +if __name__ == "__main__": + func = sys.argv[1] + classApp = App() + try: + data = eval("classApp." + func + "()") + print(data) + except Exception as e: + print('error:' + str(e)) diff --git a/plugins/imail/info.json b/plugins/imail/info.json new file mode 100755 index 000000000..406806c19 --- /dev/null +++ b/plugins/imail/info.json @@ -0,0 +1,18 @@ +{ + "sort": 7, + "ps": "简单邮件服务[DEV]", + "name": "imail", + "title": "邮件服务", + "shell": "install.sh", + "versions":["0.0.14"], + "updates":["0.0.14"], + "tip": "soft", + "checks": "server/imail", + "path": "server/imail", + "display": 1, + "author": "midoks", + "date": "2022-09-26", + "home": "https://github.com/midoks/mdserver-web", + "type": 0, + "pid": "5" +} \ No newline at end of file diff --git a/plugins/imail/init.d/imail.service.tpl b/plugins/imail/init.d/imail.service.tpl new file mode 100644 index 000000000..d5473e613 --- /dev/null +++ b/plugins/imail/init.d/imail.service.tpl @@ -0,0 +1,12 @@ +[Unit] +Description=Gogs +After=network.target + +[Service] +Type=forking +ExecStart={$SERVER_PATH}/imail/init.d/imail start +ExecStop={$SERVER_PATH}/imail/init.d/imail stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/plugins/imail/init.d/imail.tpl b/plugins/imail/init.d/imail.tpl new file mode 100644 index 000000000..042fe3f4e --- /dev/null +++ b/plugins/imail/init.d/imail.tpl @@ -0,0 +1,110 @@ +#!/bin/sh +# +# /etc/rc.d/init.d/imail +# +# Runs the imail +# +# +# chkconfig: - 85 15 +# + +### BEGIN INIT INFO +# Provides: imail +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: mysql +# Should-Stop: mysql +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start imail at boot time. +# Description: Control imail. +### END INIT INFO + +# Source function library. +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 + +# Default values +export HOME={$HOME_DIR} +export USER={$RUN_USER} +NAME=imail +GOGS_HOME={$SERVER_PATH}/imail +GOGS_PATH=${GOGS_HOME}/$NAME +GOGS_USER={$RUN_USER} +SERVICENAME="imail" +LOCKFILE=/tmp/imail.lock +LOGPATH=${GOGS_HOME}/log +LOGFILE=${LOGPATH}/imail.log +RETVAL=0 + + +[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME +DAEMON_OPTS="--check $NAME" +[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}" + + +status(){ + isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` + if [ "$isStart" == '' ];then + echo -e "${SERVICENAME} not running" + else + echo -e "${SERVICENAME}(pid $(echo $isStart)) already running" + fi +} + +start() { + isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` + if [ "$isStart" != '' ];then + echo "${SERVICENAME}(pid $(echo $isStart)) already running" + return $RETVAL + fi + + cd ${GOGS_HOME} + echo -e "Starting ${SERVICENAME}: \c" + ${GOGS_PATH} web > ${LOGFILE} 2>&1 & + RETVAL=$? + [ $RETVAL = 0 ] && touch ${LOCKFILE} && echo -e "\033[32mdone\033[0m" + return $RETVAL +} + +stop() { + + pids=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'` + arr=($pids) + echo -e "Stopping gogs... \c" + for p in ${arr[@]} + do + kill -9 $p + done + echo -e "\033[32mdone\033[0m" +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart) + stop + start + ;; + reload) + stop + start + ;; + *) + echo "Usage: ${NAME} {start|stop|status|restart}" + exit 1 + ;; +esac +exit $RETVAL diff --git a/plugins/imail/install.sh b/plugins/imail/install.sh new file mode 100755 index 000000000..04a563fe9 --- /dev/null +++ b/plugins/imail/install.sh @@ -0,0 +1,25 @@ +#!/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") + +install_tmp=${rootPath}/tmp/mw_install.pl + +action=$1 +type=$2 + +if [ "${2}" == "" ];then + echo '缺少安装脚本...' > $install_tmp + exit 0 +fi + +if [ ! -d $curPath/versions/$2 ];then + echo '缺少安装脚本2...' > $install_tmp + exit 0 +fi + +sh -x $curPath/versions/$2/install.sh $1 diff --git a/plugins/imail/js/imail.js b/plugins/imail/js/imail.js new file mode 100755 index 000000000..56fc09190 --- /dev/null +++ b/plugins/imail/js/imail.js @@ -0,0 +1,95 @@ +var mail = { + plugin_name: 'imail', + init: function () { + var _this = this; + }, + + str2Obj:function(str){ + var data = {}; + kv = str.split('&'); + for(i in kv){ + v = kv[i].split('='); + data[v[0]] = v[1]; + } + return data; + }, + + send:function(info){ + var tips = info['tips']; + var method = info['method']; + var args = info['data']; + var callback = info['success']; + + var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); + + var data = {}; + data['name'] = 'mail'; + data['func'] = method; + data['version'] = $('.plugin_version').attr('version'); + + if (typeof(args) == 'string'){ + data['args'] = JSON.stringify(this.str2Obj(args)); + } else { + data['args'] = JSON.stringify(args); + } + + $.post('/plugins/run', data, function(res) { + layer.close(loadT); + if (!res.status){ + layer.msg(res.msg,{icon:2,time:10000}); + return; + } + + 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); + } + },'json'); + }, + postCallback:function(info){ + var tips = info['tips']; + var method = info['method']; + var args = info['data']; + var callback = info['success']; + + var loadT = layer.msg(tips, { icon: 16, time: 0, shade: 0.3 }); + + var data = {}; + data['name'] = 'mail'; + data['func'] = method; + data['version'] = $('.plugin_version').attr('version'); + + if (typeof(args) == 'string'){ + data['args'] = JSON.stringify(this.str2Obj(args)); + } else { + data['args'] = JSON.stringify(args); + } + + $.post('/plugins/callback', data, function(res) { + + layer.close(loadT); + if (!res.status){ + layer.msg(res.msg,{icon:2,time:10000}); + return; + } + + var ret_data = $.parseJSON(res.data); + if (!ret_data.status){ + layer.msg(ret_data.msg,{icon:2,time:2000}); + return; + } + + if(typeof(callback) == 'function'){ + callback(res); + } + },'json'); + } +} diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.14/install.sh new file mode 100755 index 000000000..d9b4d4a4a --- /dev/null +++ b/plugins/imail/versions/0.0.14/install.sh @@ -0,0 +1,113 @@ +#!/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") + +install_tmp=${rootPath}/tmp/mw_install.pl +VERSION=0.0.14 + +## curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash +## debug: +## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 1.0 + +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}'` + +check_go_environment() { + if test ! -x "$(command -v go)"; then + printf "\e[1;31mmissing go running environment\e[0m\n" + exit 1 + fi +} + +get_arch() { + echo "package main +import ( + \"fmt\" + \"runtime\" +) +func main() { fmt.Println(runtime.GOARCH) }" > /tmp/go_arch.go + + ARCH=$(go run /tmp/go_arch.go) +} + +load_vars() { + OS=$(uname | tr '[:upper:]' '[:lower:]') + TARGET_DIR="$serverPath/imail" +} + +get_download_url() { + DOWNLOAD_URL="https://github.com/midoks/imail/releases/download/$VERSION/imail_${VERSION}_${OS}_${ARCH}.tar.gz" +} + +# 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_App() +{ + echo '正在安装脚本文件...' > $install_tmp + mkdir -p $serverPath/source + + check_go_environment + load_vars + get_arch + get_download_url + + DOWNLOAD_FILE="$(mktemp).tar.gz" + download_file $DOWNLOAD_URL $DOWNLOAD_FILE + + if [ ! -d "$TARGET_DIR" ]; then + mkdir -p "$TARGET_DIR" + fi + + tar -C "$TARGET_DIR" -zxf $DOWNLOAD_FILE + rm -rf $DOWNLOAD_FILE + + pushd "$TARGET_DIR/scripts" >/dev/null 2>&1 + bash make.sh + + systemctl daemon-reload + + echo "$VERSION" > $serverPath/imail/version.pl + echo '安装完成' > $install_tmp +} + +Uninstall_App() +{ + + echo "Uninstall_Mail" > $install_tmp +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi From f341c80fbea8d1dd165e41712c84db81029edf38 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 20:51:23 +0800 Subject: [PATCH 15/53] up imail --- plugins/imail/index.html | 3 +- plugins/imail/index.py | 78 ++++++++++++- plugins/imail/init.d/imail.tpl | 141 ++++++++++------------- plugins/imail/versions/0.0.14/install.sh | 5 +- 4 files changed, 136 insertions(+), 91 deletions(-) diff --git a/plugins/imail/index.html b/plugins/imail/index.html index becb767d2..a2c3eb779 100755 --- a/plugins/imail/index.html +++ b/plugins/imail/index.html @@ -4,8 +4,6 @@

服务

自启动

配置文件

-

配置修改

-

用户列表

运行日志

@@ -17,5 +15,6 @@ \ No newline at end of file diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 98e709df3..3b8bf0f55 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -20,10 +20,17 @@ if mw.isAppleSystem(): class App: __setupPath = '/www/server/imail' + __SR = '' def __init__(self): self.__setupPath = self.getServerDir() + self.__SR = '''#!/bin/bash + PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin + export PATH + export USER=%s + export HOME=%s && ''' % ( self.getRunUser(), self.getHomeDir()) + def getArgs(self): args = sys.argv[3:] tmp = {} @@ -41,7 +48,7 @@ class App: return tmp def getPluginName(self): - return 'mail' + return 'imail' def getPluginDir(self): return mw.getPluginDir() + '/' + self.getPluginName() @@ -49,6 +56,26 @@ class App: def getServerDir(self): return mw.getServerDir() + '/' + self.getPluginName() + def getInitdConfTpl(self): + path = self.getPluginDir() + "/init.d/imail.tpl" + return path + + def getHomeDir(self): + if mw.isAppleSystem(): + 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() + return user + else: + return 'root' + def status(self): data = mw.execShell( "ps -ef|grep " + self.getPluginName() + " |grep -v grep | grep -v python | awk '{print $2}'") @@ -56,6 +83,16 @@ class App: return 'stop' return 'start' + def contentReplace(self, content): + + service_path = mw.getServerDir() + content = content.replace('{$ROOT_PATH}', mw.getRootDir()) + 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): file_tpl = self.getInitdConfTpl() @@ -68,7 +105,9 @@ class App: if not os.path.exists(file_bin): content = mw.readFile(file_tpl) - content = contentReplace(content) + print(file_tpl) + print(content) + content = self.contentReplace(content) mw.writeFile(file_bin, content) mw.execShell('chmod +x ' + file_bin) @@ -93,12 +132,13 @@ class App: file = self.initDreplace() if not mw.isAppleSystem(): - data = mw.execShell('systemctl ' + method + ' imail') + cmd = 'systemctl {} {}'.format(method, self.getPluginName()) + data = mw.execShell(cmd) if data[1] == '': return 'ok' return 'fail' - data = mw.execShell(__SR + file + ' ' + method) + data = mw.execShell(self.__SR + file + ' ' + method) if data[1] == '': return 'ok' return data[0] @@ -115,6 +155,36 @@ class App: def reload(self): return self.imOp('reload') + def initd_status(self): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + cmd = 'systemctl status imail | grep loaded | grep "enabled;"' + data = mw.execShell(cmd) + if data[0] == '': + return 'fail' + return 'ok' + + def initd_install(self): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl enable imail') + return 'ok' + + def initd_uinstall(self): + if mw.isAppleSystem(): + return "Apple Computer does not support" + + mw.execShell('systemctl disable imail') + return 'ok' + + def conf(self): + return self.getServerDir() + '/custom/conf/app.conf' + + def run_log(self): + return self.getServerDir() + '/logs/imail.log' + if __name__ == "__main__": func = sys.argv[1] diff --git a/plugins/imail/init.d/imail.tpl b/plugins/imail/init.d/imail.tpl index 042fe3f4e..4de3daf08 100644 --- a/plugins/imail/init.d/imail.tpl +++ b/plugins/imail/init.d/imail.tpl @@ -1,25 +1,19 @@ -#!/bin/sh -# -# /etc/rc.d/init.d/imail -# -# Runs the imail -# -# -# chkconfig: - 85 15 -# +#!/bin/bash +# chkconfig: 2345 55 25 +# description: Imail Service ### BEGIN INIT INFO -# Provides: imail -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Should-Start: mysql -# Should-Stop: mysql +# Provides: bt +# Required-Start: $all +# Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Start imail at boot time. -# Description: Control imail. +# Short-Description: starts Imail +# Description: starts the Imail ### END INIT INFO +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin + # Source function library. if [ -f /etc/init.d/functions ];then . /etc/init.d/functions @@ -29,54 +23,43 @@ if [ -f /etc/rc.d/init.d/functions ];then . /etc/rc.d/init.d/functions fi -# Default values -export HOME={$HOME_DIR} -export USER={$RUN_USER} -NAME=imail -GOGS_HOME={$SERVER_PATH}/imail -GOGS_PATH=${GOGS_HOME}/$NAME -GOGS_USER={$RUN_USER} +app_path={$SERVER_PATH}/imail SERVICENAME="imail" -LOCKFILE=/tmp/imail.lock -LOGPATH=${GOGS_HOME}/log -LOGFILE=${LOGPATH}/imail.log -RETVAL=0 - - -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME -DAEMON_OPTS="--check $NAME" -[ ! -z "$GOGS_USER" ] && DAEMON_OPTS="$DAEMON_OPTS --user=${GOGS_USER}" - - -status(){ - isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` - if [ "$isStart" == '' ];then - echo -e "${SERVICENAME} not running" - else - echo -e "${SERVICENAME}(pid $(echo $isStart)) already running" - fi -} -start() { - isStart=`ps -ef|grep 'imail web' |grep -v grep|awk '{print $2}'` - if [ "$isStart" != '' ];then - echo "${SERVICENAME}(pid $(echo $isStart)) already running" - return $RETVAL +im_start(){ + isStart=`ps -ef|grep 'imail service' |grep -v grep|awk '{print $2}'` + if [ "$isStart" == '' ];then + echo -e "Starting imail... \c" + cd $app_path && daemon "${app_path}/imail service &" + isStart="" + while [[ "$isStart" == "" ]]; + do + echo -e ".\c" + sleep 0.5 + isStart=$(lsof -n -P -i:25|grep LISTEN|grep -v grep|awk '{print $2}'|xargs) + let n+=1 + if [ $n -gt 15 ];then + break; + fi + done + if [ "$isStart" == '' ];then + echo -e "\033[31mfailed\033[0m" + echo '------------------------------------------------------' + tail -n 20 ${app_path}/logs/run_away.log + echo '------------------------------------------------------' + 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 - - cd ${GOGS_HOME} - echo -e "Starting ${SERVICENAME}: \c" - ${GOGS_PATH} web > ${LOGFILE} 2>&1 & - RETVAL=$? - [ $RETVAL = 0 ] && touch ${LOCKFILE} && echo -e "\033[32mdone\033[0m" - return $RETVAL } -stop() { - - pids=`ps -ef|grep 'gogs web' |grep -v grep|awk '{print $2}'` +im_stop(){ + pids=`ps -ef|grep 'imail service' |grep -v grep|awk '{print $2}'` arr=($pids) - echo -e "Stopping gogs... \c" + echo -e "Stopping ${SERVICENAME}... \c" for p in ${arr[@]} do kill -9 $p @@ -84,27 +67,23 @@ stop() { echo -e "\033[32mdone\033[0m" } +im_status(){ + isStart=`ps -ef|grep 'imail service' |grep -v grep|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) - start - ;; - stop) - stop - ;; - status) - status - ;; - restart) - stop - start - ;; - reload) - stop - start - ;; - *) - echo "Usage: ${NAME} {start|stop|status|restart}" - exit 1 - ;; -esac -exit $RETVAL + 'start') im_start;; + 'stop') im_stop;; + 'status') im_status;; + 'reload') + im_stop + im_start;; + 'restart') + im_stop + im_start;; +esac \ No newline at end of file diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.14/install.sh index d9b4d4a4a..d7a0f2bf3 100755 --- a/plugins/imail/versions/0.0.14/install.sh +++ b/plugins/imail/versions/0.0.14/install.sh @@ -10,8 +10,7 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl VERSION=0.0.14 -## curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash -## debug: + ## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 1.0 bash ${rootPath}/scripts/getos.sh @@ -93,8 +92,6 @@ Install_App() pushd "$TARGET_DIR/scripts" >/dev/null 2>&1 bash make.sh - systemctl daemon-reload - echo "$VERSION" > $serverPath/imail/version.pl echo '安装完成' > $install_tmp } From 7e78c2dac496009f77fbd636883451d974dd757a Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 20:57:26 +0800 Subject: [PATCH 16/53] up --- plugins/imail/index.py | 9 +++++++++ plugins/imail/versions/0.0.14/install.sh | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 3b8bf0f55..627c396f0 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -180,9 +180,18 @@ class App: return 'ok' def conf(self): + conf_path = self.getServerDir() + '/custom/conf/app.conf' + if not os.path.exists(conf_path): + return mw.returnJson(False, "请先安装初始化!
默认地址:http://" + mw.getLocalIp() + ":1080") + return self.getServerDir() + '/custom/conf/app.conf' def run_log(self): + ilog = self.getServerDir() + '/logs/imail.log' + + if not os.path.exists(ilog): + return mw.returnJson(False, "请先安装初始化!
默认地址:http://" + mw.getLocalIp() + ":1080") + return self.getServerDir() + '/logs/imail.log' diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.14/install.sh index d7a0f2bf3..538fccb38 100755 --- a/plugins/imail/versions/0.0.14/install.sh +++ b/plugins/imail/versions/0.0.14/install.sh @@ -98,7 +98,7 @@ Install_App() Uninstall_App() { - + rm -rf $serverPath/imail echo "Uninstall_Mail" > $install_tmp } From 7deaf2822abd5a8d106815a52eb675c4ffde62ca Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 20:57:37 +0800 Subject: [PATCH 17/53] Update index.py --- plugins/imail/index.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 627c396f0..76b56c1a5 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -188,7 +188,6 @@ class App: def run_log(self): ilog = self.getServerDir() + '/logs/imail.log' - if not os.path.exists(ilog): return mw.returnJson(False, "请先安装初始化!
默认地址:http://" + mw.getLocalIp() + ":1080") From b7902ae2d0515fdd3498f47828eec1303627113f Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 21:00:07 +0800 Subject: [PATCH 18/53] Update install.sh --- plugins/imail/versions/0.0.14/install.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.14/install.sh index 538fccb38..26261c1de 100755 --- a/plugins/imail/versions/0.0.14/install.sh +++ b/plugins/imail/versions/0.0.14/install.sh @@ -92,14 +92,19 @@ Install_App() pushd "$TARGET_DIR/scripts" >/dev/null 2>&1 bash make.sh - echo "$VERSION" > $serverPath/imail/version.pl - echo '安装完成' > $install_tmp + if [ -d $serverPath/imail ];then + echo "$VERSION" > $serverPath/imail/version.pl + + cd ${rootPath} && python3 ${rootPath}/plugins/imail/index.py start + cd ${rootPath} && python3 ${rootPath}/plugins/imail/index.py initd_install + fi + echo 'install successful' > $install_tmp } Uninstall_App() { rm -rf $serverPath/imail - echo "Uninstall_Mail" > $install_tmp + echo "install fail" > $install_tmp } action=$1 From 796c19b5dc7ef8502ece3b29a2e8c92921dbc33e Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 21:00:52 +0800 Subject: [PATCH 19/53] Update install.sh --- plugins/imail/versions/0.0.14/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.14/install.sh index 26261c1de..94201aac8 100755 --- a/plugins/imail/versions/0.0.14/install.sh +++ b/plugins/imail/versions/0.0.14/install.sh @@ -103,6 +103,8 @@ Install_App() Uninstall_App() { + cd ${rootPath} && python3 ${rootPath}/plugins/imail/index.py initd_uninstall + cd ${rootPath} && python3 ${rootPath}/plugins/imail/index.py stop rm -rf $serverPath/imail echo "install fail" > $install_tmp } From 31a090351427bb098d8f83df117e98b0ba991827 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 21:15:26 +0800 Subject: [PATCH 20/53] Update public.js --- route/static/app/public.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/route/static/app/public.js b/route/static/app/public.js index 6063fa656..c2a1f072e 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -1698,12 +1698,22 @@ function pluginConfig(_name, version, func){
    \
  • 此处为'+ _name + version +'主配置文件,若您不了解配置规则,请勿随意修改。
  • \
'; - $(".soft-man-con").html(con); + var loadT = layer.msg('配置文件路径获取中...',{icon:16,time:0,shade: [0.3, '#000']}); $.post('/plugins/run', {name:_name, func:func_name,version:version},function (data) { layer.close(loadT); + try{ + var jdata = $.parseJSON(data.data); + if (!jdata['status']){ + layer.msg(jdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + }catch(err){/*console.log(err);*/} + + $(".soft-man-con").html(con); + var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']}); var fileName = data.data; $.post('/files/get_body', 'path=' + fileName, function(rdata) { @@ -1957,6 +1967,15 @@ function pluginLogs(_name, version, func, line){ $.post('/plugins/run', {name:_name, func:func_name, version:version},function (data) { layer.close(loadT); + try{ + var jdata = $.parseJSON(data.data); + if (!jdata['status']){ + layer.msg(jdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + }catch(err){/*console.log(err);*/} + + var loadT2 = layer.msg('文件内容获取中...',{icon:16,time:0,shade: [0.3, '#000']}); var fileName = data.data; $.post('/files/get_last_body', 'path=' + fileName+'&line='+file_line, function(rdata) { From 576f553317a69bed798ce32d796af527f15c22f6 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 26 Sep 2022 21:44:58 +0800 Subject: [PATCH 21/53] Update index.html --- plugins/imail/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/index.html b/plugins/imail/index.html index a2c3eb779..f2eb7fb60 100755 --- a/plugins/imail/index.html +++ b/plugins/imail/index.html @@ -4,7 +4,7 @@

服务

自启动

配置文件

-

运行日志

+

运行日志

From b102d4dd1fdc1d52b3eee549c76e72cdb2d44ac8 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:02:07 +0800 Subject: [PATCH 22/53] up --- plugins/imail/versions/{0.0.14 => 0.0.15}/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename plugins/imail/versions/{0.0.14 => 0.0.15}/install.sh (99%) diff --git a/plugins/imail/versions/0.0.14/install.sh b/plugins/imail/versions/0.0.15/install.sh similarity index 99% rename from plugins/imail/versions/0.0.14/install.sh rename to plugins/imail/versions/0.0.15/install.sh index 94201aac8..7b3cb3506 100755 --- a/plugins/imail/versions/0.0.14/install.sh +++ b/plugins/imail/versions/0.0.15/install.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl -VERSION=0.0.14 +VERSION=0.0.15 ## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 1.0 From d0166f03bbb81f9a9cab295033ed0501ca2272c6 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:04:09 +0800 Subject: [PATCH 23/53] Update info.json --- plugins/imail/info.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/imail/info.json b/plugins/imail/info.json index 406806c19..03915cabe 100755 --- a/plugins/imail/info.json +++ b/plugins/imail/info.json @@ -4,8 +4,8 @@ "name": "imail", "title": "邮件服务", "shell": "install.sh", - "versions":["0.0.14"], - "updates":["0.0.14"], + "versions":["0.0.15"], + "updates":["0.0.15"], "tip": "soft", "checks": "server/imail", "path": "server/imail", From 0dabfdacbdc1c207407b3fbbbf6bae41e2ec3729 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:08:21 +0800 Subject: [PATCH 24/53] Update imail.tpl --- plugins/imail/init.d/imail.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/init.d/imail.tpl b/plugins/imail/init.d/imail.tpl index 4de3daf08..3006e0944 100644 --- a/plugins/imail/init.d/imail.tpl +++ b/plugins/imail/init.d/imail.tpl @@ -30,7 +30,7 @@ im_start(){ isStart=`ps -ef|grep 'imail service' |grep -v grep|awk '{print $2}'` if [ "$isStart" == '' ];then echo -e "Starting imail... \c" - cd $app_path && daemon "${app_path}/imail service &" + cd $app_path && ${app_path}/imail service & isStart="" while [[ "$isStart" == "" ]]; do From 0dd3c1844eba52413162d782a1bb55a046ec33f2 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:09:46 +0800 Subject: [PATCH 25/53] Update index.py --- plugins/imail/index.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 76b56c1a5..055d3ff0c 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -105,8 +105,6 @@ class App: if not os.path.exists(file_bin): content = mw.readFile(file_tpl) - print(file_tpl) - print(content) content = self.contentReplace(content) mw.writeFile(file_bin, content) mw.execShell('chmod +x ' + file_bin) From 51b8738cbc53325ac0ec009df8b03dfead260c45 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:10:22 +0800 Subject: [PATCH 26/53] Update index.py --- plugins/imail/index.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 055d3ff0c..5044fc4ea 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -110,19 +110,19 @@ class App: mw.execShell('chmod +x ' + file_bin) # systemd - # systemDir = mw.systemdCfgDir() - # systemService = systemDir + '/gogs.service' - # systemServiceTpl = getPluginDir() + '/init.d/gogs.service.tpl' - # if os.path.exists(systemDir) and not os.path.exists(systemService): - # service_path = mw.getServerDir() - # se_content = mw.readFile(systemServiceTpl) - # se_content = se_content.replace('{$SERVER_PATH}', service_path) - # mw.writeFile(systemService, se_content) - # mw.execShell('systemctl daemon-reload') - - # log_path = getServerDir() + '/log' - # if not os.path.exists(log_path): - # os.mkdir(log_path) + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/imail.service' + systemServiceTpl = getPluginDir() + '/init.d/imail.service.tpl' + if os.path.exists(systemDir) and not os.path.exists(systemService): + service_path = mw.getServerDir() + se_content = mw.readFile(systemServiceTpl) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + log_path = getServerDir() + '/log' + if not os.path.exists(log_path): + os.mkdir(log_path) return file_bin From 1b4582574cd579a63e740abcc7baf47af15ef1cc Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:10:41 +0800 Subject: [PATCH 27/53] Update imail.service.tpl --- plugins/imail/init.d/imail.service.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/init.d/imail.service.tpl b/plugins/imail/init.d/imail.service.tpl index d5473e613..af7c6a444 100644 --- a/plugins/imail/init.d/imail.service.tpl +++ b/plugins/imail/init.d/imail.service.tpl @@ -1,5 +1,5 @@ [Unit] -Description=Gogs +Description=Imail Simple Mail Server After=network.target [Service] From 3a10aa78097947c5413f6ac1ed7c306358588480 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:12:50 +0800 Subject: [PATCH 28/53] Update index.py --- plugins/imail/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 5044fc4ea..c2b4c9fdc 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -112,7 +112,7 @@ class App: # systemd systemDir = mw.systemdCfgDir() systemService = systemDir + '/imail.service' - systemServiceTpl = getPluginDir() + '/init.d/imail.service.tpl' + systemServiceTpl = self.getPluginDir() + '/init.d/imail.service.tpl' if os.path.exists(systemDir) and not os.path.exists(systemService): service_path = mw.getServerDir() se_content = mw.readFile(systemServiceTpl) From aac7704208b77c4dbcdebab3070aff51e2b94842 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:15:34 +0800 Subject: [PATCH 29/53] Update index.py --- plugins/imail/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index c2b4c9fdc..6a47a57dd 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -120,7 +120,7 @@ class App: mw.writeFile(systemService, se_content) mw.execShell('systemctl daemon-reload') - log_path = getServerDir() + '/log' + log_path = self.getServerDir() + '/log' if not os.path.exists(log_path): os.mkdir(log_path) From 067ee597a724c1db93589d3d01a8fa80ecde0082 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:15:58 +0800 Subject: [PATCH 30/53] Update index.py --- plugins/imail/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index 6a47a57dd..f259259ed 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -120,7 +120,7 @@ class App: mw.writeFile(systemService, se_content) mw.execShell('systemctl daemon-reload') - log_path = self.getServerDir() + '/log' + log_path = self.getServerDir() + '/logs' if not os.path.exists(log_path): os.mkdir(log_path) From a346da07adb13a8ba412f2194627a298597eb61e Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:45:52 +0800 Subject: [PATCH 31/53] Update install.sh --- plugins/imail/versions/0.0.15/install.sh | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/plugins/imail/versions/0.0.15/install.sh b/plugins/imail/versions/0.0.15/install.sh index 7b3cb3506..5b52c8a1e 100755 --- a/plugins/imail/versions/0.0.15/install.sh +++ b/plugins/imail/versions/0.0.15/install.sh @@ -17,22 +17,13 @@ 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}'` -check_go_environment() { - if test ! -x "$(command -v go)"; then - printf "\e[1;31mmissing go running environment\e[0m\n" - exit 1 - fi -} get_arch() { - echo "package main -import ( - \"fmt\" - \"runtime\" -) -func main() { fmt.Println(runtime.GOARCH) }" > /tmp/go_arch.go - - ARCH=$(go run /tmp/go_arch.go) + + TMP_ARCH=`arch` + if [ "$TMP_ARCH" == "x86_64" ];then + ARCH="amd64" + fi } load_vars() { @@ -74,7 +65,6 @@ Install_App() echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/source - check_go_environment load_vars get_arch get_download_url From 3ea67beea97f58d8bb6c0cf11be6bca5a01bc223 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:46:13 +0800 Subject: [PATCH 32/53] Update install.sh --- plugins/imail/versions/0.0.15/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/versions/0.0.15/install.sh b/plugins/imail/versions/0.0.15/install.sh index 5b52c8a1e..93c059463 100755 --- a/plugins/imail/versions/0.0.15/install.sh +++ b/plugins/imail/versions/0.0.15/install.sh @@ -19,7 +19,7 @@ OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F get_arch() { - + ARCH="amd64" TMP_ARCH=`arch` if [ "$TMP_ARCH" == "x86_64" ];then ARCH="amd64" From 8c41b4c3fa0fb811033632945311f046479662c4 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:46:22 +0800 Subject: [PATCH 33/53] Update install.sh --- plugins/imail/versions/0.0.15/install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/imail/versions/0.0.15/install.sh b/plugins/imail/versions/0.0.15/install.sh index 93c059463..8f9ad2114 100755 --- a/plugins/imail/versions/0.0.15/install.sh +++ b/plugins/imail/versions/0.0.15/install.sh @@ -10,14 +10,12 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl VERSION=0.0.15 - ## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 1.0 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}'` - get_arch() { ARCH="amd64" TMP_ARCH=`arch` From e7d2eddc20ab1450150686e3658245ff344fef23 Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 19:49:35 +0800 Subject: [PATCH 34/53] Update install.sh --- plugins/imail/versions/0.0.15/install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/imail/versions/0.0.15/install.sh b/plugins/imail/versions/0.0.15/install.sh index 8f9ad2114..5b48a1283 100755 --- a/plugins/imail/versions/0.0.15/install.sh +++ b/plugins/imail/versions/0.0.15/install.sh @@ -10,14 +10,18 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl VERSION=0.0.15 -## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 1.0 +# bash install.sh install 0.0.15 +## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 0.0.15 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() { - ARCH="amd64" + TMP_ARCH=`arch` if [ "$TMP_ARCH" == "x86_64" ];then ARCH="amd64" From 0307828a82c09b49e5ec46e2dd6d5561abd5eade Mon Sep 17 00:00:00 2001 From: midoks Date: Wed, 28 Sep 2022 23:20:38 +0800 Subject: [PATCH 35/53] Update index.py --- plugins/gogs/index.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index e494d29e0..4193d04c3 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -240,7 +240,12 @@ def pMysqlDb(conf): db.setPort(int(host[1])) db.setUser(conf['USER']) - db.setPwd(conf['PASSWD']) + + if 'PASSWD' in conf: + db.setPwd(conf['PASSWD']) + else: + db.setPwd(conf['PASSWORD']) + db.setDbName(conf['NAME']) # db.setSocket(getSocketFile()) db.setCharset("utf8") From 40a86207450dacaa36d282433480238e03f4a025 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 29 Sep 2022 18:56:20 +0800 Subject: [PATCH 36/53] Update task.py --- task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.py b/task.py index 8a105daa3..a7d9b546b 100755 --- a/task.py +++ b/task.py @@ -102,7 +102,7 @@ def downloadFile(url, filename): try: import urllib import socket - socket.setdefaulttimeout(60) + socket.setdefaulttimeout(300) headers = ( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36') From b236bd85c9d13d85789d15edfeefa1f5c63b640f Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 29 Sep 2022 22:21:12 +0800 Subject: [PATCH 37/53] up --- plugins/imail/info.json | 4 ++-- plugins/imail/versions/{0.0.15 => 0.0.16}/install.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename plugins/imail/versions/{0.0.15 => 0.0.16}/install.sh (97%) diff --git a/plugins/imail/info.json b/plugins/imail/info.json index 03915cabe..d3c991f79 100755 --- a/plugins/imail/info.json +++ b/plugins/imail/info.json @@ -4,8 +4,8 @@ "name": "imail", "title": "邮件服务", "shell": "install.sh", - "versions":["0.0.15"], - "updates":["0.0.15"], + "versions":["0.0.16"], + "updates":["0.0.16"], "tip": "soft", "checks": "server/imail", "path": "server/imail", diff --git a/plugins/imail/versions/0.0.15/install.sh b/plugins/imail/versions/0.0.16/install.sh similarity index 97% rename from plugins/imail/versions/0.0.15/install.sh rename to plugins/imail/versions/0.0.16/install.sh index 5b48a1283..5b880384c 100755 --- a/plugins/imail/versions/0.0.15/install.sh +++ b/plugins/imail/versions/0.0.16/install.sh @@ -8,10 +8,10 @@ rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl -VERSION=0.0.15 +VERSION=0.0.16 -# bash install.sh install 0.0.15 -## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 0.0.15 +# bash install.sh install 0.0.16 +## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 0.0.16 bash ${rootPath}/scripts/getos.sh OSNAME=`cat ${rootPath}/data/osname.pl` From ec00e9d17e5bbb8e8ec553db21800bc0decf1f19 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 29 Sep 2022 23:06:53 +0800 Subject: [PATCH 38/53] Update index.py --- plugins/imail/index.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index f259259ed..bfe6fae9c 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -47,6 +47,20 @@ class App: return tmp + def __release_port(self, port): + from collections import namedtuple + try: + import firewall_api + firewall_api.firewall_api().addAcceptPortArgs(port, 'Mail-Server', 'port') + return port + except Exception as e: + return "Release failed {}".format(e) + + def openPort(self): + for i in ["25", "110", "143", "465", "995", "993", "587"]: + self.__release_port(i) + return True + def getPluginName(self): return 'imail' @@ -101,6 +115,8 @@ class App: initD_path = self.getServerDir() + '/init.d' if not os.path.exists(initD_path): os.mkdir(initD_path) + self.openPort() + file_bin = initD_path + '/' + self.getPluginName() if not os.path.exists(file_bin): From f98e4db019ac960025ee6371381a7409b1461219 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 29 Sep 2022 23:07:12 +0800 Subject: [PATCH 39/53] Update index.py --- plugins/imail/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/imail/index.py b/plugins/imail/index.py index bfe6fae9c..a79b8d576 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -51,7 +51,7 @@ class App: from collections import namedtuple try: import firewall_api - firewall_api.firewall_api().addAcceptPortArgs(port, 'Mail-Server', 'port') + firewall_api.firewall_api().addAcceptPortArgs(port, 'IMail-Server', 'port') return port except Exception as e: return "Release failed {}".format(e) From 0fafeabcf042f510079aa243c59e58c8896487c6 Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 30 Sep 2022 16:13:49 +0800 Subject: [PATCH 40/53] up --- plugins/imail/info.json | 4 ++-- plugins/imail/versions/{0.0.16 => 0.0.17}/install.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename plugins/imail/versions/{0.0.16 => 0.0.17}/install.sh (99%) diff --git a/plugins/imail/info.json b/plugins/imail/info.json index d3c991f79..5707b4ace 100755 --- a/plugins/imail/info.json +++ b/plugins/imail/info.json @@ -4,8 +4,8 @@ "name": "imail", "title": "邮件服务", "shell": "install.sh", - "versions":["0.0.16"], - "updates":["0.0.16"], + "versions":["0.0.17"], + "updates":["0.0.17"], "tip": "soft", "checks": "server/imail", "path": "server/imail", diff --git a/plugins/imail/versions/0.0.16/install.sh b/plugins/imail/versions/0.0.17/install.sh similarity index 99% rename from plugins/imail/versions/0.0.16/install.sh rename to plugins/imail/versions/0.0.17/install.sh index 5b880384c..791fef2f6 100755 --- a/plugins/imail/versions/0.0.16/install.sh +++ b/plugins/imail/versions/0.0.17/install.sh @@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl -VERSION=0.0.16 +VERSION=0.0.17 # bash install.sh install 0.0.16 ## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 0.0.16 From 9e9f10b06f49160213a8923c1faea54f93c778b3 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 16:41:55 +0800 Subject: [PATCH 41/53] =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E9=9A=8F=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setting.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setting.py b/setting.py index c60fd7c9e..2024c13b2 100755 --- a/setting.py +++ b/setting.py @@ -3,7 +3,9 @@ import time import sys +import random import os + chdir = os.getcwd() sys.path.append(chdir + '/class/core') @@ -31,6 +33,9 @@ if os.path.exists("data/port.pl"): mw_port = mw.readFile('data/port.pl') mw_port.strip() else: + import firewall_api + mw_port = str(random.randint(10000, 65530)) + firewall_api.firewall_api().addAcceptPortArgs(mw_port, 'MW-Panel', 'port') mw.writeFile('data/port.pl', mw_port) bind = [] From 5934be02bd2b2aed08bc0649fb59c42ec409b442 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 16:56:18 +0800 Subject: [PATCH 42/53] Update setting.py --- setting.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/setting.py b/setting.py index 2024c13b2..5d88ef1ed 100755 --- a/setting.py +++ b/setting.py @@ -24,8 +24,9 @@ cpu_info = system_api.system_api().getCpuInfo() workers = cpu_info[1] -if not os.path.exists(os.getcwd() + '/logs'): - os.mkdir(os.getcwd() + '/logs') +log_dir = os.getcwd() + '/logs' +if not os.path.exists(log_dir): + os.mkdir(log_dir) # default port mw_port = "7200" @@ -58,9 +59,9 @@ preload_app = True capture_output = True access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"' loglevel = 'info' -errorlog = chdir + '/logs/error.log' -accesslog = chdir + '/logs/access.log' -pidfile = chdir + '/logs/mw.pid' +errorlog = log_dir + '/error.log' +accesslog = log_dir + '/access.log' +pidfile = log_dir + '/mw.pid' if os.path.exists(os.getcwd() + '/data/ssl.pl'): certfile = 'ssl/certificate.pem' keyfile = 'ssl/privateKey.pem' From f5161bca6650b06b6c7cdf831c409dabebd3bb6d Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 17:58:51 +0800 Subject: [PATCH 43/53] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E7=AB=AF=E5=8F=A3-WEB?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/sql/default.sql | 7 +++---- scripts/install/alma.sh | 4 ++-- scripts/install/amazon.sh | 4 ++-- scripts/install/arch.sh | 4 ++-- scripts/install/centos.sh | 4 ++-- scripts/install/debian.sh | 4 ++-- scripts/install/fedora.sh | 4 ++-- scripts/install/freebsd.sh | 4 ++-- scripts/install/opensuse.sh | 4 ++-- scripts/install/rocky.sh | 4 ++-- scripts/install/ubuntu.sh | 4 ++-- setting.py | 4 +++- 12 files changed, 26 insertions(+), 25 deletions(-) diff --git a/data/sql/default.sql b/data/sql/default.sql index 9ae5a4496..1f3925a48 100755 --- a/data/sql/default.sql +++ b/data/sql/default.sql @@ -46,10 +46,9 @@ CREATE TABLE IF NOT EXISTS `firewall` ( INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES (1, '80', '网站默认端口', '0000-00-00 00:00:00'), -(2, '7200', 'WEB面板', '0000-00-00 00:00:00'), -(3, '22', 'SSH远程管理服务', '0000-00-00 00:00:00'), -(4, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00'), -(5, '443', 'HTTPS', '0000-00-00 00:00:00'); +(2, '22', 'SSH远程管理服务', '0000-00-00 00:00:00'), +(3, '443', 'HTTPS', '0000-00-00 00:00:00'), +(4, '888', 'phpMyAdmin默认端口', '0000-00-00 00:00:00'); diff --git a/scripts/install/alma.sh b/scripts/install/alma.sh index 9ce000d79..f03f8b67b 100755 --- a/scripts/install/alma.sh +++ b/scripts/install/alma.sh @@ -26,7 +26,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -50,7 +50,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/amazon.sh b/scripts/install/amazon.sh index bcadf789e..572cdde91 100755 --- a/scripts/install/amazon.sh +++ b/scripts/install/amazon.sh @@ -34,7 +34,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -60,7 +60,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/arch.sh b/scripts/install/arch.sh index 69a31f2e9..72e633dba 100644 --- a/scripts/install/arch.sh +++ b/scripts/install/arch.sh @@ -65,7 +65,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -89,7 +89,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/centos.sh b/scripts/install/centos.sh index 7fad4e0c2..2856a0038 100755 --- a/scripts/install/centos.sh +++ b/scripts/install/centos.sh @@ -35,7 +35,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -61,7 +61,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/debian.sh b/scripts/install/debian.sh index e6b813945..33144e7bd 100644 --- a/scripts/install/debian.sh +++ b/scripts/install/debian.sh @@ -42,7 +42,7 @@ if [ -f /usr/sbin/ufw ];then ufw allow 80/tcp ufw allow 443/tcp ufw allow 888/tcp - ufw allow 7200/tcp + # ufw allow 7200/tcp # ufw allow 3306/tcp # ufw allow 30000:40000/tcp @@ -64,7 +64,7 @@ if [ ! -f /usr/sbin/ufw ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/fedora.sh b/scripts/install/fedora.sh index 969fe49fa..3b1af73b5 100644 --- a/scripts/install/fedora.sh +++ b/scripts/install/fedora.sh @@ -29,7 +29,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -55,7 +55,7 @@ if [ "${isVersion}" == '' ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp firewall-cmd --reload diff --git a/scripts/install/freebsd.sh b/scripts/install/freebsd.sh index 64659dcd4..59574053f 100644 --- a/scripts/install/freebsd.sh +++ b/scripts/install/freebsd.sh @@ -51,7 +51,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -75,7 +75,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/opensuse.sh b/scripts/install/opensuse.sh index 4f971fcb4..eb2112e63 100644 --- a/scripts/install/opensuse.sh +++ b/scripts/install/opensuse.sh @@ -62,7 +62,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -86,7 +86,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/rocky.sh b/scripts/install/rocky.sh index 59e5de5b2..044284fc4 100644 --- a/scripts/install/rocky.sh +++ b/scripts/install/rocky.sh @@ -31,7 +31,7 @@ if [ -f /etc/init.d/iptables ];then iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT + # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7200 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 30000:40000 -j ACCEPT service iptables save @@ -55,7 +55,7 @@ if [ ! -f /etc/init.d/iptables ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/scripts/install/ubuntu.sh b/scripts/install/ubuntu.sh index 4a526c60d..aa180c325 100644 --- a/scripts/install/ubuntu.sh +++ b/scripts/install/ubuntu.sh @@ -31,7 +31,7 @@ if [ -f /usr/sbin/ufw ];then ufw allow 80/tcp ufw allow 443/tcp ufw allow 888/tcp - ufw allow 7200/tcp + # ufw allow 7200/tcp # ufw allow 3306/tcp # ufw allow 30000:40000/tcp @@ -51,7 +51,7 @@ if [ ! -f /usr/sbin/ufw ];then firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --permanent --zone=public --add-port=888/tcp - firewall-cmd --permanent --zone=public --add-port=7200/tcp + # firewall-cmd --permanent --zone=public --add-port=7200/tcp # firewall-cmd --permanent --zone=public --add-port=3306/tcp # firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp diff --git a/setting.py b/setting.py index 5d88ef1ed..79c00ea56 100755 --- a/setting.py +++ b/setting.py @@ -35,8 +35,10 @@ if os.path.exists("data/port.pl"): mw_port.strip() else: import firewall_api + import common + common.initDB() mw_port = str(random.randint(10000, 65530)) - firewall_api.firewall_api().addAcceptPortArgs(mw_port, 'MW-Panel', 'port') + firewall_api.firewall_api().addAcceptPortArgs(mw_port, 'WEB面板', 'port') mw.writeFile('data/port.pl', mw_port) bind = [] From 5b8cf7bb0a1fc2201d1f3e4ef37c771ef7d1d0e1 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 18:57:15 +0800 Subject: [PATCH 44/53] #201 --- route/static/app/crontab.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/route/static/app/crontab.js b/route/static/app/crontab.js index b200ed8bd..c2d2235e9 100755 --- a/route/static/app/crontab.js +++ b/route/static/app/crontab.js @@ -201,8 +201,7 @@ function planAdd(){ var type = $(".plancycle").find("b").attr("val"); $("#set-Config input[name='type']").val(type); - - var where1 = $("#ptime input[name='where1']").val(); + var is1; var is2 = 1; @@ -304,6 +303,11 @@ function planAdd(){ allAddCrontab(dataList,0,''); return; } + + if (type == 'minute-n'){ + var where1 = $("#ptime input[name='where1']").val(); + $("#set-Config input[name='where1']").val(where1); + } $("#set-Config input[name='sName']").val(sName); layer.msg('正在添加,请稍候...!',{icon:16,time:0,shade: [0.3, '#000']}); From cf645d1f20c7c2197b5a223f343d86853488e784 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 19:45:45 +0800 Subject: [PATCH 45/53] Update mw.tpl --- scripts/init.d/mw.tpl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 7d660dc77..7f0d75e8c 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -226,12 +226,13 @@ case "$1" in echo 'True' > $mw_path/data/ipv6.pl address="MW-Panel-Url: http://[$v6]:$port$auth_path" else - address="No v4 or v6 available" + address="MW-Panel-Url: http://you-network-ip:$port$auth_path" fi else address="MW-Panel-Url: http://$address:$port$auth_path" fi + show_panel_ip="$port|" echo -e "==================================================================" echo -e "\033[32mMW-Panel default info!\033[0m" echo -e "==================================================================" @@ -240,7 +241,7 @@ case "$1" in echo -e "password: $password" echo -e "\033[33mWarning:\033[0m" echo -e "\033[33mIf you cannot access the panel, \033[0m" - echo -e "\033[33mrelease the following port (7200|888|80|443|22) in the security group\033[0m" + echo -e "\033[33mrelease the following port (${show_panel_ip}888|80|443|22) in the security group\033[0m" echo -e "==================================================================" ;; esac From 5cbd53a6676a1e46fb1e3c7656a313f5c422d8a8 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 19:49:00 +0800 Subject: [PATCH 46/53] Update mw.tpl --- scripts/init.d/mw.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 7f0d75e8c..6d3092d1e 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -240,8 +240,8 @@ case "$1" in echo -e `python3 $mw_path/tools.py username` echo -e "password: $password" echo -e "\033[33mWarning:\033[0m" - echo -e "\033[33mIf you cannot access the panel, \033[0m" - echo -e "\033[33mrelease the following port (${show_panel_ip}888|80|443|22) in the security group\033[0m" + echo -e "\033[33mIf you cannot access the panel. \033[0m" + echo -e "\033[33mrelease the following port (${show_panel_ip}888|80|443|22) in the security group.\033[0m" echo -e "==================================================================" ;; esac From 062de09b3baec480eb68de4129b50271e2996ae2 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 19:53:11 +0800 Subject: [PATCH 47/53] Update app.sh --- scripts/quick/app.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/quick/app.sh b/scripts/quick/app.sh index d8310683c..91faa3a03 100755 --- a/scripts/quick/app.sh +++ b/scripts/quick/app.sh @@ -34,6 +34,14 @@ else echo "php74 alreay exist!" fi + +# swap +if [ ! -d /www/server/swap ];then + cd /www/server/mdserver-web/plugins/swap && bash install.sh install 5.6 +else + echo "swap alreay exist!" +fi + # mysql if [ ! -d /www/server/mysql ];then cd /www/server/mdserver-web/plugins/mysql && bash install.sh install 5.6 From f14d55fcc65c74573e8d469a841175151b6c0a0a Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 20:09:11 +0800 Subject: [PATCH 48/53] Update index.py --- plugins/mysql/index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 3dda72f36..4394e3dcb 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -428,7 +428,7 @@ def initMysqlPwd(): mw.execShell(drop_test_db) # 删除冗余账户 - hostname = mw.execShell('hostname')[0] + hostname = mw.execShell('hostname')[0].strip() drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' @@ -481,7 +481,7 @@ def initMysql8Pwd(): mw.execShell(drop_test_db) # 删除冗余账户 - hostname = mw.execShell('hostname')[0] + hostname = mw.execShell('hostname')[0].strip() drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' From 92d83bb82da37a1d99333751848c4885cabf6ecc Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 20:09:32 +0800 Subject: [PATCH 49/53] Update index.py --- plugins/mariadb/index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 62112a5d7..937a89ed1 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -365,7 +365,7 @@ def initMariaDbPwd(): mw.execShell(drop_test_db) # 删除冗余账户 - hostname = mw.execShell('hostname')[0] + hostname = mw.execShell('hostname')[0].strip() drop_hostname = serverdir + '/bin/mysql --defaults-file=' + \ myconf + ' -uroot -p' + pwd + ' -e "drop user \'\'@\'' + hostname + '\'";' mw.execShell(drop_hostname) From 2ae74d6199ddf9e11b54f8e9f015925e117cfc90 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 20:14:28 +0800 Subject: [PATCH 50/53] up --- plugins/mysql/conf/my.cnf | 3 - plugins/mysql/conf/my5.6.cnf | 110 +++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 plugins/mysql/conf/my5.6.cnf diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index 92a8c7111..31c59ecc8 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -7,9 +7,6 @@ socket = {$SERVER_APP_PATH}/mysql.sock [mysqld] !include {$SERVER_APP_PATH}/etc/mode/classic.cnf -;sha256_password_private_key_path=mysql.pem -;sha256_password_public_key_path=mysql.pub - pid-file = {$SERVER_APP_PATH}/data/mysql.pid user = mysql port = 3306 diff --git a/plugins/mysql/conf/my5.6.cnf b/plugins/mysql/conf/my5.6.cnf new file mode 100644 index 000000000..48c5a89f6 --- /dev/null +++ b/plugins/mysql/conf/my5.6.cnf @@ -0,0 +1,110 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock + +[mysqld] +!include {$SERVER_APP_PATH}/etc/mode/classic.cnf + +sha256_password_private_key_path=mysql.pem +sha256_password_public_key_path=mysql.pub + +pid-file = {$SERVER_APP_PATH}/data/mysql.pid +user = mysql +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock +basedir = {$SERVER_APP_PATH} +datadir = {$SERVER_APP_PATH}/data +log-error = {$SERVER_APP_PATH}/data/error.log +server-id = {$SERVER_ID} + +default_storage_engine = InnoDB + +key_buffer_size = 8M +max_allowed_packet = 100M + +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +lower_case_table_names=0 +query_cache_size = 4M +tmp_table_size = 8M + +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 65535 + +skip-name-resolve=1 +#skip-grant-tables +#skip-networking +#skip-external-locking +#loose-skip-innodb + +log-bin=mysql-bin +binlog_format=mixed +slow_query_log=1 +slow-query-log-file={$SERVER_APP_PATH}/data/mysql-slow.log +long_query_time=10 +#log_queries_not_using_indexes=on +#log_slow_admin_statements=1 +#log_slow_slave_statements=1 +expire_logs_days=30 + +relay-log=mdserver +relay-log-index=mdserver + +#master +#binlog-do-db +binlog-ignore-db = test +binlog-ignore-db = mysql +binlog-ignore-db = information_schema +binlog-ignore-db = performance_schema + +#slave +log-slave-updates = 1 +skip-slave-start = 1 +#replicate-do-db +replicate-ignore-db = information_schema +replicate-ignore-db = performance_schema +replicate-ignore-db = mysql +replicate-ignore-db = test + + +innodb_data_home_dir = {$SERVER_APP_PATH}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = {$SERVER_APP_PATH}/data +innodb_buffer_pool_size = 16M +innodb_additional_mem_pool_size = 2M +innodb_log_file_size = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 2 +innodb_lock_wait_timeout = 120 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 1 +innodb_write_io_threads = 1 +innodb_file_per_table=1 +innodb_large_prefix = 1 + + +secure-file-priv={$SERVER_APP_PATH}/tmp + +[mysqldump] +quick +max_allowed_packet = 16M + +[mysql] +no-auto-rehash + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout \ No newline at end of file From 1cc4813c52464b7b8aa7726d579b7268a1f6f707 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 1 Oct 2022 20:38:28 +0800 Subject: [PATCH 51/53] up --- plugins/mysql/conf/{my.cnf => my5.5.cnf} | 0 plugins/mysql/index.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename plugins/mysql/conf/{my.cnf => my5.5.cnf} (100%) diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my5.5.cnf similarity index 100% rename from plugins/mysql/conf/my.cnf rename to plugins/mysql/conf/my5.5.cnf diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 4394e3dcb..b8c65fbe2 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -498,7 +498,7 @@ def initMysql8Pwd(): def myOp(version, method): # import commands - init_file = initDreplace() + init_file = initDreplace(version) try: isInited = initMysqlData() if not isInited: From f36495f0fdd017439f89589990ea96fdae929ec6 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 2 Oct 2022 02:04:29 +0800 Subject: [PATCH 52/53] Update app.sh --- scripts/quick/app.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/quick/app.sh b/scripts/quick/app.sh index 91faa3a03..33abb533e 100755 --- a/scripts/quick/app.sh +++ b/scripts/quick/app.sh @@ -37,7 +37,7 @@ fi # swap if [ ! -d /www/server/swap ];then - cd /www/server/mdserver-web/plugins/swap && bash install.sh install 5.6 + cd /www/server/mdserver-web/plugins/swap && bash install.sh install 1.1 else echo "swap alreay exist!" fi From 71770ec40692b3e69651ab7c4378c815069548e8 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 2 Oct 2022 09:25:33 +0800 Subject: [PATCH 53/53] 0.9.11 --- README.md | 12 ++++++------ class/core/config_api.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bc31eec95..ab0187235 100644 --- a/README.md +++ b/README.md @@ -90,13 +90,13 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443: ``` -### 版本更新 0.9.10 +### 版本更新 0.9.11 -* 防跨站攻击(open_basedir)功能优化。 -* 创建站点域名批量添加优化。 -* 首页CPU显示tip添加。 -* 优化日志读取。 -* 加入开发模式开关。 +* 大文件解压优化。 +* 防火墙api优化。 +* mysql|mariadb安装删除冗余账户。 +* imail插件添加。 +* 安装面板初始化安装时不再固定端口[7200],优化为随机端口。 * redis添加性能调整功能。 diff --git a/class/core/config_api.py b/class/core/config_api.py index 980fab20e..1eb48f58a 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -15,7 +15,7 @@ from flask import request class config_api: - __version = '0.9.10.1' + __version = '0.9.11' def __init__(self): pass