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 be5ae448a..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' + __version = '0.9.11' def __init__(self): pass 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, '文件解压成功!') 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() diff --git a/class/core/mw.py b/class/core/mw.py index 5e87be762..81d892da7 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -406,6 +406,30 @@ 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 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请求 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/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") 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 000000000..fd5d7fad1 Binary files /dev/null and b/plugins/imail/ico.png differ diff --git a/plugins/imail/index.html b/plugins/imail/index.html new file mode 100755 index 000000000..f2eb7fb60 --- /dev/null +++ b/plugins/imail/index.html @@ -0,0 +1,20 @@ +
+
+
+

服务

+

自启动

+

配置文件

+

运行日志

+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/plugins/imail/index.py b/plugins/imail/index.py new file mode 100755 index 000000000..a79b8d576 --- /dev/null +++ b/plugins/imail/index.py @@ -0,0 +1,218 @@ +# 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' + __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 = {} + 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 __release_port(self, port): + from collections import namedtuple + try: + import firewall_api + firewall_api.firewall_api().addAcceptPortArgs(port, 'IMail-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' + + def getPluginDir(self): + return mw.getPluginDir() + '/' + self.getPluginName() + + 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}'") + if data[0] == '': + 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() + service_path = mw.getServerDir() + + 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): + content = mw.readFile(file_tpl) + content = self.contentReplace(content) + mw.writeFile(file_bin, content) + mw.execShell('chmod +x ' + file_bin) + + # systemd + systemDir = mw.systemdCfgDir() + systemService = systemDir + '/imail.service' + 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) + se_content = se_content.replace('{$SERVER_PATH}', service_path) + mw.writeFile(systemService, se_content) + mw.execShell('systemctl daemon-reload') + + log_path = self.getServerDir() + '/logs' + 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(): + cmd = 'systemctl {} {}'.format(method, self.getPluginName()) + data = mw.execShell(cmd) + if data[1] == '': + return 'ok' + return 'fail' + + data = mw.execShell(self.__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') + + 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): + 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' + + +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..5707b4ace --- /dev/null +++ b/plugins/imail/info.json @@ -0,0 +1,18 @@ +{ + "sort": 7, + "ps": "简单邮件服务[DEV]", + "name": "imail", + "title": "邮件服务", + "shell": "install.sh", + "versions":["0.0.17"], + "updates":["0.0.17"], + "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..af7c6a444 --- /dev/null +++ b/plugins/imail/init.d/imail.service.tpl @@ -0,0 +1,12 @@ +[Unit] +Description=Imail Simple Mail Server +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..3006e0944 --- /dev/null +++ b/plugins/imail/init.d/imail.tpl @@ -0,0 +1,89 @@ +#!/bin/bash +# chkconfig: 2345 55 25 +# description: Imail Service + +### BEGIN INIT INFO +# Provides: bt +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# 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 +fi + +if [ -f /etc/rc.d/init.d/functions ];then + . /etc/rc.d/init.d/functions +fi + +app_path={$SERVER_PATH}/imail +SERVICENAME="imail" + +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 && ${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 +} + +im_stop(){ + pids=`ps -ef|grep 'imail service' |grep -v grep|awk '{print $2}'` + arr=($pids) + echo -e "Stopping ${SERVICENAME}... \c" + for p in ${arr[@]} + do + kill -9 $p + done + 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') 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/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.17/install.sh b/plugins/imail/versions/0.0.17/install.sh new file mode 100755 index 000000000..791fef2f6 --- /dev/null +++ b/plugins/imail/versions/0.0.17/install.sh @@ -0,0 +1,109 @@ +#!/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.17 + +# 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` +OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + + +ARCH="amd64" + +get_arch() { + + TMP_ARCH=`arch` + if [ "$TMP_ARCH" == "x86_64" ];then + ARCH="amd64" + fi +} + +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 + + 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 + + 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() +{ + 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 +} + +action=$1 +if [ "${1}" == 'install' ];then + Install_App +else + Uninstall_App +fi diff --git a/plugins/mariadb/index.py b/plugins/mariadb/index.py index 279e28813..937a89ed1 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" @@ -363,6 +364,16 @@ def initMariaDbPwd(): pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + 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) + + 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 diff --git a/plugins/mysql/conf/my5.5.cnf b/plugins/mysql/conf/my5.5.cnf new file mode 100644 index 000000000..31c59ecc8 --- /dev/null +++ b/plugins/mysql/conf/my5.5.cnf @@ -0,0 +1,107 @@ +[client] +user = root +#password = your_password +port = 3306 +socket = {$SERVER_APP_PATH}/mysql.sock + +[mysqld] +!include {$SERVER_APP_PATH}/etc/mode/classic.cnf + +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 diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my5.6.cnf similarity index 95% rename from plugins/mysql/conf/my.cnf rename to plugins/mysql/conf/my5.6.cnf index 92a8c7111..48c5a89f6 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my5.6.cnf @@ -7,8 +7,8 @@ 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 +sha256_password_private_key_path=mysql.pem +sha256_password_public_key_path=mysql.pub pid-file = {$SERVER_APP_PATH}/data/mysql.pid user = mysql diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index d4f9cf8ed..b8c65fbe2 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 @@ -426,6 +427,17 @@ def initMysqlPwd(): pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + 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) + + 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 @@ -468,6 +480,17 @@ def initMysql8Pwd(): myconf + ' -uroot -p' + pwd + ' -e "drop database test";' mw.execShell(drop_test_db) + # 删除冗余账户 + 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) + + 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 @@ -475,7 +498,7 @@ def initMysql8Pwd(): def myOp(version, method): # import commands - init_file = initDreplace() + init_file = initDreplace(version) try: isInited = initMysqlData() if not isInited: 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}); + }); + }) + }); + }); /////////////////////////////////////////////// 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']}); 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){ '; - $(".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) { diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 7d660dc77..6d3092d1e 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 "==================================================================" @@ -239,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 (7200|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 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/scripts/quick/app.sh b/scripts/quick/app.sh index d8310683c..33abb533e 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 1.1 +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 diff --git a/setting.py b/setting.py index c60fd7c9e..79c00ea56 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') @@ -22,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" @@ -31,6 +34,11 @@ if os.path.exists("data/port.pl"): mw_port = mw.readFile('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, 'WEB面板', 'port') mw.writeFile('data/port.pl', mw_port) bind = [] @@ -53,9 +61,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' 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')