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/.github/workflows/python-app.yml b/.github/workflows/python-app-mysql8.yml similarity index 53% rename from .github/workflows/python-app.yml rename to .github/workflows/python-app-mysql8.yml index 1a5293b29..d33551fdc 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app-mysql8.yml @@ -1,13 +1,13 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: MW APP +name: MW APP MySQL80 on: push: - branches: [ "master" ] + branches: [ "master","dev" ] pull_request: - branches: [ "master" ] + branches: [ "master","dev" ] permissions: contents: read @@ -26,10 +26,17 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" - - name: Install dependencies + - name: Install MW run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi + sudo bash scripts/install_dev.sh + - name: Install MySQL80 + run: | + sudo mkdir -p /tmp + sudo cat /www/server/mdserver-web/plugins/mysql/versions/8.0/install.sh > /tmp/t.log + sudo echo "export MAKEJN=-j12\n" >> /www/server/mdserver-web/plugins/mysql/versions/8.0/install.sh + sudo cat /tmp/t.log >> /www/server/mdserver-web/plugins/mysql/versions/8.0/install.sh + + cd /www/server/mdserver-web/plugins/mysql && sudo bash install.sh install 8.0 - name: Start DEBUG run: | gunicorn -c setting.py app:app diff --git a/.github/workflows/python-app-op.yml b/.github/workflows/python-app-op.yml new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.github/workflows/python-app-op.yml @@ -0,0 +1 @@ + diff --git a/.github/workflows/python3.6.8-app.yml b/.github/workflows/python3.6.8-app.yml deleted file mode 100644 index ddc13ace1..000000000 --- a/.github/workflows/python3.6.8-app.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: MW APP 3.6.8 - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - #runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.6.8 - uses: actions/setup-python@v3 - with: - python-version: "3.6.8" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi - - name: Start DEBUG - run: | - gunicorn -c setting.py app:app - python3 task.py & diff --git a/.gitignore b/.gitignore index aae13447a..168553aa0 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,8 @@ include data/api_login.txt data/sessions data/ssl.pl +data/port.pl +plugins/openlitespeed +plugins/gdrive/ +data/ipv6.pl +data/restart.pl diff --git a/README.md b/README.md index 2c908a929..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使用 - 自动安装 @@ -111,10 +109,9 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/up 如果你自己写了插件,想分享出来,也可以提Issue。 ``` -- 开发文档 - https://github.com/midoks/mdserver-web/wiki/插件开发 +- 简单例子 - 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 @@ -122,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 f8fa5ccf7..beb8347f8 100755 --- a/class/core/mw.py +++ b/class/core/mw.py @@ -570,7 +570,7 @@ def downloadHook(count, blockSize, totalSize): print('%02d%%' % (100.0 * count * blockSize / totalSize)) -def getLocalIp(): +def getLocalIpBack(): # 取本地外网IP try: import re @@ -591,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/site_api.py b/class/core/site_api.py index 6978c96e1..36a0be774 100755 --- a/class/core/site_api.py +++ b/class/core/site_api.py @@ -1526,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('|', ',') @@ -1553,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) @@ -1619,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/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 @@