Compare commits

...
119 Commits
Author SHA1 Message Date
Mr Chen 2861f7f995 Merge pull request #282 from midoks/dev
0.11.2
2022-12-03 12:32:47 +08:00
midoks 10d6fa2d47 0.11.2 2022-12-03 12:31:51 +08:00
midoks 16e5b4ae73 php82 rc7 测试版 2022-12-03 12:03:34 +08:00
midoks aca89d7d5e Update config.html 2022-12-03 12:00:35 +08:00
midoks ffefe96f1f 域名绑定 2022-12-03 11:49:20 +08:00
midoks e1e1e81a90 Update gettext.sh 2022-12-03 11:47:09 +08:00
midoks 502295125a Update gettext.sh 2022-12-03 11:33:02 +08:00
midoks 85258dd80b Update lib.sh 2022-12-03 02:34:36 +08:00
midoks ff0cb6eb31 up 2022-12-03 01:28:39 +08:00
midoks e4e1945ea5 域名配置 2022-12-03 01:23:11 +08:00
midoks e7f74a482f Update install.sh 2022-12-02 23:25:54 +08:00
midoks dd27af9ede up 2022-12-02 23:23:50 +08:00
midoks 4aeffd2aa6 Update openssl.sh 2022-12-02 22:59:05 +08:00
midoks 8924957e7f Update centos.sh 2022-12-02 22:55:56 +08:00
midoks c013db9d41 Update install.sh 2022-12-02 22:54:35 +08:00
midoks e492abf354 Update openssl.sh 2022-12-02 22:54:28 +08:00
midoks f84cab9e98 Update openssl.sh 2022-12-02 22:51:57 +08:00
midoks eb5be2842d Update openssl.sh 2022-12-02 22:51:29 +08:00
midoks 06e99096cf Update yar.sh 2022-12-02 22:50:32 +08:00
midoks 93f1129c0f Update gd.sh 2022-12-02 22:36:35 +08:00
midoks 46bc94946c Update site.js 2022-12-02 12:55:09 +08:00
midoks 0857c6aed7 Update config_api.py 2022-12-02 12:51:45 +08:00
midoks fdcdd27f8e Update site.js 2022-12-02 12:45:51 +08:00
midoks d1810606db Update config_api.py 2022-12-01 23:09:33 +08:00
midoks 68f5f4c6cb Update site.js 2022-12-01 23:07:52 +08:00
midoks d40665c0f8 Update site.js 2022-12-01 23:05:23 +08:00
midoks 9d1ebba509 up 2022-12-01 23:02:25 +08:00
midoks d0113840a3 up 2022-12-01 22:55:17 +08:00
midoks 43c287132b php命令功能 2022-12-01 22:50:17 +08:00
midoks deb3a40fb7 Update README.md 2022-12-01 20:52:59 +08:00
midoks 88196175f4 Update index.py 2022-12-01 17:42:20 +08:00
midoks 217ba2d14e Update index.py 2022-12-01 17:41:34 +08:00
midoks 7af7e2321a Update webstats_log.lua 2022-12-01 17:09:39 +08:00
midoks 20b39cbb70 Update webstats_common.lua 2022-12-01 12:43:31 +08:00
midoks 66ff690bae Update webstats_log.lua 2022-12-01 12:33:09 +08:00
midoks 99e8e63917 Update webstats_common.lua 2022-12-01 03:28:39 +08:00
midoks a4dfe26254 Update webstats_common.lua 2022-12-01 03:27:24 +08:00
midoks 15c0ef390e Update webstats_common.lua 2022-12-01 03:15:53 +08:00
midoks a2b9658b2e Update webstats_common.lua 2022-12-01 03:03:50 +08:00
midoks 5bcb0fb739 Update webstats_log.lua 2022-12-01 03:01:32 +08:00
midoks 6278c9588b Update files.js 2022-12-01 01:06:14 +08:00
midoks 19d4456e2e Update index.py 2022-11-30 21:06:13 +08:00
midoks 807cb8fe98 Update install.sh 2022-11-30 20:19:15 +08:00
midoks ba2df01084 登出 2022-11-30 20:03:07 +08:00
midoks d82b0dbe9f Update commit.tpl 2022-11-30 16:13:18 +08:00
midoks acc18cf571 up 2022-11-30 16:02:17 +08:00
midoks f69dd139c0 Update commit.tpl.ssh 2022-11-30 15:25:39 +08:00
midoks ab6f860bde Update index.py 2022-11-30 15:14:07 +08:00
midoks febe56f430 Update index.py 2022-11-30 14:46:53 +08:00
midoks 0962e5aab8 up 2022-11-30 14:44:56 +08:00
midoks 5ea062862f 为了同步代码,改为www 2022-11-30 14:39:37 +08:00
midoks cce5598f2f Update index.py 2022-11-30 13:22:23 +08:00
midoks d88962eb56 gitea卸载检查 2022-11-30 13:21:28 +08:00
midoks b44e24df0d Update index.py 2022-11-30 12:19:31 +08:00
midoks f36e540a59 加强redis安全 2022-11-30 11:46:40 +08:00
midoks 992e7445f6 mysql utf8mb4排第一 2022-11-29 20:30:08 +08:00
midoks 066729e8d9 up 2022-11-29 20:18:51 +08:00
Mr Chen be3e57a905 Merge pull request #280 from midoks/dev
版本号修正
2022-11-29 12:26:41 +08:00
midoks bc7a569ae9 Update config_api.py 2022-11-29 12:25:45 +08:00
Mr Chen 1bc24b12fc Merge pull request #278 from midoks/dev
0.11.1
2022-11-29 10:47:24 +08:00
midoks b2fdc8212f 0.11.1
* 提供面板API接口访问的支持。
* rockylinux系统安装优化。
* 网站统计记录POST请求原文优化。
* 针对mysql下载速度优化。
* mysql初始化默认参数优化。
* OP防火墙安全设置BUG解决。
* Gitea优化。
2022-11-29 10:42:35 +08:00
midoks ab763f444b up 2022-11-29 10:19:56 +08:00
midoks c0738ff1bd Update config_api.py 2022-11-29 03:06:03 +08:00
midoks 82dd2553e6 网站统计记录POST请求原文优化 2022-11-29 02:58:52 +08:00
midoks ae371be91a Update install.sh 2022-11-29 02:47:09 +08:00
midoks 48e1ecaec6 up 2022-11-28 21:46:56 +08:00
midoks 5a21c4dac8 优化下载速度 2022-11-28 21:35:07 +08:00
midoks 7e014dfa94 提供面板API接口访问的支持
还有功能要上,肯能会影响使用,,测试使用即可。
2022-11-28 20:14:45 +08:00
midoks 93785a2472 Update ioncube.sh 2022-11-28 17:05:51 +08:00
midoks cd0f5fd8a0 Update rocky.sh 2022-11-28 16:05:03 +08:00
midoks d12524debd Update info.json 2022-11-28 11:52:44 +08:00
midoks 297fb60fcb Update mw.tpl 2022-11-28 11:50:55 +08:00
midoks d3781edad0 Update close.html 2022-11-28 11:50:51 +08:00
midoks 78667460e6 up 2022-11-28 11:50:36 +08:00
midoks decc579c2d up 2022-11-28 10:35:32 +08:00
midoks 34a64eafa2 Update install_dev.sh 2022-11-28 02:06:52 +08:00
midoks 38b263e689 Update rocky.sh 2022-11-28 02:04:37 +08:00
midoks 0ad3e8d42c Update rocky.sh 2022-11-28 02:02:39 +08:00
midoks 5243f6f4c3 Update rocky.sh 2022-11-28 01:53:52 +08:00
midoks 976c8c3271 Update lib.sh 2022-11-28 01:42:10 +08:00
midoks b627b222bc Update lib.sh 2022-11-28 01:40:40 +08:00
midoks 8df8365eaa Update rocky.sh 2022-11-28 01:32:44 +08:00
midoks d735d857a4 Update rocky.sh 2022-11-28 01:22:21 +08:00
midoks 211764060f up 2022-11-28 01:21:00 +08:00
midoks b07be2d004 Update lib.sh 2022-11-28 01:17:33 +08:00
midoks c6edd2221c Update backup.py 2022-11-28 00:08:36 +08:00
midoks be8dd153a3 up 2022-11-27 23:31:48 +08:00
midoks e4aef4592e Update index.py 2022-11-27 22:34:41 +08:00
midoks 4f5b25a680 Update index.py 2022-11-27 22:12:37 +08:00
midoks abc4486311 up 2022-11-27 21:51:32 +08:00
midoks baeb788148 up 2022-11-27 20:46:31 +08:00
midoks e30dcf1fbe 修改优惠码 2022-11-27 14:12:52 +08:00
midoks e7347c4a4c Update index.py 2022-11-27 11:20:41 +08:00
midoks 044cad1e64 API接口 后台ui 完成。 功能50% 2022-11-27 00:28:09 +08:00
midoks c0d0efb756 up 2022-11-26 16:23:58 +08:00
midoks 49d1579782 Update index.py 2022-11-26 13:20:24 +08:00
midoks b6f7ec11c2 Update install.sh 2022-11-25 23:52:09 +08:00
midoks 0860ffc713 Update install.sh 2022-11-25 23:48:12 +08:00
midoks cd3f7603e8 Update install.sh 2022-11-25 23:47:15 +08:00
midoks bc0e7764b2 Update install.sh 2022-11-25 23:45:19 +08:00
midoks cfe185b105 Update gitea.service.tpl 2022-11-25 23:24:28 +08:00
midoks 3094a0af32 Update index.py 2022-11-25 16:47:44 +08:00
midoks 7f010caa6e Update index.py 2022-11-25 16:46:25 +08:00
midoks 2b6d287cf1 Update index.py 2022-11-25 16:43:13 +08:00
midoks e525323a7d Update index.py 2022-11-25 16:38:11 +08:00
midoks 69670aa1f6 Update index.py 2022-11-25 16:26:13 +08:00
midoks d741677b66 Update index.py 2022-11-25 16:21:22 +08:00
midoks 7fd4ea28c1 Update .gitignore 2022-11-25 13:27:21 +08:00
midoks 41294a23a2 Update .gitignore 2022-11-25 12:10:39 +08:00
midoks 86edf89474 Update .gitignore 2022-11-25 09:25:15 +08:00
midoks e2f4043569 Create fastdfs.conf 2022-11-24 19:10:33 +08:00
midoks 6ebcb8e005 up 2022-11-24 18:21:25 +08:00
midoks 088b7425d7 Update backup.py 2022-11-23 19:56:41 +08:00
midoks f854eed924 Update config.js 2022-11-23 19:42:56 +08:00
Mr Chen ba706e070e Merge pull request #269 from midoks/dev
ipv6识别启动优化
2022-11-23 11:50:23 +08:00
midoks 2cdaa36744 Update mw.tpl 2022-11-23 11:46:26 +08:00
midoks 7937189935 up 2022-11-23 02:38:03 +08:00
midoks 1b7f1e2f13 Update info.json 2022-11-23 02:29:19 +08:00
midoks a88483e2ba Update .gitignore 2022-11-22 20:15:18 +08:00
78 changed files with 1095 additions and 250 deletions
+7 -1
View File
@@ -107,7 +107,6 @@ venv.bak/
tmp/*
*.swp
*.zip
scripts/init.d/mw
logs/*
data/*.db
data/control.conf
@@ -132,7 +131,9 @@ include
share
pip-selfcheck.json
scripts/init.d/mw
scripts/mdserver-web
data/api_login.txt
data/sessions
data/ssl.pl
@@ -147,6 +148,8 @@ data/system.db-journal
data/hook_*.json
data/letsencrypt.json
data/basic_auth.json
data/api.json
data/bind_domain.pl
plugins/l2tp
plugins/openlitespeed
@@ -155,6 +158,9 @@ plugins/mtproxy
plugins/zimg
plugins/bk_demo
plugins/mail
plugins/fastdfs
plugins/v2ray
plugins/frp
debug.out
+10 -13
View File
@@ -78,8 +78,7 @@ PHP[72-81]支持phpMyAdmin[5.2.0]
| 服务商 | LOGO | 推广地址 | 优惠码 |
| ------------- |----------|-----------|-------|
| digitalvirt |[![digitalvirt](https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg)](https://digitalvirt.com/aff.php?aff=154) | https://digitalvirt.com/aff.php?aff=154 | 9SYDY7UH0U |
| 搬瓦工 |[![搬瓦工](https://bwh81.net/templates/organicbandwagon/images/logo.png)](https://bwh81.net/aff.php?aff=54161) | https://bwh81.net/aff.php?aff=54161 | BWH3HYATVBJW |
| digitalvirt |[![digitalvirt](https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg)](https://digitalvirt.com/aff.php?aff=154) | https://digitalvirt.com/aff.php?aff=154 | mdserver-web |
# Docker
@@ -91,18 +90,16 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```
### 版本更新 0.11.0
### 版本更新 0.11.2
* redis安全强化。
* 添加php命令行设置。
* 域名绑定。
* Gitea优化。
* 网站统计优化。
* centos9下php-gd安装优化。
* php82rc7测试版。
* 改造HTTPS升级,为lets和acme申请。
* 改造SSH管理,加入`禁止密码登陆`。
* 计划任务BUG,修改时错误提示。
* PG在debian11优化。
* PHP默认配置curl,openssl ssl配置优化。
* 初始花安装提示。
* 面板设置UI优化。
* 加入BasicAuth认证功能。
* MySQL[APT,YUM]安装检查优化。
* MySQL导入优化,对sql后缀支持。
### JSDelivr安装地址
+112 -1
View File
@@ -27,7 +27,8 @@ from flask import request
class config_api:
__version = '0.11.0'
__version = '0.11.2'
__api_addr = 'data/api.json'
def __init__(self):
pass
@@ -88,6 +89,21 @@ class config_api:
return mw.returnJson(True, '修改成功!')
return mw.returnJson(False, '修改失败!')
def setPanelDomainApi(self):
domain = request.form.get('domain', '')
cfg_domain = 'data/bind_domain.pl'
if domain == '':
os.remove(cfg_domain)
return mw.returnJson(True, '清空域名成功!')
reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$"
if not re.match(reg, domain):
return mw.returnJson(False, '主域名格式不正确')
mw.writeFile(cfg_domain, domain)
return mw.returnJson(True, '设置域名成功!')
def syncDateApi(self):
if mw.isAppleSystem():
return mw.returnJson(True, '开发系统不必同步时间!')
@@ -489,6 +505,85 @@ class config_api:
'id,type,uid,log,addtime').select()
return mw.returnJson(False, 'ok', data)
def checkPanelToken(self):
api_file = self.__api_addr
if not os.path.exists(api_file):
return False, ''
tmp = mw.readFile(api_file)
data = json.loads(tmp)
if data['open']:
return True, data
else:
return False, ''
def getPanelTokenApi(self):
api_file = self.__api_addr
tmp = mw.readFile(api_file)
if not os.path.exists(api_file):
ready_data = {"open": False, "token": "", "limit_addr": []}
mw.writeFile(api_file, json.dumps(ready_data))
mw.execShell("chmod 600 " + api_file)
tmp = mw.readFile(api_file)
data = json.loads(tmp)
if not 'key' in data:
data['key'] = mw.getRandomString(16)
mw.writeFile(api_file, json.dumps(data))
if 'token_crypt' in data:
data['token'] = mw.deCrypt(data['token'], data['token_crypt'])
else:
token = mw.getRandomString(32)
data['token'] = mw.md5(token)
data['token_crypt'] = mw.enCrypt(
data['token'], token).decode('utf-8')
mw.writeFile(api_file, json.dumps(data))
data['token'] = "***********************************"
data['limit_addr'] = '\n'.join(data['limit_addr'])
del(data['key'])
return mw.returnJson(True, 'ok', data)
def setPanelTokenApi(self):
op_type = request.form.get('op_type', '').strip()
api_file = self.__api_addr
tmp = mw.readFile(api_file)
data = json.loads(tmp)
if op_type == '1':
token = mw.getRandomString(32)
data['token'] = mw.md5(token)
data['token_crypt'] = mw.enCrypt(
data['token'], token).decode('utf-8')
mw.writeLog('API配置', '重新生成API-Token')
mw.writeFile(api_file, json.dumps(data))
return mw.returnJson(True, 'ok', token)
elif op_type == '2':
data['open'] = not data['open']
stats = {True: '开启', False: '关闭'}
if not 'token_crypt' in data:
token = mw.getRandomString(32)
data['token'] = mw.md5(token)
data['token_crypt'] = mw.enCrypt(
data['token'], token).decode('utf-8')
token = stats[data['open']] + '成功!'
mw.writeLog('API配置', '%sAPI接口' % stats[data['open']])
mw.writeFile(api_file, json.dumps(data))
return mw.returnJson(not not data['open'], token)
elif op_type == '3':
limit_addr = request.form.get('limit_addr', '').strip()
data['limit_addr'] = limit_addr.split('\n')
mw.writeLog('API配置', '变更IP限制为[%s]' % limit_addr)
mw.writeFile(api_file, json.dumps(data))
return mw.returnJson(True, '保存成功!')
def get(self):
data = {}
@@ -534,6 +629,22 @@ class config_api:
else:
data['basic_auth'] = ''
cfg_domain = 'data/bind_domain.pl'
if os.path.exists(cfg_domain):
domain = mw.readFile(cfg_domain)
data['bind_domain'] = domain.strip()
else:
data['bind_domain'] = ''
api_token = self.__api_addr
if os.path.exists(api_token):
bac = mw.readFile(api_token)
bac = json.loads(bac)
if bac['open']:
data['api_token'] = 'checked'
else:
data['api_token'] = ''
data['site_count'] = mw.M('sites').count()
data['username'] = mw.M('users').where(
+70 -1
View File
@@ -541,6 +541,34 @@ def dePunycode(domain):
return newdomain[0:-1]
def enCrypt(key, strings):
# 加密字符串
try:
if type(strings) != bytes:
strings = strings.encode('utf-8')
from cryptography.fernet import Fernet
f = Fernet(key)
result = f.encrypt(strings)
return result.decode('utf-8')
except:
# print(get_error_info())
return strings
def deCrypt(key, strings):
# 解密字符串
try:
if type(strings) != bytes:
strings = strings.decode('utf-8')
from cryptography.fernet import Fernet
f = Fernet(key)
result = f.decrypt(strings).decode('utf-8')
return result
except:
# print(get_error_info())
return strings
def buildSoftLink(src, dst, force=False):
'''
建立软连接
@@ -862,6 +890,47 @@ def checkIp(ip):
return False
def getHost(port=False):
from flask import request
host_tmp = request.headers.get('host')
if not host_tmp:
if request.url_root:
tmp = re.findall(r"(https|http)://([\w:\.-]+)", request.url_root)
if tmp:
host_tmp = tmp[0][1]
if not host_tmp:
host_tmp = getLocalIp() + ':' + readFile('data/port.pl').strip()
try:
if host_tmp.find(':') == -1:
host_tmp += ':80'
except:
host_tmp = "127.0.0.1:8888"
h = host_tmp.split(':')
if port:
return h[-1]
return ':'.join(h[0:-1])
def getClientIp():
from flask import request
return request.remote_addr.replace('::ffff:', '')
def checkDomainPanel():
tmp = getHost()
domain = readFile('data/bind_domain.pl')
port = readFile('data/port.pl').strip()
if domain:
client_ip = getClientIp()
if client_ip in ['127.0.0.1', 'localhost', '::1']:
return False
if tmp.strip().lower() != domain.strip().lower():
from flask import Flask, redirect, request, url_for
to = "http://" + domain + ":" + port
return redirect(to, code=302)
return False
def createLinuxUser(user, group):
execShell("groupadd {}".format(group))
execShell('useradd -s /sbin/nologin -g {} {}'.format(user, group))
@@ -899,7 +968,7 @@ def setOwn(filename, user, group=None):
def checkPort(port):
# 检查端口是否合法
ports = ['21', '25', '443', '888']
ports = ['21', '443', '888']
if port in ports:
return False
intport = int(port)
+55 -2
View File
@@ -139,6 +139,58 @@ class site_api:
data['default_site'] = mw.readFile('data/default_site.pl')
return mw.getJson(data)
def getCliPhpVersionApi(self):
php_bin = '/usr/bin/php'
php_versions = self.getPhpVersion()
php_versions = php_versions[1:]
if len(php_versions) < 1:
return mw.returnJson(False, '未安装PHP,无法设置')
if os.path.exists(php_bin) and os.path.islink(php_bin):
link_re = os.readlink(php_bin)
for v in php_versions:
if link_re.find(v['version']) != -1:
return mw.getJson({"select": v, "versions": php_versions})
return mw.getJson({
"select": php_versions[0],
"versions": php_versions})
def setCliPhpVersionApi(self):
if mw.isAppleSystem():
return mw.returnJson(False, "开发机不可设置!")
version = request.form.get('version', '')
php_bin = '/usr/bin/php'
php_bin_src = "/www/server/php/%s/bin/php" % version
php_ize = '/usr/bin/phpize'
php_ize_src = "/www/server/php/%s/bin/phpize" % version
php_fpm = '/usr/bin/php-fpm'
php_fpm_src = "/www/server/php/%s/sbin/php-fpm" % version
php_pecl = '/usr/bin/pecl'
php_pecl_src = "/www/server/php/%s/bin/pecl" % version
php_pear = '/usr/bin/pear'
php_pear_src = "/www/server/php/%s/bin/pear" % version
if not os.path.exists(php_bin_src):
return mw.returnJson(False, '指定PHP版本未安装!')
is_chattr = mw.execShell('lsattr /usr|grep /usr/bin')[0].find('-i-')
if is_chattr != -1:
mw.execShell('chattr -i /usr/bin')
mw.execShell("rm -f " + php_bin + ' ' + php_ize + ' ' +
php_fpm + ' ' + php_pecl + ' ' + php_pear)
mw.execShell("ln -sf %s %s" % (php_bin_src, php_bin))
mw.execShell("ln -sf %s %s" % (php_ize_src, php_ize))
mw.execShell("ln -sf %s %s" % (php_fpm_src, php_fpm))
mw.execShell("ln -sf %s %s" % (php_pecl_src, php_pecl))
mw.execShell("ln -sf %s %s" % (php_pear_src, php_pear))
if is_chattr != -1:
mw.execShell('chattr +i /usr/bin')
mw.writeLog('面板设置', '设置PHP-CLI版本为: %s' % version)
return mw.returnJson(True, '设置成功!')
def setPsApi(self):
mid = request.form.get('id', '')
ps = request.form.get('ps', '')
@@ -266,7 +318,8 @@ class site_api:
return mw.returnJson(True, '站点删除成功!')
def getPhpVersionApi(self):
return self.getPhpVersion()
data = self.getPhpVersion()
return mw.getJson(data)
def setPhpVersionApi(self):
siteName = request.form.get('siteName', '')
@@ -2311,7 +2364,7 @@ location ^~ {from} {\n\
tmp['name'] = 'PHP-' + matchVer
data.append(tmp)
return mw.getJson(data)
return data
# 是否跳转到https
def isToHttps(self, siteName):
+2 -2
View File
@@ -15,8 +15,8 @@ server
#PROXY-START
#ERROR-PAGE-START
error_page 404 /404.html;
error_page 502 /502.html;
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START
+2 -2
View File
@@ -12,8 +12,8 @@ server
#SSL-END
#ERROR-PAGE-START
error_page 404 /404.html;
error_page 502 /502.html;
#error_page 404 /404.html;
#error_page 502 /502.html;
#ERROR-PAGE-END
#PHP-INFO-START
+8 -2
View File
@@ -10,6 +10,7 @@ GIT_PROJECT_DIR="${GIT_USER_DIR}/{$PROJECT}"
git config --global credential.helper store
git config --global pull.rebase false
# echo $GIT_PROJECT_DIR
if [ ! -d $GIT_PROJECT_DIR ];then
@@ -18,6 +19,7 @@ if [ ! -d $GIT_PROJECT_DIR ];then
fi
unset GIT_DIR
cd $GIT_PROJECT_DIR && git pull
# func 2
@@ -26,9 +28,13 @@ cd $GIT_PROJECT_DIR && git pull
#更新的目的地址
WEB_PATH={$WEB_ROOT}/{$USERNAME}/{$PROJECT}
mkdir -p $WEB_PATH
rsync -vauP --delete --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
if [ ! -d $WEB_PATH ];then
mkdir -p $WEB_PATH
rsync -vauP --delete --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
else
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
fi
sysName=`uname`
if [ $sysName == 'Darwin' ]; then
+2
View File
@@ -15,6 +15,8 @@ if [ ! -d $GIT_PROJECT_DIR ];then
fi
unset GIT_DIR
git config pull.rebase false
cd $GIT_PROJECT_DIR && git pull
# func 2
+24 -6
View File
@@ -101,7 +101,7 @@ def getHomeDir():
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return '/Users/' + user
else:
return 'git'
return 'www'
def getRunUser():
@@ -110,7 +110,7 @@ def getRunUser():
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
return user
else:
return 'git'
return 'www'
__SR = '''#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
@@ -135,6 +135,10 @@ def initDreplace():
file_tpl = getInitdConfTpl()
service_path = mw.getServerDir()
git_dir = mw.getServerDir() + '/git'
if not os.path.exists(git_dir):
mw.execShell('mkdir -p ' + git_dir)
initD_path = getServerDir() + '/init.d'
if not os.path.exists(initD_path):
os.mkdir(initD_path)
@@ -445,7 +449,7 @@ def submitGogsConf():
val = g + ' = ' + args[g]
conf = re.sub(rep, val, conf)
mw.writeFile(filename, conf)
reload()
restart()
return mw.returnJson(True, '设置成功')
@@ -515,7 +519,7 @@ def checkProjectListIsHasScript(user, data):
path = getRootPath() + '/' + user
for x in range(len(data)):
name = data[x]['name'] + '.git'
path_tmp = path + '/' + name + '/custom_hooks/post-receive'
path_tmp = path + '/' + name + '/hooks/post-receive.d/post-receive'
if os.path.exists(path_tmp):
data[x]['has_hook'] = True
else:
@@ -593,15 +597,17 @@ def projectScriptLoad():
path = getRootPath() + '/' + user + '/' + name
post_receive_tpl = getPluginDir() + '/hook/post-receive.tpl'
post_receive = path + '/custom_hooks/post-receive'
post_receive = path + '/hooks/post-receive.d/post-receive'
if not os.path.exists(path + '/custom_hooks'):
mw.execShell('mkdir -p ' + path + '/custom_hooks')
mw.execShell('chown -R www:www ' + path + '/custom_hooks')
pct_content = mw.readFile(post_receive_tpl)
pct_content = pct_content.replace('{$PATH}', path + '/custom_hooks')
mw.writeFile(post_receive, pct_content)
mw.execShell('chmod 777 ' + post_receive)
mw.execShell('chown -R www:www ' + post_receive)
commit_tpl = getPluginDir() + '/hook/commit.tpl'
commit = path + '/custom_hooks/commit'
@@ -618,6 +624,7 @@ def projectScriptLoad():
cc_content = cc_content.replace('{$WEB_ROOT}', mw.getWwwDir())
mw.writeFile(commit, cc_content)
mw.execShell('chmod 777 ' + commit)
mw.execShell('chown -R www:www ' + commit)
return 'ok'
@@ -632,7 +639,7 @@ def projectScriptUnload():
name = args['name'] + '.git'
post_receive = getRootPath() + '/' + user + '/' + name + \
'/custom_hooks/post-receive'
'/hooks/post-receive.d/post-receive'
mw.execShell('rm -f ' + post_receive)
commit = getRootPath() + '/' + user + '/' + name + \
@@ -697,6 +704,15 @@ def getTotalStatistics():
return mw.returnJson(False, 'fail', data)
def uninstallPreInspection():
repo_dir = getServerDir() + "/data/gitea-repositories"
if not os.path.exists(repo_dir):
return 'ok'
dir_list = os.listdir(repo_dir)
if len(dir_list) > 0:
return "有项目数据!请手动删除Gitea<br/> rm -rf {}".format(getServerDir())
return 'ok'
if __name__ == "__main__":
func = sys.argv[1]
if func == 'status':
@@ -715,6 +731,8 @@ if __name__ == "__main__":
print(initdInstall())
elif func == 'initd_uninstall':
print(initdUinstall())
elif func == 'uninstall_pre_inspection':
print(uninstallPreInspection())
elif func == 'run_log':
print(runLog())
elif func == 'post_receive_log':
+2
View File
@@ -4,6 +4,8 @@
"title": "Gitea",
"versions": ["1.17.2"],
"tip": "soft",
"install_pre_inspection":false,
"uninstall_pre_inspection":true,
"checks": "server/gitea",
"path":"server/gitea",
"author": "gitea",
+3 -3
View File
@@ -6,12 +6,12 @@ After=network.target
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
User=www
Group=www
WorkingDirectory={$SERVER_PATH}/gitea
ExecStart={$SERVER_PATH}/gitea/gitea web
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
Environment=USER=www HOME=/home/www GITEA_WORK_DIR={$SERVER_PATH}/gitea
RemainAfterExit=yes
#AmbientCapabilities=CAP_NET_BIND_SERVICE
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+37 -20
View File
@@ -16,42 +16,59 @@ fi
URL_DOWNLOAD=https://dl.gitea.io/
getOs(){
os=`uname`
if [ "Darwin" == "$os" ];then
echo 'darwin'
else
echo 'linux'
fi
return 0
}
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
getBit(){
echo `getconf LONG_BIT`
}
Install_Rsync(){
if [ "$OSNAME" == "debian" ] || [ "$OSNAME" == "ubuntu" ];then
apt install -y rsync
elif [[ "$OSNAME" == "arch" ]]; then
echo y | pacman -Sy rsync
elif [[ "$OSNAME" == "macos" ]]; then
# brew install rsync
# brew install lsyncd
echo "ok"
else
yum install -y rsync
fi
}
Install_App()
{
{
Install_Rsync
mkdir -p $serverPath/source/gitea
if id git &> /dev/null ;then
echo "git UID is `id -u git`"
echo "git Shell is `grep "^git:" /etc/passwd |cut -d':' -f7 `"
if id www &> /dev/null ;then
echo "www uid is `id -u www`"
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
else
groupadd git
useradd -g git git
groupadd www
useradd -g www www
fi
if [ "macos" != "$OSNAME" ];then
if [ ! -d /home/www ];then
mkdir -p /home/www
chown -R www:www /home/www
fi
fi
echo '正在安装脚本文件...' > $install_tmp
version=$1
os=`getOs`
git config --global push.default simple
if [ "darwin" == "$os" ];then
if [ "macos" == "$OSNAME" ];then
file=gitea-${version}-darwin-10.12-amd64
else
file=gitea-${version}-linux-amd64
@@ -60,7 +77,7 @@ Install_App()
file_xz="${file}.xz"
echo "wget -O $serverPath/source/gitea/$file_xz ${URL_DOWNLOAD}/gitea/${version}/${file_xz}"
if [ ! -f $serverPath/source/gitea/$file_xz ];then
wget -O $serverPath/source/gitea/$file_xz ${URL_DOWNLOAD}/gitea/${version}/${file_xz}
wget --no-check-certificate -O $serverPath/source/gitea/$file_xz ${URL_DOWNLOAD}/gitea/${version}/${file_xz}
fi
cd $serverPath/source/gitea && xz -k -d $file_xz
@@ -69,7 +86,7 @@ Install_App()
mv $serverPath/source/gitea/$file $serverPath/gitea/gitea
chmod +x $serverPath/gitea/gitea
chown -R git:git $serverPath/gitea
chown -R www:www $serverPath/gitea
fi
+65 -49
View File
@@ -1,19 +1,9 @@
function str2Obj(str){
var data = {};
kv = str.split('&');
for(i in kv){
v = kv[i].split('=');
data[v[0]] = v[1];
}
return data;
}
function gogsPost(method,args,callback, title){
var _args = null;
if (typeof(args) == 'string'){
_args = JSON.stringify(str2Obj(args));
_args = JSON.stringify(toArrayObject(args));
} else {
_args = JSON.stringify(args);
}
@@ -186,6 +176,28 @@ function giteaUserList(page, search) {
}
function userProjectList(user, search){
var loadOpen = layer.open({
type: 1,
title: '用户('+user+')项目列表',
area: '500px',
content:"<div class='bt-form pd20 c6'>\
<div>\
<div id='gitea_table' class='divtable' style='margin-top:5px;'>\
<table class='table table-hover'>\
<thead><tr><th>项目</th><th>操作</th></tr></thead>\
<tbody></tbody>\
</table>\
<div class='dataTables_paginate paging_bootstrap pagination' style='margin-top:0px;'><ul id='gitea_page' class='page'></ul></div>\
</div>\
</div>\
</div>",
success:function(){
userProjectListPost(user,search);
}
});
}
function userProjectListPost(user, search){
var req = {};
if (!isNaN(user)){
req['page'] = user;
@@ -201,8 +213,7 @@ function userProjectList(user, search){
if(typeof(search) != 'undefined'){
req['search'] = search;
}
$('.layui-layer-close1').click();
gogsPost('user_project_list', req, function(data){
var rdata = [];
try {
@@ -227,24 +238,10 @@ function userProjectList(user, search){
</tr>';
}
var page = '<div class="dataTables_paginate paging_bootstrap pagination" style="margin-top:0px;"><ul id="softPage" class="page"><div>';
page += rdata['data']['list'];
page += '</div></ul></div>';
$('#gitea_table tbody').html(list);
var loadOpen = layer.open({
type: 1,
title: '用户('+user+')项目列表',
area: '500px',
content:"<div class='bt-form pd20 c6'>\
<div>\
<div class='divtable' style='margin-top:5px;'>\
<table class='table table-hover'>\
<thead><tr><th>项目</th><th>操作</th></tr></thead>\
<tbody>" + list + "</tbody>\
</table>" +
page +
"</div></div></div>"
});
var page = rdata['data']['list'];
$('#gitea_table .gitea_page').html(page);
});
}
@@ -253,23 +250,41 @@ function projectScript(user, name,has_hook){
// console.log(user,name,has_hook);
var html = '';
if (has_hook){
html += '<button onclick="projectScriptEdit(\''+user+'\',\''+name+'\')" class="btn btn-default btn-sm">手动编辑</button>';
html += '<button onclick="projectScriptDebug(\''+user+'\',\''+name+'\')" class="btn btn-default btn-sm">调试日志</button>';
html += '<button onclick="projectScriptLoad(\''+user+'\',\''+name+'\')" class="btn btn-default btn-sm">重新加载</button>';
html += '<button onclick="projectScriptUnload(\''+user+'\',\''+name+'\')" class="btn btn-default btn-sm">卸载脚本</button>';
html += '<button class="btn btn-default btn-sm hook_edit">手动编辑</button>';
html += '<button class="btn btn-default btn-sm hook_log">调试日志</button>';
html += '<button class="btn btn-default btn-sm hook_load">重新加载</button>';
html += '<button class="btn btn-default btn-sm hook_unload">卸载脚本</button>';
} else {
html += '<button onclick="projectScriptLoad(\''+user+'\',\''+name+'\')" class="btn btn-default btn-sm">加载脚本</button>';
html += '<button class="btn btn-default btn-sm hook_load">加载脚本</button>';
}
var loadOpen = layer.open({
type: 1,
title: '['+user+']['+name+']脚本设置',
area: '240px',
content:'<div class="change-default pd20">'+html+'</div>'
content:'<div class="change-default pd20">'+html+'</div>',
success:function(layero,index) {
$('.hook_edit').click(function(){
projectScriptEdit(user,name,index);
});
$('.hook_log').click(function(){
projectScriptDebug(user,name,index);
});
$('.hook_load').click(function(){
projectScriptLoad(user,name,index);
});
$('.hook_unload').click(function(){
projectScriptUnload(user,name,index);
});
}
});
}
function projectScriptEdit(user,name){
function projectScriptEdit(user,name,index){
gogsPost('project_script_edit', {'user':user,'name':name}, function(data){
var rdata = $.parseJSON(data.data);
if (rdata['status']){
@@ -280,41 +295,42 @@ function projectScriptEdit(user,name){
});
}
function projectScriptLoad(user,name){
function projectScriptLoad(user,name,index){
gogsPost('project_script_load', {'user':user,'name':name}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
layer.msg('加载成功!',{icon:1,time:2000,shade: [0.3, '#000']});
setTimeout(function(){
userProjectList(1);
}, 2000);
showMsg('加载成功!',function(){
layer.close(index);
userProjectListPost(1);
},{icon:1,time:2000,shade: [0.3, '#000']},2000);
});
}
function projectScriptUnload(user,name){
function projectScriptUnload(user,name,index){
gogsPost('project_script_unload', {'user':user,'name':name}, function(data){
if (data.data != 'ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
return;
}
layer.msg('卸载成功!',{icon:1,time:2000,shade: [0.3, '#000']});
setTimeout(function(){
userProjectList(1);
}, 2000);
showMsg('卸载成功!',function(){
layer.close(index);
userProjectListPost(1);
},{icon:1,time:2000,shade: [0.3, '#000']},2000);
});
}
function projectScriptDebug(user,name){
function projectScriptDebug(user,name,index){
gogsPost('project_script_debug', {'user':user,'name':name}, function(data){
var rdata = $.parseJSON(data.data);
if (rdata['status']){
onlineEditFile(0, rdata['path']);
} else {
layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']});
showMsg(rdata.msg,function(){
},{icon:1,time:2000,shade: [0.3, '#000']},2000);
}
});
}
+1 -1
View File
@@ -53,7 +53,7 @@ Install_gogs()
fi
if [ ! -f $serverPath/source/gogs/$file ];then
wget -O $serverPath/source/gogs/$file ${GOGS_DOWNLOAD}/${version}/${file}
wget --no-check-certificate -O $serverPath/source/gogs/$file ${GOGS_DOWNLOAD}/${version}/${file}
fi
cd $serverPath/source/gogs && unzip -o $file -d gogs_${version}
+1 -1
View File
@@ -29,7 +29,7 @@ Install_App()
if [ ! -f ${APP_DIR}/haproxy-${VERSION}.tar.gz ];then
if [ $sysName == 'Darwin' ]; then
wget -O ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
wget --no-check-certificate -O ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
else
curl -sSLo ${APP_DIR}/haproxy-${VERSION}.tar.gz https://www.haproxy.org/download/${MIN_VERSION}/src/haproxy-${VERSION}.tar.gz
fi
+2 -2
View File
@@ -4,8 +4,8 @@
"name": "imail",
"title": "邮件服务",
"shell": "install.sh",
"versions":["0.0.17"],
"updates":["0.0.17"],
"versions":["0.0.19"],
"updates":["0.0.19"],
"tip": "soft",
"checks": "server/imail",
"path": "server/imail",
@@ -8,7 +8,7 @@ rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
install_tmp=${rootPath}/tmp/mw_install.pl
VERSION=0.0.17
VERSION=0.0.19
# bash install.sh install 0.0.16
## cd /www/server/mdserver-web/plugins/imail && bash install.sh install 0.0.16
+1 -1
View File
@@ -18,7 +18,7 @@ Install_mem(){
echo '正在安装脚本文件...' > $install_tmp
if [ ! -f $serverPath/source/memcached.tar.gz ];then
wget -O $serverPath/source/memcached.tar.gz http://www.memcached.org/files/memcached-${VERSION}.tar.gz
wget --no-check-certificate -O $serverPath/source/memcached.tar.gz http://www.memcached.org/files/memcached-${VERSION}.tar.gz
fi
cd $serverPath/source && tar -zxvf memcached.tar.gz
+1 -1
View File
@@ -29,7 +29,7 @@ lower_case_table_names=0
character-set-server = UTF8MB4
query_cache_type = 1
query_cache_size = 8M
query_cache_size = 64M
max_connections = 500
max_connect_errors = 100
+1 -1
View File
@@ -690,8 +690,8 @@ function addDatabase(type){
<span class='tname'>数据库名</span>\
<div class='info-r'><input name='name' class='bt-input-text mr5' placeholder='新的数据库名称' type='text' style='width:65%' value=''>\
<select class='bt-input-text mr5 codeing_a5nGsm' name='codeing' style='width:27%'>\
<option value='utf8'>utf-8</option>\
<option value='utf8mb4'>utf8mb4</option>\
<option value='utf8'>utf-8</option>\
<option value='gbk'>gbk</option>\
<option value='big5'>big5</option>\
</select>\
+1 -1
View File
@@ -43,7 +43,7 @@ APT_INSTALL()
mkdir -p $myDir
mkdir -p $serverPath/mysql-apt/bin
wget -O ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar https://cdn.mysql.com/archives/mysql-5.7/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
wget --no-check-certificate -O ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar https://cdn.mysql.com/archives/mysql-5.7/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
chmod +x ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
cd ${myDir} && tar vxf ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
+1 -1
View File
@@ -35,7 +35,7 @@ APT_INSTALL()
mkdir -p $myDir
mkdir -p $serverPath/mysql-apt/bin
wget -O ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar https://cdn.mysql.com/archives/mysql-8.0/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
wget --no-check-certificate -O ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar https://cdn.mysql.com/archives/mysql-8.0/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
chmod +x ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
cd ${myDir} && tar vxf ${myDir}/mysql-server_${SUFFIX_NAME}.deb-bundle.tar
+1 -1
View File
@@ -30,7 +30,7 @@ tmp_table_size = 8M
character-set-server = UTF8MB4
query_cache_type = 1
query_cache_size = 8M
query_cache_size = 64M
max_connections = 500
max_connect_errors = 100
+1 -1
View File
@@ -690,8 +690,8 @@ function addDatabase(type){
<span class='tname'>数据库名</span>\
<div class='info-r'><input name='name' class='bt-input-text mr5' placeholder='新的数据库名称' type='text' style='width:65%' value=''>\
<select class='bt-input-text mr5 codeing_a5nGsm' name='codeing' style='width:27%'>\
<option value='utf8'>utf-8</option>\
<option value='utf8mb4'>utf8mb4</option>\
<option value='utf8'>utf-8</option>\
<option value='gbk'>gbk</option>\
<option value='big5'>big5</option>\
</select>\
+1 -1
View File
@@ -52,7 +52,7 @@ YUM_INSTALL()
#######
mkdir -p $myDir
wget -O $myDir/mysql-${SUFFIX_NAME}.rpm-bundle.tar https://cdn.mysql.com/archives/mysql-5.7/mysql-${SUFFIX_NAME}.rpm-bundle.tar
wget --no-check-certificate -O $myDir/mysql-${SUFFIX_NAME}.rpm-bundle.tar https://cdn.mysql.com/archives/mysql-5.7/mysql-${SUFFIX_NAME}.rpm-bundle.tar
cd ${myDir} && tar vxf mysql-${SUFFIX_NAME}.rpm-bundle.tar
mkdir -p ${serverPath}/mysql-yum/bin && cd ${serverPath}/mysql-yum/bin
+1 -1
View File
@@ -48,7 +48,7 @@ YUM_INSTALL()
#######
mkdir -p $myDir
wget -O $myDir/mysql-${SUFFIX_NAME}.rpm-bundle.tar https://cdn.mysql.com/archives/mysql-8.0/mysql-${SUFFIX_NAME}.rpm-bundle.tar
wget --no-check-certificate -O $myDir/mysql-${SUFFIX_NAME}.rpm-bundle.tar https://cdn.mysql.com/archives/mysql-8.0/mysql-${SUFFIX_NAME}.rpm-bundle.tar
cd ${myDir} && tar vxf mysql-${SUFFIX_NAME}.rpm-bundle.tar
mkdir -p ${serverPath}/mysql-yum/bin && cd ${serverPath}/mysql-yum/bin
+1 -1
View File
@@ -33,7 +33,7 @@ tmp_table_size = 8M
query_cache_type = 1
query_cache_size = 4M
query_cache_size = 64M
max_connections = 500
max_connect_errors = 100
+1 -1
View File
@@ -35,7 +35,7 @@ lower_case_table_names=0
tmp_table_size = 8M
query_cache_type = 1
query_cache_size = 4M
query_cache_size = 64M
max_connections = 500
max_connect_errors = 100
+1 -1
View File
@@ -36,7 +36,7 @@ tmp_table_size = 8M
character-set-server = UTF8MB4
query_cache_type = 1
query_cache_size = 4M
query_cache_size = 64M
max_connections = 500
max_connect_errors = 100
+14 -9
View File
@@ -2233,7 +2233,7 @@ def initSlaveStatus(version=''):
ssh.connect(hostname=ip, port=int(master_port),
username='root', pkey=key)
cmd = 'cd /www/server/mdserver-web && python3 plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"","db":""}'
cmd = 'cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"","db":""}'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read()
result = result.decode('utf-8')
@@ -2254,11 +2254,11 @@ def initSlaveStatus(version=''):
# 保证同步IP一致
cmd = cmd_data['data']['cmd']
if cmd.find('SOURCE_HOST') > -1:
cmd = re.sub(r"SOURCE_HOST='(.*)'",
cmd = re.sub(r"SOURCE_HOST='(.*?)'",
"SOURCE_HOST='" + ip + "'", cmd, 1)
if cmd.find('MASTER_HOST') > -1:
cmd = re.sub(r"MASTER_HOST='(.*)'",
cmd = re.sub(r"MASTER_HOST='(.*?)'",
"MASTER_HOST='" + ip + "'", cmd, 1)
db.query(cmd)
db.query("start slave user='{}' password='{}';".format(
@@ -2318,11 +2318,12 @@ def dumpMysqlData(version=''):
if args['db'].lower() == 'all':
dlist = findBinlogDoDb()
cmd = mysql_dir + "/bin/mysqldump --defaults-file=" + myconf + " " + option + " -uroot -p" + \
pwd + " --databases " + \
pwd + " --force --databases " + \
' '.join(dlist) + " | gzip > /tmp/dump.sql.gz"
else:
cmd = mysql_dir + "/bin/mysqldump --defaults-file=" + myconf + " " + option + " -uroot -p" + \
pwd + " --databases " + args['db'] + " | gzip > /tmp/dump.sql.gz"
pwd + " --force --databases " + \
args['db'] + " | gzip > /tmp/dump.sql.gz"
ret = mw.execShell(cmd)
if ret[0] == '':
@@ -2392,7 +2393,7 @@ def doFullSync(version=''):
writeDbSyncStatus({'code': 0, 'msg': '登录Master成功...', 'progress': 5})
dbname = args['db']
cmd = "cd /www/server/mdserver-web && python3 plugins/mysql/index.py dump_mysql_data {\"db\":'" + dbname + "'}"
cmd = "cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py dump_mysql_data {\"db\":'" + dbname + "'}"
print(cmd)
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read()
@@ -2415,7 +2416,7 @@ def doFullSync(version=''):
if copy_status == None:
writeDbSyncStatus({'code': 2, 'msg': '数据同步本地完成...', 'progress': 40})
cmd = 'cd /www/server/mdserver-web && python3 plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"' + db_user + '","db":""}'
cmd = 'cd /www/server/mdserver-web && source bin/activate && python3 plugins/mysql/index.py get_master_rep_slave_user_cmd {"username":"' + db_user + '","db":""}'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read()
result = result.decode('utf-8')
@@ -2427,10 +2428,12 @@ def doFullSync(version=''):
cmd = cmd_data['data']['cmd']
# 保证同步IP一致
if cmd.find('SOURCE_HOST') > -1:
cmd = re.sub(r"SOURCE_HOST='(.*)'", "SOURCE_HOST='" + ip + "'", cmd, 1)
cmd = re.sub(r"SOURCE_HOST='(.*?)'",
"SOURCE_HOST='" + ip + "'", cmd, 1)
if cmd.find('MASTER_HOST') > -1:
cmd = re.sub(r"MASTER_HOST='(.*)'", "SOURCE_HOST='" + ip + "'", cmd, 1)
cmd = re.sub(r"MASTER_HOST='(.*?)'",
"MASTER_HOST='" + ip + "'", cmd, 1)
db.query(cmd)
uinfo = cmd_data['data']['info']
@@ -2444,6 +2447,8 @@ def doFullSync(version=''):
mw.execShell("cd /tmp && gzip -d dump.sql.gz")
cmd = root_dir + "/bin/mysql -S " + msock + \
" -uroot -p" + pwd + " < /tmp/dump.sql"
print(cmd)
import_data = mw.execShell(cmd)
if import_data[0] == '':
print(import_data[1])
+1 -1
View File
@@ -690,8 +690,8 @@ function addDatabase(type){
<span class='tname'>数据库名</span>\
<div class='info-r'><input name='name' class='bt-input-text mr5' placeholder='新的数据库名称' type='text' style='width:65%' value=''>\
<select class='bt-input-text mr5 codeing_a5nGsm' name='codeing' style='width:27%'>\
<option value='utf8'>utf-8</option>\
<option value='utf8mb4'>utf8mb4</option>\
<option value='utf8'>utf-8</option>\
<option value='gbk'>gbk</option>\
<option value='big5'>big5</option>\
</select>\
+1 -1
View File
@@ -17,7 +17,7 @@ which rpcgen
if [ "$?" != "0" ];then
if [ ! -f ${SOURCE_ROOT}/rpcsvc-proto-1.4.tar.gz ];then
wget -O ${SOURCE_ROOT}/rpcsvc-proto-1.4.tar.gz https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz
wget --no-check-certificate -O ${SOURCE_ROOT}/rpcsvc-proto-1.4.tar.gz https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz
fi
if [ ! -d ${SERVER_ROOT}/rpcsvc-proto-1.4 ];then
+1 -1
View File
@@ -59,7 +59,7 @@ Install_mysql()
# ----- cpu end ------
if [ ! -f ${mysqlDir}/mysql-5.5.62.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.5.62.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-5.5.62.tar.gz --tries=3 https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.5.62 ];then
+1 -1
View File
@@ -63,7 +63,7 @@ Install_mysql()
if [ ! -f ${mysqlDir}/mysql-5.6.50.tar.gz ];then
wget -O ${mysqlDir}/mysql-5.6.50.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-5.6.50.tar.gz --tries=3 https://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.50.tar.gz
fi
if [ ! -d ${mysqlDir}/mysql-5.6.50 ];then
+2 -2
View File
@@ -66,7 +66,7 @@ Install_mysql()
cd ${rootPath}/plugins/mysql/lib && /bin/bash rpcgen.sh
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
fi
#检测文件是否损坏.
@@ -78,7 +78,7 @@ Install_mysql()
else
# 重新下载
rm -rf ${mysqlDir}/mysql-${VERSION}
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${VERSION}.tar.gz
fi
fi
+3 -3
View File
@@ -109,7 +109,7 @@ Install_mysql()
fi
if [ ! -f ${mysqlDir}/mysql-boost-${VERSION}.tar.gz ];then
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${VERSION}.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${VERSION}.tar.gz
fi
#检测文件是否损坏.
@@ -121,7 +121,7 @@ Install_mysql()
else
# 重新下载
rm -rf ${mysqlDir}/mysql-${VERSION}
wget -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${VERSION}.tar.gz
wget --no-check-certificate -O ${mysqlDir}/mysql-boost-${VERSION}.tar.gz --tries=3 https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${VERSION}.tar.gz
fi
fi
@@ -163,7 +163,7 @@ Install_mysql()
LIBTIRPC_VER=`pkg-config libtirpc --modversion`
if [ ! -f ${mysqlDir}/libtirpc_1.2.5.orig.tar.bz2 ];then
wget -O ${mysqlDir}/libtirpc_1.2.5.orig.tar.bz2 https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libtirpc/1.2.5-1ubuntu0.1/libtirpc_1.2.5.orig.tar.bz2
wget --no-check-certificate -O ${mysqlDir}/libtirpc_1.2.5.orig.tar.bz2 https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/libtirpc/1.2.5-1ubuntu0.1/libtirpc_1.2.5.orig.tar.bz2
cd ${mysqlDir} && tar -jxvf libtirpc_1.2.5.orig.tar.bz2
cd libtirpc-1.2.5 && ./configure
fi
+1 -1
View File
@@ -842,7 +842,7 @@ def setSafeVerify():
cobj = json.loads(content)
cobj['safe_verify']['time'] = args['time']
cobj['safe_verify']['cpu'] = args['cpu']
cobj['safe_verify']['cpu'] = int(args['cpu'])
if args['auto'] == '0':
cobj['safe_verify']['auto'] = False
+1 -1
View File
@@ -300,7 +300,7 @@ def runInfo():
# 取Openresty负载状态
try:
url = 'http://127.0.0.1/nginx_status'
result = mw.httpGet(url)
result = mw.httpGet(url, timeout=1)
tmp = result.split()
data = {}
data['active'] = tmp[2]
+5
View File
@@ -57,12 +57,17 @@ if [ "${action}" == "install" ] && [ -d ${serverPath}/php/${type} ];then
# 安装通用扩展
echo "install PHP${type} extend start"
# cd /www/server/mdserver-web/plugins/php/versions/common && bash iconv.sh install 53
# cd /www/server/mdserver-web/plugins/php/versions/common && bash gd.sh install 56
# cd /www/server/mdserver-web/plugins/php/versions/common && bash openssl.sh install 56
cd ${rootPath}/plugins/php/versions/common && bash gd.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash iconv.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash exif.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash intl.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash mcrypt.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash openssl.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash bcmath.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash gettext.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash redis.sh install ${type}
cd ${rootPath}/plugins/php/versions/common && bash memcached.sh install ${type}
+1
View File
@@ -56,6 +56,7 @@ fi
ZIP_OPTION='--enable-zip'
libzip_version=`pkg-config libzip --modversion`
if version_lt "$libzip_version" "0.11.0" ;then
cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh
export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig
ZIP_OPTION="--with-libzip=$serverPath/lib/libzip"
fi
+1
View File
@@ -72,6 +72,7 @@ echo "$sourcePath/php/php${PHP_VER}"
ZIP_OPTION='--with-zip'
libzip_version=`pkg-config libzip --modversion`
if version_lt "$libzip_version" "0.11.0" ;then
cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh
export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig
ZIP_OPTION="--with-zip=$serverPath/lib/libzip"
fi
+1 -1
View File
@@ -16,7 +16,7 @@ function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)"
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
version=8.2.0RC6
version=8.2.0RC7
PHP_VER=82
Install_php()
{
+10 -3
View File
@@ -18,9 +18,16 @@ LIBNAME=gd
LIBV=0
if [ "$version" -lt "74" ];then
bash $curPath/gd_old.sh $1 $2
exit 0
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
OSNAME_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
if [ "centos" == "$OSNAME" ] || [ "OSNAME_ID" != "9" ];then
if [ "$version" -lt "74" ];then
bash $curPath/gd_old.sh $1 $2
exit 0
fi
fi
+5 -4
View File
@@ -52,10 +52,11 @@ Install_lib()
$serverPath/php/$version/bin/phpize
./configure --with-php-config=$serverPath/php/$version/bin/php-config
FIND_C99=`cat Makefile|grep c99`
if [ "$FIND_C99" == "" ];then
sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile
fi
# PHP52需要,因为52关闭。所有注释掉
# FIND_C99=`cat Makefile|grep c99`
# if [ "$FIND_C99" == "" ];then
# sed -i $BAK 's/CFLAGS \=/CFLAGS \= -std=c99/g' Makefile
# fi
make clean && make && make install && make clean
+6 -1
View File
@@ -19,12 +19,17 @@ sysName=`uname`
actionType=$1
version=$2
IC_VERSION=${version:0:1}.${version:1:2}
ARCH=`uname -m`
if [ "$version" -gt "74" ];then
echo "not need"
exit 1
fi
DEFAULT_ARCH='x86-64'
if [ "$ARCH" == "aarch64" ];then
DEFAULT_ARCH='aarch64'
fi
LIB_PATH_NAME=lib/php
if [ -d $serverPath/php/${version}/lib64 ];then
@@ -55,7 +60,7 @@ Install_lib()
php_lib=$sourcePath/php_lib
mkdir -p $php_lib
if [ ! -f $php_lib/ioncube_loaders_lin.tar.gz ];then
wget -O $php_lib/ioncube_loaders_lin.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
wget -O $php_lib/ioncube_loaders_lin.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_${DEFAULT_ARCH}.tar.gz
cd $php_lib && tar -zxvf ioncube_loaders_lin.tar.gz
fi
cd $php_lib/ioncube
+4 -3
View File
@@ -42,7 +42,7 @@ Install_lib()
fi
# cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh
if [ "$version" -lt "70" ];then
if [ "$version" -lt "81" ];then
cd ${rootPath}/plugins/php/lib && /bin/bash openssl_10.sh
fi
@@ -63,8 +63,9 @@ Install_lib()
mv config0.m4 config.m4
fi
openssl_version=`pkg-config openssl --modversion`
if [ "$version" -lt "70" ];then
# openssl_version=`pkg-config openssl --modversion`
# export PKG_CONFIG_PATH=$serverPath/lib/openssl10/lib/pkgconfig
if [ "$version" -lt "81" ];then
export PKG_CONFIG_PATH=$serverPath/lib/openssl10/lib/pkgconfig
fi
+5
View File
@@ -21,6 +21,11 @@ if [ "$version" -lt "70" ];then
LIBV=1.2.5
fi
if [ "$version" -eq "82" ];then
echo "wait php82 release"
exit 0
fi
LIB_PATH_NAME=lib/php
if [ -d $serverPath/php/${version}/lib64 ];then
+2 -2
View File
@@ -1,9 +1,9 @@
daemonize yes
pidfile {$SERVER_PATH}/redis/redis_6379.pid
bind 0.0.0.0
bind 127.0.0.1
port 6379
requirepass admin
requirepass {$REDIS_PASS}
timeout 0
tcp-keepalive 0
+7 -5
View File
@@ -101,6 +101,9 @@ def initDreplace():
if not os.path.exists(dst_conf_init):
conf_content = mw.readFile(getConfTpl())
conf_content = conf_content.replace('{$SERVER_PATH}', service_path)
conf_content = conf_content.replace(
'{$REDIS_PASS}', mw.getRandomString(10))
mw.writeFile(dst_conf, conf_content)
mw.writeFile(dst_conf_init, 'ok')
@@ -167,11 +170,10 @@ def runInfo():
if tmp:
requirepass = tmp.groups()[1]
default_ip = '0.0.0.0'
findDebian = mw.execShell('cat /etc/issue |grep Debian')
if findDebian[0] != '':
default_ip = mw.getLocalIp()
default_ip = '127.0.0.1'
# findDebian = mw.execShell('cat /etc/issue |grep Debian')
# if findDebian[0] != '':
# default_ip = mw.getLocalIp()
cmd = getServerDir() + "/bin/redis-cli -h " + default_ip + " info"
if requirepass != "":
cmd = getServerDir() + '/bin/redis-cli -h ' + default_ip + \
+18 -12
View File
@@ -381,9 +381,9 @@ def addRec():
args_ps = args['ps']
if not mw.isAppleSystem():
mw.execShell("mkdir -p " + args_path)
mw.execShell("chown -R www:www " + args_path)
mw.execShell("chmdo -R 755 " + args_path)
os.system("mkdir -p " + args_path + " &")
os.system("chown -R www:www " + args_path + " &")
os.system("chmod -R 755 " + args_path + " &")
delRecBy(args_name)
@@ -710,8 +710,7 @@ def lsyncdAdd():
import base64
args = getArgs()
data = checkArgs(args, ['ip', 'conn_type', 'path',
'secret_key', 'delay', 'period'])
data = checkArgs(args, ['ip', 'conn_type', 'path', 'delay', 'period'])
if not data[0]:
return data[1]
@@ -719,12 +718,12 @@ def lsyncdAdd():
path = args['path']
if not mw.isAppleSystem():
mw.execShell("mkdir -p " + path)
mw.execShell("chown -R www:www " + path)
mw.execShell("chmod -R 755 " + path)
os.system("mkdir -p " + path + " &")
os.system("chown -R www:www " + path + " &")
os.system("chmod -R 755 " + path + " &")
conn_type = args['conn_type']
secret_key = args['secret_key']
delete = args['delete']
realtime = args['realtime']
delay = args['delay']
@@ -750,6 +749,12 @@ def lsyncdAdd():
}
if conn_type == "key":
secret_key_check = checkArgs(args, ['secret_key'])
if not secret_key_check[0]:
return secret_key_check[1]
secret_key = args['secret_key']
try:
m = base64.b64decode(secret_key)
m = json.loads(m)
@@ -759,12 +764,13 @@ def lsyncdAdd():
except Exception as e:
return mw.returnJson(False, "接收密钥格式错误!")
else:
data = checkArgs(args, ['uname'])
data = checkArgs(args, ['sname', 'password'])
if not data[0]:
return data[1]
info['name'] = args['uname']
info['password'] = args['uname']
info['name'] = args['sname']
info['password'] = args['password']
info['port'] = args['port']
rsync = {
'bwlimit': bwlimit,
+1 -1
View File
@@ -324,7 +324,7 @@ def startJob():
data = mw.execShell(cmd)
if data[0] != '':
if data[1] != '':
return mw.returnJson(False, action + '[' + name + ']失败!')
return mw.returnJson(True, action + '[' + name + ']成功!')
+4 -1
View File
@@ -32,4 +32,7 @@ net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1024 65000
vm.overcommit_memory=1
vm.overcommit_memory=1
net.ipv4.ip_conntrack_max = 81920
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1500
+1 -1
View File
@@ -207,7 +207,7 @@
</div>
</div>
<script type="text/javascript">
resetPluginWinWidth(900);
resetPluginWinWidth(950);
$.getScript( "/static/js/echarts.min.js", function(){
console.log("echarts load done");
});
+20 -4
View File
@@ -96,10 +96,27 @@ def loadConfigFile():
content = json.loads(content)
dst_conf_json = getServerDir() + "/lua/config.json"
mw.writeFile(dst_conf_json, json.dumps(content))
if not os.path.exists(dst_conf_json):
mw.writeFile(dst_conf_json, json.dumps(content))
dst_conf_lua = getServerDir() + "/lua/webstats_config.lua"
listToLuaFile(dst_conf_lua, content)
if not os.path.exists(dst_conf_lua):
listToLuaFile(dst_conf_lua, content)
# def loadConfigFileReload():
# -- 配置生活或可使用
# lua_dir = getServerDir() + "/lua"
# conf_tpl = getPluginDir() + "/conf/config.json"
# content = mw.readFile(conf_tpl)
# content = json.loads(content)
# dst_conf_json = getServerDir() + "/lua/config.json"
# mw.writeFile(dst_conf_json, json.dumps(content))
# dst_conf_lua = getServerDir() + "/lua/webstats_config.lua"
# listToLuaFile(dst_conf_lua, content)
def loadLuaSiteFile():
@@ -261,10 +278,9 @@ def restart():
def reload():
initDreplace()
loadDebugLogFile()
mw.opWeb("reload")
mw.opWeb("restart")
return 'ok'
+42 -4
View File
@@ -2232,7 +2232,12 @@ function wsTableLogRequest(page){
list += '<td>' + toSecond(data[i]['request_time']) +'</td>';
list += '<td><span class="overflow_hide" style="width:130px;">' + data[i]['uri'] +'</span></td>';
list += '<td>'+spider_tip+'<span class="overflow_hide" style="width:60px;">' + data[i]['status_code']+'/' + data[i]['method'] +'</span></td>';
list += '<td><a data-id="'+i+'" href="javascript:;" class="btlink details" title="详情">详情</a></td>';
var http_data = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
if (data[i]['request_headers']!=''){
http_data = '<a data-id="'+i+'" href="javascript:;" class="btlink http_data" title="HTTP">HTTP</a>&nbsp;|&nbsp;';
}
list += '<td><span>'+http_data+'<a data-id="'+i+'" href="javascript:;" class="btlink details" title="详情">详情</a></span></td>';
list += '</tr>';
}
} else{
@@ -2277,19 +2282,52 @@ function wsTableLogRequest(page){
<div><b style="margin-left:10px">协议</b></div>\
<div class="lib-con mt10"><div class="divpre">' + res.protocol + '</div></div>\
<div><b style="margin-left:10px">URL</b></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div ></div>').text(res.uri).html() + '</div></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div></div>').text(res.uri).html() + '</div></div>\
<div><b style="margin-left:10px">完整IP列表</b></div>\
<div class="lib-con mt10"><div class="divpre" style="max-height: 66px;">' + $('<div ></div>').text(res.ip_list).html() + '</div></div>\
<div><b style="margin-left:10px">来路</b></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div ></div>').text(res.referer == null ?'None':res.referer).html() + '</div></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div></div>').text(res.referer == null ?'None':res.referer).html() + '</div></div>\
<div><b style="margin-left:10px">User-Agent</b></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div ></div>').text(res.user_agent).html() + '</div></div>\
<div class="lib-con mt10"><div class="divpre">' + $('<div></div>').text(res.user_agent).html() + '</div></div>\
<div><b style="margin-left:10px">处理耗时</b></div>\
<div class="lib-con mt10"><div class="divpre">' +res.request_time + ' ms</div></div>\
</div>',
});
});
$(".tablescroll .http_data").click(function(){
var index = $(this).attr('data-id');
var res = data[index];
var request_headers = res.request_headers;
var req_data = $.parseJSON(request_headers);
var req_data_html = res.method +' ' + res.uri + '<br/>';
for (var d in req_data) {
if (d == 'payload'){
req_data_html += '<b style="color:red;">'+d +"</b>:"+req_data[d]+"<br/>";
} else{
req_data_html += d+":"+req_data[d]+"<br/>";
}
}
layer.open({
type: 1,
title: "【"+res.domain + "】HTTP详情",
area: ['600px','375px'],
closeBtn: 1,
shadeClose: false,
content: '<div class="pd15 lib-box">\
<div class="lib-con mt10"><div class="divpre" style="max-height:250px;white-space: break-spaces;">' + req_data_html + '</div></div>\
<ul class="help-info-text c7 mtb15">\
<li style="list-style: none;">payload: POST请求中客户端提交的参数。</li>\
</ul>\
</div>',
});
});
$('[data-toggle="tooltip"]').tooltip();
});
}
+9 -4
View File
@@ -76,6 +76,10 @@ function _M.getTotalKey(self)
return self.total_key
end
function _M.to_json(self, msg)
return json.encode(msg)
end
function _M.setConfData( self, config, site_config )
self.config = config
self.site_config = site_config
@@ -102,9 +106,8 @@ end
function _M.get_domain(self)
local domain = ngx.req.get_headers()['host']
if domain ~= nil then
domain = ngx.re.gsub(domain, "_", ".")
else
-- domain = ngx.re.gsub(domain, "_", ".")
if domain == nil then
domain = "unknown"
end
return domain
@@ -197,9 +200,11 @@ end
function _M.get_http_origin(self)
local data = ""
local headers = request_header
local headers = ngx.req.get_headers()
if not headers then return data end
if method ~='GET' then
-- API disabled in the context of log_by_lua*
-- ngx.req.read_body()
data = ngx.req.get_body_data()
if not data then
data = ngx.req.get_post_args(1000000)
+7 -8
View File
@@ -43,7 +43,9 @@ log_by_lua_block {
local config = require "webstats_config"
local sites = require "webstats_sites"
local server_name = string.gsub(C:get_sn(ngx.var.server_name),'_','.')
-- string.gsub(C:get_sn(ngx.var.server_name),'_','.')
local server_name = ngx.var.server_name
C:setConfData(config, sites)
@@ -373,12 +375,13 @@ log_by_lua_block {
local client_stat_fields = {}
if not excluded then
if status_code == 500 or (method=="POST" and config["record_post_args"] == true) or (status_code==403 and config["record_get_403_args"] == true) then
if status_code == 500 or (method=="POST" and config['global']["record_post_args"] == true) or (status_code==403 and config['global']["record_get_403_args"] == true) then
local data = ""
local ok, err = pcall(function() data = C:get_http_origin() end)
if ok and not err then
kv["request_headers"] = data
else
C:D("debug request_headers error:"..tostring(err))
end
end
@@ -645,11 +648,7 @@ log_by_lua_block {
local function run_app_ok()
if not debug_mode then return run_app() end
local presult, err = pcall(
function()
run_app()
end
)
local presult, err = pcall( function() run_app() end)
if not presult then
C:D("debug error on :"..tostring(err))
return true
+5
View File
@@ -0,0 +1,5 @@
location ~/group([0-9])/M00 {
# Need to cooperate with it
# https://github.com/mw-plugin/fastdfs
ngx_fastdfs_module;
}
+3 -3
View File
@@ -1,4 +1,4 @@
location / {
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
}
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
}
+54 -6
View File
@@ -133,8 +133,6 @@ def funConvert(fun):
func += suf
return func
# Flask请求勾子
def sendAuthenticated():
# 发送http认证信息
@@ -148,6 +146,7 @@ def sendAuthenticated():
@app.before_request
def requestCheck():
# Flask请求勾子
if app.config['BASIC_AUTH_OPEN']:
auth = request.authorization
if request.path in ['/download', '/hook', '/down']:
@@ -160,6 +159,10 @@ def requestCheck():
or mw.md5(auth.password.strip() + salt) != app.config['BASIC_AUTH_PASSWORD']:
return sendAuthenticated()
domain_check = mw.checkDomainPanel()
if domain_check:
return domain_check
def isLogined():
# print('isLogined', session)
@@ -407,6 +410,51 @@ def login_temp_user(token):
return redirect('/')
@app.route('/api/<reqClass>/<reqAction>', methods=['POST', 'GET'])
def api(reqClass=None, reqAction=None, reqData=None):
comReturn = common.local()
if comReturn:
return comReturn
import config_api
isOk, data = config_api.config_api().checkPanelToken()
if not isOk:
return mw.returnJson(False, '未开启API')
request_time = request.form.get('request_time', '')
request_token = request.form.get('request_token', '')
request_ip = request.remote_addr
token_md5 = mw.md5(str(request_time) + mw.md5(data['token_crypt']))
if not (token_md5 == request_token):
return mw.returnJson(False, '密钥错误')
if not mw.inArray(data['limit_addr'], request_ip):
return mw.returnJson(False, '非法请求')
if reqClass == None:
return mw.returnJson(False, '请指定请求方法类')
if reqAction == None:
return mw.returnJson(False, '请指定请求方法')
classFile = ('config_api', 'crontab_api', 'files_api', 'firewall_api',
'plugins_api', 'system_api', 'site_api', 'task_api')
className = reqClass + '_api'
if not className in classFile:
return "external api request error"
eval_str = "__import__('" + className + "')." + className + '()'
newInstance = eval(eval_str)
try:
return publicObject(newInstance, reqAction)
except Exception as e:
return mw.getTracebackInfo()
@app.route('/<reqClass>/<reqAction>', methods=['POST', 'GET'])
@app.route('/<reqClass>/', methods=['POST', 'GET'])
@app.route('/<reqClass>', methods=['POST', 'GET'])
@@ -439,8 +487,8 @@ def index(reqClass=None, reqAction=None, reqData=None):
# 登录页
if reqClass == 'login':
dologin = request.args.get('dologin', '')
if dologin == 'True':
signout = request.args.get('signout', '')
if signout == 'True':
session.clear()
session['login'] = False
session['overdue'] = 0
@@ -462,14 +510,14 @@ def index(reqClass=None, reqAction=None, reqData=None):
return render_template(reqClass + '.html', data=data)
if not isLogined():
return 'request error!'
return 'error request!'
# API请求
classFile = ('config_api', 'crontab_api', 'files_api', 'firewall_api',
'plugins_api', 'system_api', 'site_api', 'task_api')
className = reqClass + '_api'
if not className in classFile:
return "api request error"
return "api error request"
eval_str = "__import__('" + className + "')." + className + '()'
newInstance = eval(eval_str)
+81 -2
View File
@@ -57,8 +57,8 @@ $('input[name="sites_path"]').change(function(){
$('input[name="backup_path"]').change(function(){
var backup_path = $(this).val();
$('.backup_path').removeAttr('disabled');
$('.btn_sites_path').unbind().click(function(){
$('.btn_backup_path').removeAttr('disabled');
$('.btn_backup_path').unbind().click(function(){
$.post('/config/set_backup_dir','backup_path='+backup_path, function(rdata){
showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json');
@@ -66,6 +66,16 @@ $('input[name="backup_path"]').change(function(){
});
$('input[name="bind_domain"]').change(function(){
var domain = $(this).val();
console.log(domain);
$('.btn_bind_domain').removeAttr('disabled');
$('.btn_bind_domain').unbind().click(function(){
$.post('/config/set_panel_domain','domain='+domain, function(rdata){
showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
},'json');
});
});
/** op **/
@@ -665,3 +675,72 @@ function setBasicAuth(){
}
}
function showPanelApi(){
$.post('/config/get_panel_token', '', function(rdata){
var tip = layer.open({
area: ['500px', '355px'],
title: '配置面板API',
closeBtn:1,
shift: 0,
type: 1,
content: '<div class="bt-form pd20">\
<div class="line">\
<span class="tname">接口密钥</span>\
<div class="info-r">\
<input class="bt-input-text mr5" name="token" type="text" style="width: 310px;" disabled>\
<button class="btn btn-success btn-xs reset_token" style="margin-left: -50px;">重置</button>\
</div>\
</div>\
<div class="line">\
<span class="tname" style="width: 90px; overflow: initial; height: 20px; line-height: 20px;">IP白名单<br/>(每行1个)</span>\
<div class="info-r"><textarea class="bt-input-text" name="api_limit_addr" style="width: 310px; height: 80px; line-height: 20px; padding: 5px 8px;"></textarea></div>\
</div>\
<div class="line">\
<span class="tname"></span>\
<div class="info-r"><button class="btn btn-success btn-sm save_api">保存配置</button></div>\
</div>\
<ul class="help-info-text c7">\
<li>开启API后,必需在IP白名单列表中的IP才能访问面板API接口</li>\
<li style="color: red;">请不要在生产环境开启,这可能增加服务器安全风险;</li>\
</ul>\
</div>',
success:function(layero,index){
$('input[name="token"]').val(rdata.data.token);
$('textarea[name="api_limit_addr"]').val(rdata.data.limit_addr);
$('.reset_token').click(function(){
layer.confirm('您确定要重置当前密钥吗?<br/><span style="color: red; ">重置密钥后,已关联密钥产品,将失效,请重新添加新密钥至产品。</span>',{title:'重置密钥',closeBtn:2,icon:13,cancel:function(){
}}, function() {
$.post('/config/set_panel_token', {'op_type':"1"},function(rdata){
showMsg("接口密钥已生成,重置密钥后,已关联密钥产品,将失效,请重新添加新密钥至产品。", function(){
$('input[name="token"]').val(rdata.data);
} ,{icon:1}, 2000);
},'json');
});
});
$('.save_api').click(function(){
var limit_addr = $('textarea[name="api_limit_addr"]').val();
$.post('/config/set_panel_token', {'op_type':"3",'limit_addr':limit_addr},function(rdata){
showMsg(rdata.msg, function(){
} ,{icon:rdata.status?1:2}, 2000);
},'json');
});
},
});
},'json');
}
function setPanelApi(){
var cfg_panel_api = $('#cfg_panel_api').prop("checked");
$.post('/config/set_panel_token', {'op_type':"2"},function(rdata){
showMsg(rdata.msg, function(){
if (rdata.status){
showPanelApi();
}
} ,{icon:rdata.status?1:2}, 1000);
},'json');
}
+1 -1
View File
@@ -289,7 +289,7 @@ function openFilename(obj){
var ext = getSuffixName(path);
// console.log(path,ext);
if (inArray(ext,['html','htm','php','txt','md','js','css','scss','json','c','h','pl','py','java','log'])){
if (inArray(ext,['html','htm','php','txt','md','js','css','scss','json','c','h','pl','py','java','log','conf'])){
onlineEditFile(0, path);
}
+2 -2
View File
@@ -736,9 +736,9 @@ $(function() {
})
});
$("#dologin").click(function() {
$("#signout").click(function() {
layer.confirm('您真的要退出面板吗?', {icon:3,closeBtn: 1}, function() {
window.location.href = "/login?dologin=True"
window.location.href = "/login?signout=True"
});
return false
});
+58
View File
@@ -944,6 +944,64 @@ function getDefaultSite(){
},'json');
}
function setPHPVer(){
$.post('/site/get_cli_php_version','',function(rdata){
if(typeof(rdata['status'])!='undefined'){
layer.msg(rdata.msg,{icon:rdata.status?1:2});
return;
}
var opt = '';
var selected = '';
for(var i=0;i<rdata.versions.length;i++){
selected = '';
if(rdata.select.version == rdata.versions[i].version) selected = 'selected';
if (rdata.versions[i].version.indexOf("yum")>-1){
continue;
}
if (rdata.versions[i].version.indexOf("apt")>-1){
continue;
}
opt += '<option value="' + rdata.versions[i].version + '" ' + selected + '>' + rdata.versions[i].name + '</option>';
}
var phpver_layer = layer.open({
type: 1,
area: '530px',
title: '设置PHP-CLI(命令行)版本',
closeBtn: 1,
shift: 5,
shadeClose: true,
btn:["确定","取消"],
content:'<div class="bt-form ptb15">\
<p class="line">\
<span class="tname text-right">PHP-CLI版本</span>\
<select id="default_ver" class="bt-input-text" style="width: 300px;">'+opt+'</select>\
</p>\
<ul class="help-info-text c6 plr20">\
<li>此处可设置命令行运行php时使用的PHP版本</li>\
<li>安装新的PHP版本后此处需要重新设置</li>\
</ul>\
</div>',
yes:function(layero,index){
var version = $("#default_ver").val();
var loadT = layer.msg('正在处理,请稍候...',{icon:16,time:0,shade: [0.3, '#000']});
$.post('/site/set_cli_php_version','version='+version,function(rdata){
layer.close(loadT);
showMsg(rdata.msg,function(){
if (rdata.status){
layer.close(phpver_layer);
}
},{icon:rdata.status?1:5},2000);
},'json');
},
});
},'json');
}
function setIndexList(id){
var Dindex = $("#Dindex").val().replace(new RegExp(/(\n)/g), ",");
if(id == undefined ){
+1 -1
View File
@@ -6,7 +6,7 @@
</head>
<body>
<h1>开启命令</h1>
<p>{{data['cmd']}}</p>
<p>mw open</p>
<hr>
<!-- <address>Linux面板<a href="" target="_blank">请求帮助</a></address> -->
</body>
+23 -17
View File
@@ -34,15 +34,6 @@
</div>
</div>
<!--
<div class="ss-text pull-left mr50">
<em class="btlink" style="color: #20a53a;" onclick="getPanelSSL()" title="点击自定义面板证书">面板SSL</em>
<div class='ssh-item'>
<input class='btswitch btswitch-ios' id='panelSSL' type='checkbox' {{data['ssl']}}>
<label class='btswitch-btn' for='panelSSL' onclick="setPanelSSL()"></label>
</div>
</div>
-->
</div>
</div>
<div class="setbox bgw mtb15">
@@ -82,14 +73,6 @@
<span class="set-info c7">面板管理入口,设置后只能通过指定安全入口登录面板,如: /abc</span>
</p>
<!--
<p class="mtb15">
<span class="set-tit text-right">域名</span>
<input name="domain" class="inputtxt bt-input-text" type="text" value="">
<span class="set-info c7">为面板绑定一个访问域名;注意:一旦绑定域名,只能通过域名访问面板!</span>
</p>
-->
<p class="mtb15">
<span class="set-tit text-right" title="默认建站目录">默认建站目录</span>
<input name="sites_path" class="inputtxt bt-input-text" type="text" value="{{data['site_path']}}">
@@ -131,6 +114,21 @@
<div class="setting-con pd15">
<p class="mtb15">
<span class="set-tit text-right" title="绑定域名" style="float: left;">绑定域名</span>
<input name="bind_domain" class="inputtxt bt-input-text" type="text" value="{{data['bind_domain']}}">
<button type="button" class="btn btn-success btn-sm ml5 btn_bind_domain" disabled>保存</button>
<span class="set-info c7">为面板绑定一个访问域名,<b style="color: red;">注意:一旦绑定域名,只能通过域名访问面板</b></span>
</p>
<!-- <p class="mtb15">
<span class="set-tit text-right" title="面板SSL" style="float: left;">面板SSL</span>
<input id="cfg_ssl" name="bind_ssl" class="btswitch btswitch-ios" type="checkbox" {{data['ssl']}}>
<label class="btswitch-btn ml5" for="cfg_ssl" style="float: left;margin-top:4px;" onclick="getPanelSSL()"></label>
<button ype="button" class="btn btn-default btn-xs panel_api_btn" style="vertical-align: middle; margin-left: 10px" onclick="getPanelSSL();">面板SSL配置</button>
<span class="set-info c7">为面板设置https协议访问,提升面板访问<b style="color: red;">安全性</b></span>
</p> -->
<p class="mtb15">
<span class="set-tit text-right" title="BasicAuth认证" style="float: left;">BasicAuth认证</span>
<input class="btswitch btswitch-ios" id="cfg_basic_auth" type="checkbox" {{data['basic_auth']}}/>
@@ -138,6 +136,14 @@
<span class="set-info c7">为面板增加一道基于BasicAuth的认证服务,有效防止面板被扫描</span>
</p>
<p class="mtb15">
<span class="set-tit text-right" title="API接口" style="float: left;">API接口</span>
<input class="btswitch btswitch-ios" id="cfg_panel_api" type="checkbox" {{data['api_token']}}/>
<label class="btswitch-btn ml5" for="cfg_panel_api" style="float: left;margin-top:4px;" onclick="setPanelApi()"></label>
<button ype="button" class="btn btn-default btn-xs panel_api_btn" style="vertical-align: middle; margin-left: 10px" onclick="showPanelApi();">API接口配置</button>
<span class="set-info c7">提供面板API接口访问的支持</span>
</p>
<p class="mtb15">
<span class="set-tit text-right" title="临时访问授权">临时访问授权</span>
<button type="button" class="btn btn-success btn-sm ml5" onclick="setTempAccess()">临时访问授权管理</button>
+2 -2
View File
@@ -41,7 +41,7 @@
<li id="memuAcrontab"><a class="menu_day" href="/crontab">计划任务</a></li>
<li id="memuAsoft"><a class="menu_soft" href="/soft">软件管理</a><span class="softnum">1</span></li>
<li id="memuAconfig"><a class="menu_set" href="/config">面板设置</a></li>
<li><a class="menu_exit" href="javascript:;" id="dologin">退出</a></li>
<li><a class="menu_exit" href="javascript:;" id="signout">退出</a></li>
</ul>
<div id="newbtpc"></div>
<div class="btpc-plus" onclick="bindPanel(0,'b')">+</div>
@@ -91,7 +91,7 @@ function showAd(){
<table class="table table-hover">\
<thead><tr><td style="text-align: center;">商家</td><td style="text-align: center;">优惠码</td><tr></thead>\
<tbody>\
<tr><td><a target="_blank" href="https://digitalvirt.com/aff.php?aff=154"><img src="https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg"/></a></td><td>9SYDY7UH0U</td></tr>\
<tr><td><a target="_blank" href="https://digitalvirt.com/aff.php?aff=154"><img src="https://digitalvirt.com/templates/BlueWhite/img/logo-dark.svg"/></a></td><td>mdserver-web</td></tr>\
</tbody>\
</table>\
</div>'
+1
View File
@@ -23,6 +23,7 @@
<button onclick="siteDefaultPage();" class="btn btn-default btn-sm btn-title" type="button">修改默认页</button>
<button onclick="getDefaultSite();" class="btn btn-default btn-sm btn-title" type="button">默认站点</button>
<button onclick="setClassType();" class="btn btn-default btn-sm btn-title" type="button">分类管理</button>
<button onclick="setPHPVer();" class="btn btn-default btn-sm btn-title" type="button">PHP命令行版本</button>
<span>
<button batch="true" style="float: right; margin-left: 10px;display: none;" onclick="allDeleteSite();" class="btn btn-default btn-sm">删除选中</button>
</span>
+6 -3
View File
@@ -36,7 +36,7 @@ class backupTools:
"----------------------------------------------------------------------------")
return
backup_path = mw.getRootDir() + '/backup/site'
backup_path = mw.getBackupDir() + '/site'
if not os.path.exists(backup_path):
mw.execShell("mkdir -p " + backup_path)
@@ -97,7 +97,7 @@ class backupTools:
"----------------------------------------------------------------------------")
return
backup_path = mw.getRootDir() + '/backup/database'
backup_path = mw.getBackupDir() + '/database'
if not os.path.exists(backup_path):
mw.execShell("mkdir -p " + backup_path)
@@ -122,7 +122,10 @@ class backupTools:
# mw.execShell(db_path + "/bin/mysqldump --skip-lock-tables --default-character-set=utf8 " +
# name + " | gzip > " + filename)
mw.execShell(db_path + "/bin/mysqldump --single-transaction --quick --default-character-set=utf8 " +
# mw.execShell(db_path + "/bin/mysqldump --single-transaction --quick --default-character-set=utf8 " +
# name + " | gzip > " + filename)
mw.execShell(db_path + "/bin/mysqldump --force --opt --default-character-set=utf8 " +
name + " | gzip > " + filename)
if not os.path.exists(filename):
+7 -1
View File
@@ -38,4 +38,10 @@ else
OSNAME='unknow'
fi
echo "$OSNAME" > /www/server/mdserver-web/data/osname.pl
if [ -d /www/server/mdserver-web ];then
echo "$OSNAME" > /www/server/mdserver-web/data/osname.pl
fi
if [ "$OSNAME" == "macos" ];then
echo "$OSNAME"
fi
+14 -1
View File
@@ -171,6 +171,17 @@ mw_reload()
fi
}
mw_close(){
echo 'True' > $mw_path/data/close.pl
}
mw_open()
{
if [ -f $mw_path/data/close.pl ];then
rm -rf $mw_path/data/close.pl
fi
}
error_logs()
{
tail -n 100 $mw_path/logs/error.log
@@ -254,6 +265,8 @@ case "$1" in
mw_start_task;;
'status') mw_status;;
'logs') error_logs;;
'close') mw_close;;
'open') mw_open;;
'update') mw_update;;
'update_dev') mw_update_dev;;
'install_app') mw_install_app;;
@@ -292,9 +305,9 @@ case "$1" in
if [ ! -f $mw_path/data/ipv6.pl ];then
# Need to restart ipv6 to take effect
echo 'True' > $mw_path/data/ipv6.pl
mw_stop
mw_start
echo 'True' > $mw_path/data/ipv6.pl
fi
address="MW-Panel-Url: http://[$v6]:$port$auth_path"
else
+5 -2
View File
@@ -110,16 +110,18 @@ yum install -y ImageMagick ImageMagick-devel
yum install -y libzstd-devel
yum install -y libevent libevent-devel unzip zip
yum install -y python-imaging libicu-devel bzip2-devel pcre pcre-devel
# yum install -y python-imaging
yum install -y libicu-devel bzip2-devel pcre pcre-devel
yum install -y gd gd-devel
yum install -y libjpeg-devel libpng-devel libwebp libwebp-devel
yum install -y net-tools
yum install -y ncurses-devel
yum install -y libXpm-devel
for yumPack in flex file libtool libtool-libs kernel-devel patch wget glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel libcap diffutils ca-certificates net-tools psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper expat-devel readline-devel;
for yumPack in flex file libtool libtool-libs kernel-devel patch wget glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel libcap diffutils ca-certificates net-tools psmisc git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper expat-devel readline-devel;
do yum -y install $yumPack;done
@@ -136,6 +138,7 @@ if [ "$VERSION_ID" -eq "9" ];then
dnf --enablerepo=crb install -y mysql-devel
dnf --enablerepo=crb install -y libvpx-devel libXpm-devel libwebp libwebp-devel
dnf --enablerepo=crb install -y libjpeg-devel libpng-devel
dnf --enablerepo=crb install -y oniguruma oniguruma-devel
dnf --enablerepo=crb install -y libzip libzip-devel
# yum remove -y chardet
+15 -10
View File
@@ -15,7 +15,6 @@ sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
yum install -y wget lsof
yum install -y python3-devel
yum install -y python-devel
yum install -y crontabs
yum install -y expect
yum install -y curl curl-devel libcurl libcurl-devel
@@ -71,26 +70,32 @@ systemctl stop firewalld
yum groupinstall -y "Development Tools"
yum install -y epel-release
yum install -y libevent libevent-devel unzip libmcrypt libmcrypt-devel
yum install -y wget python-imaging libicu-devel zip bzip2-devel gcc libxml2 libxml2-dev libpng-devel libwebp libwebp-devel pcre pcre-devel
yum install -y lsof net-tools
yum install -y ncurses-devel mysql-devel cmake
yum install -y libevent libevent-devel zip unzip libmcrypt libmcrypt-devel
yum install -y wget libicu-devel readline-devel zip bzip2 bzip2-devel libxml2 libxml2-devel
yum install -y libpng libpng-devel libwebp libwebp-devel pcre pcre-devel gd gd-devel zlib zlib-devel gettext gettext-devel
yum install -y net-tools
yum install -y ncurses ncurses-devel mysql-devel make cmake
yum install -y sqlite-devel
# python-imaging
# yum install -y MySQL-python
for yumPack in make cmake gcc gcc-c++ flex bison file libtool libtool-libs autoconf kernel-devel patch wget libpng libpng-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel bison-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper lsof crontabs expat-devel readline-devel;
yum install -y perl perl-devel perl-Data-Dumper
for yumPack in gcc gcc-c++ flex file libtool libtool-libs autoconf kernel-devel patch glib2 glib2-devel tar e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gmp-devel libcap diffutils ca-certificates libc-client-devel psmisc libXpm-devel c-ares-devel libxslt libxslt-devel glibc.i686 libstdc++.so.6 cairo-devel libaio-devel expat-devel;
do dnf --enablerepo=powertools install -y $yumPack;done
yum install -y libtirpc libtirpc-devel
dnf install boost-locale
dnf --enablerepo=powertools install -y boost-locale
dnf --enablerepo=powertools install -y libmemcached libmemcached-devel
dnf --enablerepo=powertools install -y rpcgen
dnf --enablerepo=powertools install -y oniguruma oniguruma-devel
dnf --enablerepo=powertools install -y re2c bison
dnf --enablerepo=powertools install -y re2c bison bison-devel
dnf install -y libjpeg-turbo libjpeg-turbo-devel
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data
echo "rocky ok"
-1
View File
@@ -73,7 +73,6 @@ fi
echo "use system version: ${OSNAME}"
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
cd /www/server/mdserver-web && bash cli.sh start
isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
n=0
+11 -5
View File
@@ -33,6 +33,8 @@ elif [ "$OSNAME" == "freebsd" ];then
echo "freebsd lib"
elif [ "$OSNAME" == "centos" ];then
echo "centos lib"
elif [ "$OSNAME" == "rocky" ]; then
echo "rocky lib"
elif [ "$OSNAME" == "fedora" ];then
echo "fedora lib"
elif [ "$OSNAME" == "alma" ];then
@@ -45,14 +47,17 @@ else
echo "OK"
fi
#面板需要的库
if [ ! -f /usr/local/bin/pip3 ];then
# python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple
python3 -m pip install --upgrade pip setuptools wheel -i https://pypi.python.org/pypi
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
if [ ! -z "$cn" ];then
python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple
else
python3 -m pip install --upgrade pip setuptools wheel -i https://pypi.python.org/pypi
fi
fi
pip install --upgrade pip
which pip && pip install --upgrade pip
pip3 install --upgrade setuptools
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
@@ -69,8 +74,9 @@ fi
pip install --upgrade pip
pip3 install --upgrade setuptools
pip3 install -r /www/server/mdserver-web/requirements.txt
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
echo "lib ok!"
# pip3 install flask-caching==1.10.1
# pip3 install mysqlclient
+94
View File
@@ -0,0 +1,94 @@
<?php
/**
* MW API接口示例Demo
* 仅供参考,请根据实际项目需求开发,并做好安全处理
* date 2022-11-28
* author midoks
*/
class mwApi {
private $MW_KEY = "j7GQhzNcBV4KU9QKYPXvtjSzCcmfkc0e"; //接口密钥
private $MW_PANEL = "http://127.0.0.1:7200"; //面板地址
//如果希望多台面板,可以在实例化对象时,将面板地址与密钥传入
public function __construct($mw_panel = null, $mw_key = null) {
if ($mw_panel) {
$this->MW_PANEL = $mw_panel;
}
if ($mw_key) {
$this->MW_KEY = $mw_key;
}
}
/**
* 发起POST请求
* @param String $url 目标网填,带http://
* @param Array|String $data 欲提交的数据
* @return string
*/
private function httpPostCookie($url, $data, $timeout = 60) {
//定义cookie保存位置
$cookie_file = './' . md5($this->MW_PANEL) . '.cookie';
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
fclose($fp);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
/**
* 构造带有签名的关联数组
*/
private function getKeyData() {
$now_time = time();
$ready_data = array(
'request_token' => md5($now_time . '' . md5($this->MW_KEY)),
'request_time' => $now_time,
);
return $ready_data;
}
//示例取面板日志
public function getLogsList() {
//拼接URL地址
$url = $this->MW_PANEL . '/api/firewall/get_log_list';
//准备POST数据
$post_data = $this->getKeyData(); //取签名
$post_data['p'] = '1';
$post_data['limit'] = 10;
//请求面板接口
$result = $this->httpPostCookie($url, $post_data);
//解析JSON数据
$data = json_decode($result, true);
return $data;
}
}
//实例化对象
$api = new mwApi();
//获取面板日志
$rdata = $api->getLogsList();
// var_dump($rdata);
//输出JSON数据到浏览器
echo json_encode($rdata);
?>
+122
View File
@@ -0,0 +1,122 @@
# coding: utf-8
# +-----------------------------------------------------------------------------------
# | MW Linux面板
# +-----------------------------------------------------------------------------------
# | Copyright (c) 2015-2099 MW(http://github.com/midoks/mdserver) All rights reserved.
# +-----------------------------------------------------------------------------------
# | Author: midoks
# +-----------------------------------------------------------------------------------
#------------------------------
# API-Demo of Python
#------------------------------
import time
import hashlib
import sys
import os
import json
class mwApi:
__MW_KEY = 'j7GQhzNcBV4KU9QKYPXvtjSzCcmfkc0e'
__MW_PANEL = 'http://127.0.0.1:7200'
# 如果希望多台面板,可以在实例化对象时,将面板地址与密钥传入
def __init__(self, mw_panel=None, mw_key=None):
if mw_panel:
self.__MW_PANEL = mw_panel
self.__MW_KEY = mw_key
# 计算MD5
def __get_md5(self, s):
m = hashlib.md5()
m.update(s.encode('utf-8'))
return m.hexdigest()
# 构造带有签名的关联数组
def __get_key_data(self):
now_time = int(time.time())
ready_data = {
'request_token': self.__get_md5(str(now_time) + '' + self.__get_md5(self.__MW_KEY)),
'request_time': now_time
}
return ready_data
# 发送POST请求并保存Cookie
#@url 被请求的URL地址(必需)
#@data POST参数,可以是字符串或字典(必需)
#@timeout 超时时间默认1800秒
# return string
def __http_post_cookie(self, url, p_data, timeout=1800):
cookie_file = './' + self.__get_md5(self.__MW_PANEL) + '.cookie'
if sys.version_info[0] == 2:
# Python2
import urllib
import urllib2
import ssl
import cookielib
# 创建cookie对象
cookie_obj = cookielib.MozillaCookieJar(cookie_file)
# 加载已保存的cookie
if os.path.exists(cookie_file):
cookie_obj.load(cookie_file, ignore_discard=True,
ignore_expires=True)
ssl._create_default_https_context = ssl._create_unverified_context
data = urllib.urlencode(p_data)
req = urllib2.Request(url, data)
opener = urllib2.build_opener(
urllib2.HTTPCookieProcessor(cookie_obj))
response = opener.open(req, timeout=timeout)
# 保存cookie
cookie_obj.save(ignore_discard=True, ignore_expires=True)
return response.read()
else:
# Python3
import urllib.request
import ssl
import http.cookiejar
cookie_obj = http.cookiejar.MozillaCookieJar(cookie_file)
cookie_obj.load(cookie_file, ignore_discard=True,
ignore_expires=True)
handler = urllib.request.HTTPCookieProcessor(cookie_obj)
data = urllib.parse.urlencode(p_data).encode('utf-8')
req = urllib.request.Request(url, data)
opener = urllib.request.build_opener(handler)
response = opener.open(req, timeout=timeout)
cookie_obj.save(ignore_discard=True, ignore_expires=True)
result = response.read()
if type(result) == bytes:
result = result.decode('utf-8')
return result
# 取面板日志
def getLogs(self):
# 拼接URL地址
url = self.__MW_PANEL + '/api/firewall/get_log_list'
# 准备POST数据
post_data = self.__get_key_data() # 取签名
post_data['limit'] = 10
post_data['p'] = '1'
# 请求面板接口
result = self.__http_post_cookie(url, post_data)
# 解析JSON数据
return json.loads(result)
if __name__ == '__main__':
# 实例化宝塔API对象
api = mwApi()
# 调用get_logs方法
rdata = api.getLogs()
# 打印响应数据
print(rdata)