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... - -```   @@ -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) ### 无图不真相 @@ -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 [](https://starchart.cc/midoks/mdserver-web) -### 感谢 - -- 开发赞助 +### 感谢开发赞助 -[digitalvirt](https://digitalvirt.com/) +[](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 @@