From fbac71e542d99709e8ea56a03c0bf358734933e2 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 28 Jun 2022 09:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md | 30 +++++ .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md | 14 ++ .gitignore | 2 + LICENSE | 2 +- README.md | 35 +++-- app.py | 12 +- class/core/common.py | 7 +- class/core/config_api.py | 2 +- class/core/mw.py | 53 +++++++- class/core/plugins_api.py | 7 + class/core/site_api.py | 38 ++++-- class/core/system_api.py | 7 +- class/core/task_api.py | 2 + cli.sh | 2 +- data/sql/default.sql | 2 +- mw-cli | 81 ++++++++++++ plugins/gogs/class/mysqlDb.py | 2 +- plugins/gogs/hook/commit.tpl | 4 +- plugins/gogs/index.html | 2 +- plugins/gogs/index.py | 144 ++++++++++++++------- plugins/gogs/init.d/gogs.service.bak.tpl | 29 +++++ plugins/gogs/init.d/gogs.service.tpl | 26 +--- plugins/gogs/install.sh | 19 ++- plugins/gogs/js/gogs.js | 2 +- plugins/mongodb/info.json | 4 +- plugins/mysql/class/mysqlDb.py | 2 +- plugins/mysql/conf/my.cnf | 2 +- plugins/mysql/conf/my5.7.cnf | 2 +- plugins/mysql/conf/my8.0.cnf | 2 +- plugins/mysql/index.py | 140 +++++++++----------- plugins/mysql/js/mysql.js | 32 +++-- plugins/mysql/versions/5.5/install.sh | 28 +++- plugins/mysql/versions/5.6/install.sh | 29 ++++- plugins/mysql/versions/5.7/install.sh | 35 ++++- plugins/mysql/versions/8.0/install.sh | 41 +++++- plugins/op_waf/install.sh | 4 +- plugins/op_waf/waf/html/cookie.html | 4 +- plugins/op_waf/waf/html/get.html | 4 +- plugins/op_waf/waf/html/other.html | 4 +- plugins/op_waf/waf/html/post.html | 4 +- plugins/op_waf/waf/html/user_agent.html | 4 +- plugins/op_waf/waf/lua/init.lua | 15 ++- plugins/openresty/index.py | 25 +++- plugins/openresty/install.sh | 14 +- plugins/php/index.py | 43 +++--- plugins/php/js/php.js | 3 +- plugins/php/lib/zlib.sh | 2 +- plugins/php/versions/52/install.sh | 46 ++++++- plugins/php/versions/53/install.sh | 14 +- plugins/php/versions/54/install.sh | 34 ++++- plugins/php/versions/55/install.sh | 4 +- plugins/php/versions/56/install.sh | 5 +- plugins/php/versions/70/install.sh | 8 +- plugins/php/versions/71/install.sh | 5 +- plugins/php/versions/72/install.sh | 5 +- plugins/php/versions/73/install.sh | 4 +- plugins/php/versions/74/install.sh | 12 +- plugins/php/versions/80/install.sh | 8 +- plugins/php/versions/81/install.sh | 4 +- plugins/phpmyadmin/conf/config.inc.php | 1 + plugins/phpmyadmin/index.html | 1 + plugins/phpmyadmin/index.py | 16 +++ plugins/phpmyadmin/install.sh | 3 + plugins/pureftp/index.py | 10 ++ plugins/pureftp/info.json | 2 +- plugins/pureftp/init.d/pureftp.service.tpl | 13 ++ plugins/pureftp/install.sh | 43 ++++-- plugins/redis/index.py | 9 +- plugins/ssh-no-login/check-ssh.sh | 21 --- plugins/varnish/index.html | 1 + plugins/varnish/index.py | 46 ++++--- plugins/varnish/js/varnish.js | 63 ++++++++- plugins/xhprof/install.sh | 1 + requirements.txt | 8 +- route/__init__.py | 59 +++++++-- route/static/app/config.js | 2 +- route/static/app/files.js | 2 +- route/static/app/public.js | 11 +- route/static/app/site.js | 2 +- route/static/app/soft.js | 10 +- route/static/css/site.css | 2 +- route/static/img/soft_ico/ico-upyun.png | Bin 1183 -> 0 bytes route/static/img/weixin_zz.jpg | Bin 0 -> 60575 bytes route/static/js/socket.io.min.js | 10 +- route/static/js/socket.io.min.js.map | 1 + scripts/init.d/mw.tpl | 139 ++++++++++++-------- scripts/install.sh | 14 +- scripts/install/alma.sh | 76 +++-------- scripts/install/centos.sh | 56 +++----- scripts/install/debian.sh | 67 ++++++---- scripts/install/fedora.sh | 31 +---- scripts/install/macos.sh | 3 + scripts/install/rocky.sh | 42 +----- scripts/install/ubuntu.sh | 46 +------ scripts/install_cn.sh | 13 +- scripts/install_dev.sh | 16 ++- scripts/lib.sh | 67 ++++++++-- scripts/quick/app.sh | 42 ++++++ scripts/quick/debug.sh | 89 +++++++++++++ scripts/rememory.sh | 8 ++ scripts/update.sh | 13 +- scripts/update/alma.sh | 29 ----- scripts/update/centos.sh | 28 ---- scripts/update/debian.sh | 33 ----- scripts/update/fedora.sh | 22 ---- scripts/update/rocky.sh | 26 ---- scripts/update/ubuntu.sh | 40 ------ scripts/update_cn.sh | 15 ++- scripts/update_dev.sh | 18 ++- task.py | 139 +++++++++++++------- tools.py | 10 +- 111 files changed, 1569 insertions(+), 966 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md create mode 100644 .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md create mode 100644 mw-cli create mode 100644 plugins/gogs/init.d/gogs.service.bak.tpl create mode 100644 plugins/pureftp/init.d/pureftp.service.tpl delete mode 100755 plugins/ssh-no-login/check-ssh.sh delete mode 100755 route/static/img/soft_ico/ico-upyun.png create mode 100644 route/static/img/weixin_zz.jpg mode change 100755 => 100644 route/static/js/socket.io.min.js create mode 100644 route/static/js/socket.io.min.js.map create mode 100755 scripts/quick/app.sh create mode 100755 scripts/quick/debug.sh diff --git a/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md new file mode 100644 index 000000000..30ab509c4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_1.md @@ -0,0 +1,30 @@ +--- +name: BUG提交 +about: 问题描述 +--- + +## 什么系统 ? + +Debian x, Centos x, Centos x stream, Ubuntu x? + +## 错误信息 ? + +Ex: +```bash +................start mw success +bash: line 149: ./scripts/init.d/mw: No such file or directory +``` + +## 错误截图 ? + +... + + +## 浏览器版本 ? + +... + + +## 软件版本(插件/面板) ? + +... diff --git a/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md new file mode 100644 index 000000000..8b1420e96 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE_2.md @@ -0,0 +1,14 @@ +--- +name: 需求提交 +about: 需求描述 +--- + +## 需求 + +想开发一个什么插件? +想有什么功能? + + +## 提供参考 + +给开发者提供参考! \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1f01fc2e6..4d685bdcb 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,5 @@ include data/api_login.txt data/sessions data/ssl.pl +plugins/gdrive/ +plugins/openlitespeed/ diff --git a/LICENSE b/LICENSE index 261eeb9e9..f37a89ca4 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright [midoks] [midoks 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. diff --git a/README.md b/README.md index 8f0476f09..ca2c26962 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,6 @@ 简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。 复制了后台管理界面,按照自己想要的方式写了一版。 -``` -为了兼容CentOS,Ubuntu,Debian,Fedora, 由chkconfig改systemd管理。原来都要重新安装。还在进行修改.. - -chkconfig 支持 Fedora,CentOS -update-rc.d 支持 Ubuntu,Debian | 功能不够 -systemd 支持 CentOS,Ubuntu,Debian,Fedora... - -``` ![CentOS](https://img.shields.io/badge/LINUX-CentOS-blue?style=for-the-badge&logo=CentOS) ![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu) @@ -22,7 +14,6 @@ systemd 支持 CentOS,Ubuntu,Debian,Fedora... * 面板收藏功能 * 网站子目录绑定 * 网站备份功能 -* 自动更新优化 * 插件方式管理 基本上可以使用,后续会继续优化!欢迎提供意见! @@ -48,9 +39,8 @@ systemd 支持 CentOS,Ubuntu,Debian,Fedora... ### 问题 -- Ubuntu 20 无法安装mysql5.7 && mysql 80. -- Ftp debian无法安装成功。 -- php52,在debian无法安装成功。 +- OP防火墙,暂不要开启。 + ### GW使用 @@ -82,6 +72,14 @@ curl -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/update_cn.s ``` + +### 通用安装 + +``` +curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/quick/app.sh | bash +``` + + ### DEV使用 - 自动安装 @@ -96,6 +94,8 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/in curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash ``` +### 微信赞助 +[![截图](/route/static/img/weixin_zz.jpg)](/route/static/img/weixin_zz.jpg) ### 无图不真相 @@ -109,10 +109,9 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up 如果你自己写了插件,想分享出来,也可以提Issue。 ``` -- 开发文档 - https://github.com/midoks/mdserver-web/wiki/%E6%8F%92%E4%BB%B6%E5%BC%80%E5%8F%91 +- 简单例子 - https://github.com/mw-plugin/simple-plugin - 插件地址 - https://github.com/mw-plugin -- 例子 - https://github.com/mw-plugin/simple-plugin - +- 开发文档 - https://github.com/midoks/mdserver-web/wiki/插件开发 ### Stargazers over time @@ -120,11 +119,9 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up [![Stargazers over time](https://starchart.cc/midoks/mdserver-web.svg)](https://starchart.cc/midoks/mdserver-web) -### 感谢 - -- 开发赞助 +### 感谢开发赞助 -[digitalvirt](https://digitalvirt.com/) +[![digitalvirt](https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg)](https://digitalvirt.com/) ### 授权许可 diff --git a/app.py b/app.py index 906f56fdc..13e12f3be 100644 --- a/app.py +++ b/app.py @@ -14,13 +14,19 @@ from geventwebsocket.handler import WebSocketHandler try: if __name__ == "__main__": - f = open('data/port.pl') - PORT = int(f.read()) - HOST = '0.0.0.0' + PORT = 7200 + if os.path.exists('data/port.pl'): + f = open('data/port.pl') + PORT = int(f.read()) + f.close() + + HOST = '0.0.0.0' http_server = WSGIServer( (HOST, PORT), app, handler_class=WebSocketHandler) + http_server.serve_forever() + socketio.run(app, host=HOST, port=PORT) except Exception as ex: print(ex) diff --git a/class/core/common.py b/class/core/common.py index b91df42b8..4d6492a12 100755 --- a/class/core/common.py +++ b/class/core/common.py @@ -20,10 +20,9 @@ from flask import redirect def init(): - initDB() - initInitD() initUserInfo() + initInitD() def local(): @@ -57,7 +56,6 @@ def doContentReplace(src, dst): def initInitD(): - mw.setHostAddr(mw.getLocalIp()) # systemctl # 有问题 @@ -97,6 +95,9 @@ def initInitD(): mw.execShell('which chkconfig && chkconfig --add mw') mw.execShell('which update-rc.d && update-rc.d -f mw defaults') + # 获取系统IPV4 + mw.setHostAddr(mw.getLocalIp()) + def initUserInfo(): diff --git a/class/core/config_api.py b/class/core/config_api.py index 22cfa3ba4..71f991acc 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -18,7 +18,7 @@ class config_api: # 本版解决自启动问题 # 文件管理重命名 # 优化计划任务管理 - __version = '0.8.6' + __version = '0.8.6.1' def __init__(self): pass diff --git a/class/core/mw.py b/class/core/mw.py index 745d1c5d1..beb8347f8 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -98,6 +98,23 @@ def isAppleSystem(): return False +def isNumber(s): + try: + float(s) + return True + except ValueError: + pass + + try: + import unicodedata + unicodedata.numeric(s) + return True + except (TypeError, ValueError): + pass + + return False + + def deleteFile(file): if os.path.exists(file): os.remove(file) @@ -111,9 +128,22 @@ def isInstalledWeb(): def restartWeb(): - if isInstalledWeb(): - initd = getServerDir() + '/openresty/init.d/openresty' + if not isInstalledWeb(): + return False + + # systemd + systemd = '/lib/systemd/system/openresty.service' + if os.path.exists(systemd): + execShell('systemctl restart openresty') + return True + + # initd + initd = getServerDir() + '/openresty/init.d/openresty' + if os.path.exists(initd): execShell(initd + ' ' + 'restart') + return True + + return False def restartMw(): @@ -540,7 +570,7 @@ def downloadHook(count, blockSize, totalSize): print('%02d%%' % (100.0 * count * blockSize / totalSize)) -def getLocalIp(): +def getLocalIpBack(): # 取本地外网IP try: import re @@ -561,6 +591,23 @@ def getLocalIp(): return '127.0.0.1' +def getLocalIp(): + # 取本地外网IP + try: + import re + filename = 'data/iplist.txt' + ipaddress = readFile(filename) + if not ipaddress or ipaddress == '127.0.0.1': + import urllib + url = 'https://v6r.ipip.net/?format=text' + req = urllib.request.urlopen(url, timeout=10) + ipaddress = req.read().decode('utf-8') + writeFile(filename, ipaddress) + return ipaddress + except Exception as ex: + return '127.0.0.1' + + def inArray(arrays, searchStr): # 搜索数据中是否存在 for key in arrays: diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 3a22894f6..26f70906e 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -48,6 +48,13 @@ class plugins_api: def listApi(self): sType = request.args.get('type', '0') sPage = request.args.get('p', '1') + + if not mw.isNumber(sPage): + sPage = 1 + + if not mw.isNumber(sType): + sType = 0 + # print sPage data = self.getPluginList(sType, int(sPage)) return mw.getJson(data) diff --git a/class/core/site_api.py b/class/core/site_api.py index 9ab00f1dc..36a0be774 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -599,7 +599,11 @@ class site_api: if not os.path.exists(acem): return mw.returnJson(False, '尝试自动安装ACME失败,请通过以下命令尝试手动安装

安装命令: curl https://get.acme.sh | sh

' + acem) - force_bool = False + # 避免频繁执行 + checkAcmeRun = mw.execShell('ps -ef|grep acme.sh |grep -v grep') + if checkAcmeRun[0] != '': + return mw.returnJson(False, '正在申请或更新SSL中...') + if force == 'true': force_bool = True @@ -973,7 +977,7 @@ class site_api: "-START(.|\n)+BINDING-" + domain + "-END" tmp = re.search(rep, conf).group() dirConf = tmp.replace('rewrite/' + site['name'] + '.conf;', 'rewrite/' + site[ - 'name'] + '_' + find['path'] + '.conf;') + 'name'] + '_' + find['path'] + '.conf;') conf = conf.replace(tmp, dirConf) mw.writeFile(file, conf) data = {} @@ -1522,9 +1526,13 @@ class site_api: def getSecurity(self, sid, name): filename = self.getHostConf(name) conf = mw.readFile(filename) + + if type(conf) == bool: + return mw.returnJson(False, '读取配置文件失败!') + data = {} if conf.find('SECURITY-START') != -1: - rep = "#SECURITY-START(\n|.){1,500}#SECURITY-END" + rep = "#SECURITY-START(.|\n)*#SECURITY-END" tmp = re.search(rep, conf).group() data['fix'] = re.search( "\(.+\)\$", tmp).group().replace('(', '').replace(')$', '').replace('|', ',') @@ -1549,22 +1557,22 @@ class site_api: if os.path.exists(file): conf = mw.readFile(file) if conf.find('SECURITY-START') != -1: - rep = "\s{0,4}#SECURITY-START(\n|.){1,500}#SECURITY-END\n?" + rep = "\s{0,4}#SECURITY-START(\n|.)*#SECURITY-END\n?" conf = re.sub(rep, '', conf) mw.writeLog('网站管理', '站点[' + name + ']已关闭防盗链设置!') else: rconf = '''#SECURITY-START 防盗链配置 -location ~ .*\.(%s)$ -{ - expires 30d; - access_log /dev/null; - valid_referers none blocked %s; - if ($invalid_referer){ - return 404; + location ~ .*\.(%s)$ + { + expires 30d; + access_log /dev/null; + valid_referers none blocked %s; + if ($invalid_referer){ + return 404; + } } -} -# SECURITY-END -include enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace(',', ' ')) + #SECURITY-END + include enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace(',', ' ')) conf = re.sub("include\s+enable-php-", rconf, conf) mw.writeLog('网站管理', '站点[' + name + ']已开启防盗链!') mw.writeFile(file, conf) @@ -1615,6 +1623,8 @@ include enable-php-''' % (fix.strip().replace(',', '|'), domains.strip().replace os.makedirs(path) if not mw.isAppleSystem(): mw.execShell('chown -R www:www ' + path) + + mw.writeFile(path + '/index.html', '已经开始工作!!!') mw.execShell('chmod -R 755 ' + path) def nginxAddDomain(self, webname, domain, port): diff --git a/class/core/system_api.py b/class/core/system_api.py index 54b0c2ba2..87fb6222f 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -102,12 +102,9 @@ class system_api: return mw.returnJson(True, '正在重启服务器!') ##### ----- end ----- ### - @mw_async def restartMw(self): - sleep(0.3) - # cmd = mw.getRunDir() + '/scripts/init.d/mw restart' - # print cmd - mw.execShell('service mw restart') + mw.writeFile('data/restart.pl', 'True') + return True @mw_async def restartServer(self): diff --git a/class/core/task_api.py b/class/core/task_api.py index 728e08fba..53b8023a1 100755 --- a/class/core/task_api.py +++ b/class/core/task_api.py @@ -42,6 +42,8 @@ class task_api: _page['tojs'] = 'remind' _page['p'] = p + # return data + _ret['count'] = count _ret['page'] = mw.getPage(_page) return mw.getJson(_ret) diff --git a/cli.sh b/cli.sh index 6cddd7a73..4a2739080 100755 --- a/cli.sh +++ b/cli.sh @@ -24,8 +24,8 @@ mw_start_debug(){ } mw_start_debug2(){ - gunicorn -c setting.py app:app python3 task.py & + gunicorn -b :7200 -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app } diff --git a/data/sql/default.sql b/data/sql/default.sql index ab168862e..20b85b5dc 100755 --- a/data/sql/default.sql +++ b/data/sql/default.sql @@ -49,7 +49,7 @@ INSERT INTO `firewall` (`id`, `port`, `ps`, `addtime`) VALUES (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, '3306', 'MySQL端口', '0000-00-00 00:00:00'); +(5, '443', 'HTTPS', '0000-00-00 00:00:00'); diff --git a/mw-cli b/mw-cli new file mode 100644 index 000000000..8d5f63f10 --- /dev/null +++ b/mw-cli @@ -0,0 +1,81 @@ +#!/www/server/mdserver-web/bin/python +# description: mdserver-web cli tools +# ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli +import os +import sys + + +def mw_start(): + """ + Start mdserver-web + """ + os.system('systemctl start mw') + print("服务已启动") + + +def mw_stop(): + """ + stop mdserver-web + """ + os.system('systemctl stop mw') + print("服务已停止") + + +def mw_restart(): + """ + restart mdserver-web + """ + os.system('systemctl restart mw') + print("服务已重启") + + +def mw_reset_username(): + """ + reset mdserver-web username + """ + from tools import set_panel_username + user_name = input("请输入新的用户名: ") + set_panel_username(user_name) + + +def mw_reset_pwd(): + """ + reset mdserver-web password + """ + from tools import set_panel_pwd + pwd = input("请输入新的密码: ") + set_panel_pwd(pwd, True) + + +if __name__ == '__main__': + os.chdir("/www/server/mdserver-web") + sys.path.append(os.getcwd() + "/class/core") + + try: + str = ''' + ==== mdserver-web cli tools ==== + 1. 启动服务 2. 停止服务 + 3. 重启服务 4. 修改用户名 + 5. 修改密码 + ================================= + ''' + if len(sys.argv) == 2: + sw = sys.argv[1] + else: + print(str) + sw = input("请输入您要进行的操作: ") + + if sw == '1': + mw_start() + elif sw == '2': + mw_stop() + elif sw == '3': + mw_restart() + elif sw == '4': + mw_reset_username() + elif sw == '5': + mw_reset_pwd() + else: + print("操作不存在") + except KeyboardInterrupt: + print("\n操作已终止") diff --git a/plugins/gogs/class/mysqlDb.py b/plugins/gogs/class/mysqlDb.py index ee69c9dea..4ce57da67 100755 --- a/plugins/gogs/class/mysqlDb.py +++ b/plugins/gogs/class/mysqlDb.py @@ -21,7 +21,7 @@ class mysqlDb: def __Conn(self): '''连接MYSQL数据库''' try: - socket = '/tmp/mysql.sock' + socket = '/www/server/mysql/mysql.sock' try: import MySQLdb except Exception as ex: diff --git a/plugins/gogs/hook/commit.tpl b/plugins/gogs/hook/commit.tpl index c6a7983ef..7070accf5 100755 --- a/plugins/gogs/hook/commit.tpl +++ b/plugins/gogs/hook/commit.tpl @@ -2,7 +2,7 @@ echo `date` -GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}" +GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}.git" GIT_SDIR="{$CODE_DIR}" GIT_USER_DIR="${GIT_SDIR}/{$USERNAME}" @@ -24,7 +24,7 @@ cd $GIT_PROJECT_DIR && git pull # cd $GIT_PROJECT_DIR && env -i git pull origin master - +#更新的目的地址 WEB_PATH={$WEB_ROOT}/{$USERNAME}/{$PROJECT} mkdir -p $WEB_PATH diff --git a/plugins/gogs/index.html b/plugins/gogs/index.html index f09dfde13..e4e4a05f2 100755 --- a/plugins/gogs/index.html +++ b/plugins/gogs/index.html @@ -3,7 +3,7 @@

服务

自启动

-

启动配置

+

手动编辑

配置文件

配置修改

diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py index 0ebce029a..f909297f2 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -11,10 +11,11 @@ sys.path.append(os.getcwd() + "/class/core") import mw -cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' -info = mw.execShell(cmd) -p = "/usr/local/lib/" + info[0].strip() + "/site-packages" -sys.path.append(p) +# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' +# info = mw.execShell(cmd) +# p = "/usr/local/lib/" + info[0].strip() + "/site-packages" +# sys.path.append(p) + import psutil @@ -61,6 +62,13 @@ def getArgs(): return tmp +def checkArgs(data, ck=[]): + for i in range(len(ck)): + if not ck[i] in data: + return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) + return (True, mw.returnJson(True, 'ok')) + + def getInitdConfTpl(): path = getPluginDir() + "/init.d/gogs.tpl" return path @@ -170,9 +178,14 @@ def getRootUrl(): content = mw.readFile(getConf()) rep = 'ROOT_URL\s*=\s*(.*)' tmp = re.search(rep, content) - if not tmp: - return '' - return tmp.groups()[0] + if tmp: + return tmp.groups()[0] + + rep = 'EXTERNAL_URL\s*=\s*(.*)' + tmp = re.search(rep, content) + if tmp: + return tmp.groups()[0] + return '' def getSshPort(): @@ -218,8 +231,7 @@ def getDbConfValue(): return r -def pMysqlDb(): - conf = getDbConfValue() +def pMysqlDb(conf): host = conf['HOST'].split(':') conn = mysqlDb.mysqlDb() @@ -232,6 +244,53 @@ def pMysqlDb(): return conn +def pSqliteDb(conf): + # print(conf) + import db + psDb = db.Sql() + + # 默认 + gsdir = getServerDir() + '/data' + dbname = 'gogs' + if conf['PATH'][0] == '/': + # 绝对路径 + pass + else: + path = conf['PATH'].split('/') + gsdir = getServerDir() + '/' + path[0] + dbname = path[1].split('.')[0] + + # print(gsdir, dbname) + psDb.dbPos(gsdir, dbname) + return psDb + + +def getGogsDbType(conf): + + if 'DB_TYPE' in conf: + return conf['DB_TYPE'] + + if 'TYPE' in conf: + return conf['TYPE'] + + return 'NONE' + + +def pQuery(sql): + conf = getDbConfValue() + gtype = getGogsDbType(conf) + if gtype == 'sqlite3': + db = pSqliteDb(conf) + data = db.query(sql, []).fetchall() + return data + elif gtype == 'mysql': + db = pMysqlDb(conf) + return db.query(sql) + + print("仅支持mysql|sqlite3配置") + exit(0) + + def isSqlError(mysqlMsg): # 检测数据库执行错误 _mysqlMsg = str(mysqlMsg) @@ -255,37 +314,35 @@ def isSqlError(mysqlMsg): return mw.returnData(True, 'OK') -def start(): - +def gogsOp(method): file = initDreplace() - data = mw.execShell(__SR + file + ' start') + + if not mw.isAppleSystem(): + data = mw.execShell('systemctl ' + method + ' gogs') + if data[1] == '': + return 'ok' + return 'fail' + + data = mw.execShell(__SR + file + ' ' + method) if data[1] == '': return 'ok' return data[0] +def start(): + return gogsOp('start') + + def stop(): - file = initDreplace() - data = mw.execShell(__SR + file + ' stop') - if data[1] == '': - return 'ok' - return data[1] + return gogsOp('stop') def restart(): - file = initDreplace() - data = mw.execShell(__SR + file + ' restart') - if data[1] == '': - return 'ok' - return data[1] + return gogsOp('restart') def reload(): - file = initDreplace() - data = mw.execShell(__SR + file + ' reload') - if data[1] == '': - return 'ok' - return data[1] + return gogsOp('reload') def initdStatus(): @@ -391,15 +448,13 @@ def userList(): import math args = getArgs() - page = 1 - page_size = 10 - search = '' - if 'page' in args: - page = int(args['page']) - - if 'page_size' in args: - page_size = int(args['page_size']) + data = checkArgs(args, ['page', 'page_size']) + if not data[0]: + return data[1] + page = int(args['page']) + page_size = int(args['page_size']) + search = '' if 'search' in args: search = args['search'] @@ -407,17 +462,13 @@ def userList(): data['root_url'] = getRootUrl() - pm = pMysqlDb() start = (page - 1) * page_size - list_count = pm.query('select count(id) as num from user') + list_count = pQuery('select count(id) as num from user') count = list_count[0][0] - - list_data = pm.query( + list_data = pQuery( 'select id,name,email from user order by id desc limit ' + str(start) + ',' + str(page_size)) - - page_info = {'count': count, 'p': page, - 'row': page_size, 'tojs': 'gogsUserList'} - data['list'] = mw.getPage(page_info) + data['list'] = mw.getPage({'count': count, 'p': page, + 'row': page_size, 'tojs': 'gogsUserList'}) data['page'] = page data['page_size'] = page_size data['page_count'] = int(math.ceil(count / page_size)) @@ -542,8 +593,8 @@ def projectScriptLoad(): cc_content = mw.readFile(commit_tpl) - sshUrl = 'http://127.0.0.1:' + getHttpPort() - cc_content = cc_content.replace('{$GITROOTURL}', sshUrl) + gitPath = getRootPath() + cc_content = cc_content.replace('{$GITROOTURL}', gitPath) cc_content = cc_content.replace('{$CODE_DIR}', codeDir) cc_content = cc_content.replace('{$USERNAME}', user) cc_content = cc_content.replace('{$PROJECT}', args['name']) @@ -620,8 +671,7 @@ def getTotalStatistics(): st = status() data = {} if st.strip() == 'start': - pm = pMysqlDb() - list_count = pm.query('select count(id) as num from repository') + list_count = pQuery('select count(id) as num from repository') if list_count.find("error") > -1: data['status'] = False diff --git a/plugins/gogs/init.d/gogs.service.bak.tpl b/plugins/gogs/init.d/gogs.service.bak.tpl new file mode 100644 index 000000000..8b58b1c81 --- /dev/null +++ b/plugins/gogs/init.d/gogs.service.bak.tpl @@ -0,0 +1,29 @@ +[Unit] +Description=Gogs +After=network.target + +[Service] +# Modify these two values and uncomment them if you have +# repos with lots of files and get an HTTP error 500 because +# of that +### +#LimitMEMLOCK=infinity +#LimitNOFILE=65535 +Type=simple +User=git +Group=git +WorkingDirectory={$SERVER_PATH}/gogs +ExecStart={$SERVER_PATH}/gogs/gogs web +ExecReload=/bin/kill -USR2 $MAINPID +Restart=always +Environment=USER=git HOME=/home/git + +# Some distributions may not support these hardening directives. If you cannot start the service due +# to an unknown option, comment out the ones not supported by your version of systemd. +ProtectSystem=full +PrivateDevices=yes +PrivateTmp=yes +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target diff --git a/plugins/gogs/init.d/gogs.service.tpl b/plugins/gogs/init.d/gogs.service.tpl index 0bfca87e5..02d19b9de 100644 --- a/plugins/gogs/init.d/gogs.service.tpl +++ b/plugins/gogs/init.d/gogs.service.tpl @@ -1,30 +1,12 @@ [Unit] Description=Gogs -After=syslog.target After=network.target -After=mariadb.service mysqld.service postgresql.service memcached.service redis.service [Service] -# Modify these two values and uncomment them if you have -# repos with lots of files and get an HTTP error 500 because -# of that -### -#LimitMEMLOCK=infinity -#LimitNOFILE=65535 -Type=simple -User=root -Group=root -WorkingDirectory={$SERVER_PATH}/gogs -ExecStart={$SERVER_PATH}/gogs/gogs web -Restart=always -Environment=USER=git HOME=/home/git - -# Some distributions may not support these hardening directives. If you cannot start the service due -# to an unknown option, comment out the ones not supported by your version of systemd. -ProtectSystem=full -PrivateDevices=yes -PrivateTmp=yes -NoNewPrivileges=true +Type=forking +ExecStart={$SERVER_PATH}/gogs/init.d/gogs start +ExecStop={$SERVER_PATH}/gogs/init.d/gogs stop +RemainAfterExit=yes [Install] WantedBy=multi-user.target diff --git a/plugins/gogs/install.sh b/plugins/gogs/install.sh index 002373497..a00d2641e 100755 --- a/plugins/gogs/install.sh +++ b/plugins/gogs/install.sh @@ -35,6 +35,16 @@ Install_gogs() version=$1 os=`getOs` + # if id git &> /dev/null ;then + # echo "git uid is `id -u git`" + # echo "git shell is `grep "^git:" /etc/passwd |cut -d':' -f7 `" + # else + # groupadd git + # useradd -g git git + # fi + + git config --global push.default simple + if [ "darwin" == "$os" ];then file=gogs_${version}_darwin_amd64.zip else @@ -47,8 +57,11 @@ Install_gogs() cd $serverPath/source/gogs && unzip -o $file -d gogs_${version} mv $serverPath/source/gogs/gogs_${version}/gogs/ $serverPath/gogs - echo $version > $serverPath/gogs/version.pl + + if [ -d $serverPath/gogs ];then + echo $version > $serverPath/gogs/version.pl + fi # if id -u gogs > /dev/null 2>&1; then # echo "gogs user exists" # else @@ -63,6 +76,10 @@ Install_gogs() Uninstall_gogs() { rm -rf $serverPath/gogs + if [ -f /usr/lib/systemd/system/gogs.service ];then + systemctl stop gogs + rm -rf /usr/lib/systemd/system/gogs.service + fi echo 'uninstall success' > $install_tmp } diff --git a/plugins/gogs/js/gogs.js b/plugins/gogs/js/gogs.js index 8e9232d40..0792201c0 100755 --- a/plugins/gogs/js/gogs.js +++ b/plugins/gogs/js/gogs.js @@ -317,7 +317,7 @@ function getRsaPublic(){ var rdata = $.parseJSON(data.data); var con = '
\
\ - \ + \
\
    \
    ' diff --git a/plugins/mongodb/info.json b/plugins/mongodb/info.json index e354e1cdb..6172e4ac6 100755 --- a/plugins/mongodb/info.json +++ b/plugins/mongodb/info.json @@ -4,8 +4,8 @@ "name": "mongodb", "title": "Mongodb", "shell": "install.sh", - "versions":["4.4.14","5.0.9"], - "updates":["4.4.14","5.0.9"], + "versions":["4.4.14","5.0.4"], + "updates":["4.4.14","5.0.4"], "tip": "soft", "checks": "server/mongodb", "path": "server/mongodb", diff --git a/plugins/mysql/class/mysqlDb.py b/plugins/mysql/class/mysqlDb.py index 15bf62135..867d3f3d7 100755 --- a/plugins/mysql/class/mysqlDb.py +++ b/plugins/mysql/class/mysqlDb.py @@ -30,7 +30,7 @@ class mysqlDb: '''连接MYSQL数据库''' try: import mw - socket = '/tmp/mysql.sock' + socket = '/www/server/mysql/mysql.sock' try: import MySQLdb except Exception as ex: diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index 26cf2e994..c51593d2f 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -80,7 +80,7 @@ innodb_write_io_threads = 1 innodb_file_per_table=1 -secure-file-priv=/tmp +secure-file-priv={$SERVER_APP_PATH}/tmp [mysqldump] quick diff --git a/plugins/mysql/conf/my5.7.cnf b/plugins/mysql/conf/my5.7.cnf index b1ceb4ecb..02d4b649d 100644 --- a/plugins/mysql/conf/my5.7.cnf +++ b/plugins/mysql/conf/my5.7.cnf @@ -76,7 +76,7 @@ innodb_read_io_threads = 1 innodb_write_io_threads = 1 innodb_file_per_table=1 -secure-file-priv=/tmp +secure-file-priv={$SERVER_APP_PATH}/tmp [mysqldump] quick diff --git a/plugins/mysql/conf/my8.0.cnf b/plugins/mysql/conf/my8.0.cnf index 453ee1173..e4acaf3db 100644 --- a/plugins/mysql/conf/my8.0.cnf +++ b/plugins/mysql/conf/my8.0.cnf @@ -77,7 +77,7 @@ innodb_write_io_threads = 1 innodb_file_per_table=1 binlog_expire_logs_seconds=2592000 -secure-file-priv=/tmp +secure-file-priv={$SERVER_APP_PATH}/tmp [mysqldump] quick diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 1d624817c..d13d6e5db 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -103,6 +103,8 @@ def getConf(): def getInitdTpl(version=''): path = getPluginDir() + '/init.d/mysql' + version + '.tpl' + if not os.path.exists(path): + path = getPluginDir() + '/init.d/mysql.tpl' return path @@ -161,6 +163,11 @@ def initDreplace(version=''): if not os.path.exists(mysql_conf_dir): os.mkdir(mysql_conf_dir) + mysql_tmp = getServerDir() + '/tmp' + if not os.path.exists(mysql_tmp): + os.mkdir(mysql_tmp) + mw.execShell("chown -R mysql:mysql " + mysql_tmp) + mysql_conf = mysql_conf_dir + '/my.cnf' if not os.path.exists(mysql_conf): mysql_conf_tpl = getPluginDir() + '/conf/my' + version + '.cnf' @@ -291,8 +298,8 @@ def initMysqlData(): cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --user=' + \ user + ' --basedir=' + serverdir + ' --ldata=' + datadir mw.execShell(cmd) - return 0 - return 1 + return False + return True def initMysql57Data(): @@ -302,10 +309,10 @@ def initMysql57Data(): myconf = serverdir + "/etc/my.cnf" user = pGetDbUser() cmd = 'cd ' + serverdir + ' && ./bin/mysqld --defaults-file=' + myconf + \ - ' --initialize --explicit_defaults_for_timestamp' + ' --initialize-insecure --explicit_defaults_for_timestamp' mw.execShell(cmd) - return 0 - return 1 + return False + return True def initMysql8Data(): @@ -313,12 +320,16 @@ def initMysql8Data(): if not os.path.exists(datadir + '/mysql'): serverdir = getServerDir() user = pGetDbUser() + # cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ + # datadir + ' --initialize' + cmd = 'cd ' + serverdir + ' && ./bin/mysqld --basedir=' + serverdir + ' --datadir=' + \ - datadir + ' --initialize' + datadir + ' --initialize-insecure' + # print(cmd) mw.execShell(cmd) - return 0 - return 1 + return False + return True def initMysqlPwd(): @@ -328,8 +339,8 @@ def initMysqlPwd(): pwd = mw.getRandomString(16) cmd_pass = serverdir + '/bin/mysqladmin -uroot password ' + pwd - pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) mw.execShell(cmd_pass) + pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) return True @@ -347,62 +358,29 @@ def mysql8IsInitedPasswd(): def initMysql8Pwd(): - is_start = False - for x in range(60): - data = mw.execShell( - "ps -ef|grep mysql|grep -v grep|grep -v py|grep -v init.d|awk '{print $2}'") - if data[0] != "": - # print("mysql start ok!") - is_start = True - break - time.sleep(0.5) - - if not is_start: - # print("mysql start fail!") - return False + time.sleep(2) serverdir = getServerDir() pwd = mw.getRandomString(16) - pass_cmd = "cat " + serverdir + \ - "/data/error.log | grep root@localhost | awk -F 'root@localhost:' '{print $2}'" - passdata = mw.execShell(pass_cmd) - password = passdata[0].strip() - - if len(password) == 0: - return True - - # print('localhost', 3306, 'root', password, - # "/www/server/mysql/mysql.sock") - - # import MySQLdb as mdb - # dbconn = mdb.connect(host='localhost', port=3306, user='root', - # passwd=password, unix_socket="/www/server/mysql/mysql.sock") - # dbconn.autocommit(True) - # dbcurr = dbconn.cursor() - # dbcurr.execute('SET NAMES UTF8MB4') - - # # with mysql_native_password alter_root_pwd = 'flush privileges;' alter_root_pwd = alter_root_pwd + \ "alter user 'root'@'localhost' IDENTIFIED by '" + pwd + "';" alter_root_pwd = alter_root_pwd + \ "alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '" + pwd + "';" alter_root_pwd = alter_root_pwd + "flush privileges;" - # dbcurr.execute(alter_root_pwd) + + cmd_pass = serverdir + '/bin/mysqladmin -uroot password root' + data = mw.execShell(cmd_pass) + # print(data) tmp_file = "/tmp/mysql_init_tmp.log" mw.writeFile(tmp_file, alter_root_pwd) - cmd_pass = serverdir + '/bin/mysql --connect-expired-password -uroot -p"' + \ - password + '" < ' + tmp_file - # print(cmd_pass) + cmd_pass = serverdir + '/bin/mysql -uroot -proot < ' + tmp_file + data = mw.execShell(cmd_pass) - if data[1].find("ERROR") != -1: - # print(data[1]) - pass - else: - mw.writeFile(serverdir + "/data/error.log", "") - os.remove(tmp_file) + # print(data) + os.remove(tmp_file) pSqliteDb('config').where('id=?', (1,)).save('mysql_root', (pwd,)) @@ -413,9 +391,11 @@ def myOp(version, method): # import commands init_file = initDreplace() try: - initData = initMysqlData() - if initData == 0: + isInited = initMysqlData() + if not isInited: + mw.execShell('systemctl start mysql') initMysqlPwd() + mw.execShell('systemctl stop mysql') mw.execShell('systemctl ' + method + ' mysql') return 'ok' @@ -424,39 +404,46 @@ def myOp(version, method): def my8cmd(version, method): - # mysql 8.0 and 5.7 ok + # mysql 8.0 and 5.7 init_file = initDreplace(version) - if version == '5.7': - initMysql57Data() - elif version == '8.0': - initMysql8Data() + cmd = init_file + ' ' + method try: + if version == '5.7': + isInited = initMysql57Data() + elif version == '8.0': + isInited = initMysql8Data() + + if not isInited: + + if mw.isAppleSystem(): + cmd_init_start = init_file + ' start' + subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) - if not mysql8IsInitedPasswd(): - setSkipGrantTables(True) - cmd_init_start = init_file + ' start' - subprocess.Popen(cmd_init_start, stdout=subprocess.PIPE, shell=True, - bufsize=4096, stderr=subprocess.PIPE) + time.sleep(6) + else: + mw.execShell('systemctl start mysql') - time.sleep(6) initMysql8Pwd() - cmd_init_stop = init_file + ' stop' - subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, - bufsize=4096, stderr=subprocess.PIPE) - setSkipGrantTables(False) + if mw.isAppleSystem(): + cmd_init_stop = init_file + ' stop' + subprocess.Popen(cmd_init_stop, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + time.sleep(3) + else: + mw.execShell('systemctl stop mysql') - time.sleep(3) - my8cmd(version, method) + if mw.isAppleSystem(): + sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, + bufsize=4096, stderr=subprocess.PIPE) + sub.wait(5) else: mw.execShell('systemctl ' + method + ' mysql') - return 'ok' except Exception as e: return str(e) - return 'fail' - def appCMD(version, action): if version == '8.0' or version == '5.7': @@ -481,9 +468,8 @@ def reload(version=''): def initdStatus(): - if not app_debug: - if mw.isAppleSystem(): - return "Apple Computer does not support" + if mw.isAppleSystem(): + return "Apple Computer does not support" shell_cmd = 'systemctl status mysql | grep loaded | grep "enabled;"' data = mw.execShell(shell_cmd) @@ -673,7 +659,7 @@ def isSqlError(mysqlMsg): # 检测数据库执行错误 mysqlMsg = str(mysqlMsg) if "MySQLdb" in mysqlMsg: - return mw.returnJson(False, 'MySQLdb组件缺失!
    进入SSH命令行输入: pip install mysql-python') + return mw.returnJson(False, 'MySQLdb组件缺失!
    进入SSH命令行输入: pip install mysql-python | pip install mysqlclient==2.0.3') if "2002," in mysqlMsg: return mw.returnJson(False, '数据库连接失败,请检查数据库服务是否启动!') if "2003," in mysqlMsg: diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index d29c35e70..78926c7f5 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -805,6 +805,8 @@ function setDbPs(id, name, obj) { function openPhpmyadmin(name,username,password){ data = syncPost('/plugins/check',{'name':'phpmyadmin'}); + + if (!data.status){ layer.msg(data.msg,{icon:2,shade: [0.3, '#000']}); return; @@ -815,7 +817,7 @@ function openPhpmyadmin(name,username,password){ layer.msg('phpMyAdmin未启动',{icon:2,shade: [0.3, '#000']}); return; } - + // console.log(data); data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'get_home_page'}); var rdata = $.parseJSON(data.data); if (!rdata.status){ @@ -830,16 +832,28 @@ function openPhpmyadmin(name,username,password){ return; } - var murl = $("#toPHPMyAdmin").attr('action'); - $("#pma_username").val(username); - $("#pma_password").val(password); - $("#db").val(name); + //检查版本 + data = syncPost('/plugins/run',{'name':'phpmyadmin','func':'version'}); + bigVer = data.data.split('.')[0] + if (bigVer>=5){ - layer.msg('正在打开phpMyAdmin',{icon:16,shade: [0.3, '#000'],time:1000}); + setTimeout(function(){ + $("#toPHPMyAdmin").submit(); + },3000); + layer.msg('phpMyAdmin['+data.data+']需要手动登录😭',{icon:16,shade: [0.3, '#000'],time:4000}); + + } else{ + var murl = $("#toPHPMyAdmin").attr('action'); + $("#pma_username").val(username); + $("#pma_password").val(password); + $("#db").val(name); + + layer.msg('正在打开phpMyAdmin',{icon:16,shade: [0.3, '#000'],time:2000}); - setTimeout(function(){ - $("#toPHPMyAdmin").submit(); - },2000); + setTimeout(function(){ + $("#toPHPMyAdmin").submit(); + },3000); + } } function delBackup(filename,name){ diff --git a/plugins/mysql/versions/5.5/install.sh b/plugins/mysql/versions/5.5/install.sh index 81f4d2271..659912f7c 100755 --- a/plugins/mysql/versions/5.5/install.sh +++ b/plugins/mysql/versions/5.5/install.sh @@ -14,16 +14,23 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl mysqlDir=${serverPath}/source/mysql + Install_mysql() { mkdir -p ${mysqlDir} echo '正在安装脚本文件...' > $install_tmp + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + if [ "$sysName" != "Darwin" ];then mkdir -p /var/log/mariadb touch /var/log/mariadb/mariadb.log - groupadd mysql - useradd -g mysql mysql fi if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then @@ -47,11 +54,18 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ - && make && make install && make clean \ - && echo '5.5' > $serverPath/mysql/version.pl - echo '安装完成' > $install_tmp + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ + && make ${MAKEJN:--j2} && make install && make clean + + if [ -d $serverPath/mysql ];then + echo '5.5' > $serverPath/mysql/version.pl + echo '安装完成' > $install_tmp + else + echo '安装失败' > $install_tmp + fi fi } diff --git a/plugins/mysql/versions/5.6/install.sh b/plugins/mysql/versions/5.6/install.sh index e8c79bff4..31f193176 100755 --- a/plugins/mysql/versions/5.6/install.sh +++ b/plugins/mysql/versions/5.6/install.sh @@ -17,16 +17,23 @@ sysName=`uname` install_tmp=${rootPath}/tmp/mw_install.pl mysqlDir=${serverPath}/source/mysql + Install_mysql() { mkdir -p ${mysqlDir} echo '正在安装脚本文件...' > $install_tmp + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + if [ "$sysName" != "Darwin" ];then mkdir -p /var/log/mariadb touch /var/log/mariadb/mariadb.log - groupadd mysql - useradd -g mysql mysql fi @@ -51,11 +58,19 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ - && make && make install && make clean - echo '5.6' > $serverPath/mysql/version.pl - echo '安装完成' > $install_tmp + -DDEFAULT_CHARSET=utf8mb4 \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ + && make ${MAKEJN:--j2} && make install && make clean + + + if [ -d $serverPath/mysql ];then + echo '5.6' > $serverPath/mysql/version.pl + echo '安装完成' > $install_tmp + else + echo '安装失败' > $install_tmp + fi fi } diff --git a/plugins/mysql/versions/5.7/install.sh b/plugins/mysql/versions/5.7/install.sh index 5efccde0c..76376cb9a 100755 --- a/plugins/mysql/versions/5.7/install.sh +++ b/plugins/mysql/versions/5.7/install.sh @@ -19,22 +19,43 @@ mysqlDir=${serverPath}/source/mysql VERSION="5.7.37" + Install_mysql() { mkdir -p ${mysqlDir} echo '正在安装脚本文件...' > $install_tmp + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + if [ "$sysName" != "Darwin" ];then mkdir -p /var/log/mariadb touch /var/log/mariadb/mariadb.log - groupadd mysql - useradd -g mysql mysql - fi + fi + if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz fi + #检测文件是否损坏. + md5_mysql_ok=d0489fc3880248a58759c50bfb286dbb + if [ -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then + md5_mysql=`md5sum ${mysqlDir}/mysql-boost-${VERSION}.tar.gz | awk '{print $1}'` + if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then + echo "mysql5.7 file check ok" + else + # 重新下载 + rm -rf ${mysqlDir}/mysql-${VERSION} + wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-${VERSION}.tar.gz + fi + fi + if [ ! -d ${mysqlDir}/mysql-${VERSION} ];then cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-${VERSION}.tar.gz fi @@ -51,11 +72,13 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=1 \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ -DWITH_BOOST=${mysqlDir}/mysql-${VERSION}/boost/ - make && make install && make clean + make ${MAKEJN:--j2} && make install && make clean echo '5.7' > $serverPath/mysql/version.pl echo '安装完成' > $install_tmp fi diff --git a/plugins/mysql/versions/8.0/install.sh b/plugins/mysql/versions/8.0/install.sh index 2a7f63615..b1677e74e 100755 --- a/plugins/mysql/versions/8.0/install.sh +++ b/plugins/mysql/versions/8.0/install.sh @@ -1,3 +1,5 @@ +export MAKEJN=-j12 + # -*- coding: utf-8 -*- #!/bin/bash @@ -22,13 +24,19 @@ Install_mysql() mkdir -p ${mysqlDir} echo '正在安装脚本文件...' > $install_tmp + + if id mysql &> /dev/null ;then + echo "mysql UID is `id -u www`" + echo "mysql Shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `" + else + groupadd mysql + useradd -g mysql mysql + fi + INSTALL_CMD=cmake if [ "$sysName" != "Darwin" ];then mkdir -p /var/log/mariadb touch /var/log/mariadb/mariadb.log - groupadd mysql - useradd -g mysql mysql - INSTALL_CMD=cmake fi @@ -36,10 +44,24 @@ Install_mysql() wget -O ${mysqlDir}/mysql-boost-8.0.25.tar.gz https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.25.tar.gz fi + #检测文件是否损坏. + md5_mysql_ok=e142c2058313b4646c36fa9bb1b38493 + if [ -f ${mysqlDir}/mysql-boost-8.0.25.tar.gz ];then + md5_mysql=`md5sum ${mysqlDir}/mysql-boost-8.0.25.tar.gz | awk '{print $1}'` + if [ "${md5_mysql_ok}" == "${md5_mysql}" ]; then + echo "mysql8.0 file check ok" + else + # 重新下载 + rm -rf ${mysqlDir}/mysql-8.0.25 + wget -O ${mysqlDir}/mysql-boost-8.0.25.tar.gz https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-8.0.25.tar.gz + fi + fi + if [ ! -d ${mysqlDir}/mysql-8.0.25 ];then cd ${mysqlDir} && tar -zxvf ${mysqlDir}/mysql-boost-8.0.25.tar.gz fi + if [ ! -d $serverPath/mysql ];then cd ${mysqlDir}/mysql-8.0.25 && ${INSTALL_CMD} \ -DCMAKE_INSTALL_PREFIX=$serverPath/mysql \ @@ -52,13 +74,18 @@ Install_mysql() -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ + -DDEFAULT_CHARSET=utf8mb4 \ + -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DDOWNLOAD_BOOST=1 \ -DFORCE_INSOURCE_BUILD=1 \ + -DCMAKE_C_COMPILER=/usr/bin/gcc \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ -DWITH_BOOST=${mysqlDir}/mysql-8.0.25/boost/ - make && make install && make clean - echo '8.0' > $serverPath/mysql/version.pl + make ${MAKEJN:--j2} && make install && make clean + + if [ -d $serverPath/mysql ];then + echo '8.0' > $serverPath/mysql/version.pl + fi echo '安装完成' > $install_tmp fi } diff --git a/plugins/op_waf/install.sh b/plugins/op_waf/install.sh index d825e7e11..d29ae27b7 100755 --- a/plugins/op_waf/install.sh +++ b/plugins/op_waf/install.sh @@ -15,8 +15,10 @@ Install_of(){ echo '正在安装脚本文件...' > $install_tmp mkdir -p $serverPath/op_waf - mkdir -p $rootPath/wwwlogs/waf + if [ -f $serverPath/openresty ];then + mkdir -p $serverPath/openresty/nginx/conf/waf + fi echo '0.1' > $serverPath/op_waf/version.pl echo 'install ok' > $install_tmp } diff --git a/plugins/op_waf/waf/html/cookie.html b/plugins/op_waf/waf/html/cookie.html index dde7d7833..6c91a2efa 100755 --- a/plugins/op_waf/waf/html/cookie.html +++ b/plugins/op_waf/waf/html/cookie.html @@ -2,7 +2,7 @@ -网站防火墙 +OP网站防火墙