mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-11 06:09:25 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9b39dfe2 | ||
|
|
422514c40a | ||
|
|
632568643b | ||
|
|
a5f29a2a6a | ||
|
|
b02705aa5a | ||
|
|
1f9ab560e3 | ||
|
|
b3970326cd | ||
|
|
f6d008e0b6 | ||
|
|
6f9a49ad7a | ||
|
|
fc3c7d334a | ||
|
|
1030d1b923 | ||
|
|
94d4a90bcc | ||
|
|
da4b872666 | ||
|
|
cf15b19f4b | ||
|
|
aa9cdaada4 | ||
|
|
659c9fe16b | ||
|
|
2b8c6d6e43 | ||
|
|
263f83088f | ||
|
|
374c938ac0 | ||
|
|
6aa73b0cae | ||
|
|
7f731ae06f | ||
|
|
f87aff704c | ||
|
|
be9fa87133 | ||
|
|
de6fc19dee | ||
|
|
3987c6d3dc | ||
|
|
96875052cd | ||
|
|
583de57f96 | ||
|
|
41b7245f03 | ||
|
|
ee3684706f | ||
|
|
07936dfb81 | ||
|
|
5c46202be0 | ||
|
|
7123a15457 | ||
|
|
4aeb45b1d5 | ||
|
|
006a62be22 | ||
|
|
1e91d11125 | ||
|
|
99fb4aa723 | ||
|
|
5c5bbb2da2 | ||
|
|
8b05045901 | ||
|
|
1b73439525 | ||
|
|
ec51ad016a | ||
|
|
a42fae66ac | ||
|
|
b4c635c2e5 | ||
|
|
9802bc5915 | ||
|
|
196fbbdd7d | ||
|
|
fa278abd50 | ||
|
|
f9b2dbcb5e | ||
|
|
a8808be9ae | ||
|
|
4122de13e3 | ||
|
|
4acae8e5f5 | ||
|
|
1abb611c3e | ||
|
|
726f9fa0d2 | ||
|
|
cfb64caadc | ||
|
|
f501dd5150 | ||
|
|
d1fe006e39 | ||
|
|
d4db5dbfac | ||
|
|
efa512a3f6 | ||
|
|
b53436343d | ||
|
|
bb1a634f3c | ||
|
|
acda55cc55 | ||
|
|
0ff0728517 | ||
|
|
c575f55354 | ||
|
|
d58339dbcb | ||
|
|
f6a18fa25f | ||
|
|
3016eff372 | ||
|
|
ca518591f3 | ||
|
|
d2c74f2243 | ||
|
|
71dbf8e359 | ||
|
|
cb2ad0ca82 | ||
|
|
a157db7879 | ||
|
|
fb949f4ee6 | ||
|
|
b91ae3fde2 | ||
|
|
b508e8003b | ||
|
|
0632a4b535 | ||
|
|
397e0b89a5 | ||
|
|
2427bf81cd | ||
|
|
4179bbf580 | ||
|
|
b93c3bb88e | ||
|
|
a52c854afd | ||
|
|
d7e5cf1f45 | ||
|
|
cfb444deac | ||
|
|
78615451ac | ||
|
|
0134643c83 | ||
|
|
70ddd1c86f | ||
|
|
808dc743ef | ||
|
|
e30693f9f2 | ||
|
|
5c97fbe011 | ||
|
|
6419a18525 | ||
|
|
4a804e9243 | ||
|
|
d44526004f | ||
|
|
c1f402b278 | ||
|
|
45a3eec1b5 | ||
|
|
d6f41ceb6a | ||
|
|
a1bc0f6faf | ||
|
|
8420961cf7 | ||
|
|
421594c01d | ||
|
|
ca13e8ad77 | ||
|
|
f161f24253 | ||
|
|
e5ab03951f | ||
|
|
5b45bab36d | ||
|
|
0594d3f9ce | ||
|
|
ad541216c5 | ||
|
|
1adc0c1405 | ||
|
|
b22185b374 | ||
|
|
02f3107e93 | ||
|
|
52fece867d | ||
|
|
2e3578dcf1 | ||
|
|
73b09a7886 | ||
|
|
f33c7e5a5e | ||
|
|
3e90db2c8d | ||
|
|
d599363609 | ||
|
|
ec3167f239 | ||
|
|
2b1099b6e9 | ||
|
|
e55a0760e3 | ||
|
|
5c1353a38f | ||
|
|
f95684b316 | ||
|
|
6fc729ccf9 | ||
|
|
45d0c4fc4a | ||
|
|
6759b9055c | ||
|
|
de694b2465 | ||
|
|
c7b3daca36 | ||
|
|
452769233f | ||
|
|
8d196a3aa1 | ||
|
|
01baf509ad | ||
|
|
d59ee2c843 | ||
|
|
8919d5734e | ||
|
|
bb91b30d6d | ||
|
|
103ab2e099 | ||
|
|
0d33d0db79 | ||
|
|
6d9f4cfa08 | ||
|
|
c88c95ba21 | ||
|
|
a705f6a8e4 | ||
|
|
3f40ed0a01 | ||
|
|
39653896bf | ||
|
|
31d665d962 | ||
|
|
811fa4a40d | ||
|
|
320f58424d | ||
|
|
376f0f0a4e | ||
|
|
0efb700cee | ||
|
|
ff3fcae366 | ||
|
|
22d94ce67c | ||
|
|
042fd7ac6d | ||
|
|
1a48f52dad | ||
|
|
fc5970c65d | ||
|
|
e758698ee2 | ||
|
|
ea03bb056a | ||
|
|
088346fd5e | ||
|
|
cbcb686363 |
@@ -162,6 +162,7 @@ plugins/openlitespeed
|
||||
plugins/system_safe
|
||||
plugins/tamper_proof
|
||||
plugins/tamper_proof_*
|
||||
plugins/cryptocurrency_trade
|
||||
plugins/op_load_balance
|
||||
plugins/gdrive
|
||||
plugins/mtproxy
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
基本上可以使用,后续会继续优化!欢迎提供意见!
|
||||
|
||||
- 吹水组 - https://t.me/mdserver_web
|
||||
- 交流论坛 - https://bbs.midoks.me
|
||||
|
||||
```
|
||||
如果出现问题,最好私给我面板信息。不要让我猜。如果不提供,不要提出问题,自行解决。 — 座右铭
|
||||
@@ -73,7 +74,7 @@ phpMyAdmin[4.4.15]支持MySQL[5.5-5.7]
|
||||
phpMyAdmin[5.2.0]支持MySQL[8.0]
|
||||
|
||||
PHP[53-72]支持phpMyAdmin[4.4.15]
|
||||
PHP[72-81]支持phpMyAdmin[5.2.0]
|
||||
PHP[72-82]支持phpMyAdmin[5.2.0]
|
||||
```
|
||||
|
||||
# 特别赞助
|
||||
@@ -98,15 +99,12 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
|
||||
```
|
||||
|
||||
|
||||
### 版本更新 0.12.3
|
||||
### 版本更新 0.13.1
|
||||
|
||||
* 优先使用firewalld防火墙。
|
||||
* PHP[APT]加入curl扩展。
|
||||
* 配置添加【未认证响应状态】功能。
|
||||
* 存在ipv6时,启动时强制开启。
|
||||
* OP防火墙-性能优化。
|
||||
* 网站统计优化。
|
||||
* 优化backup_ftp插件。
|
||||
* 关闭issue,建立bbs.midoks.me。问题集中处理,发挥群众的力量。
|
||||
* 添加站操作回调钩子site_cb。 网站统计和OP防火墙不再手动重载配置
|
||||
* 修复ubuntu20 pureftp 安装时,端口没有加入安全里
|
||||
* 增加global_static hook关键字,并优化menu的文件加载hook
|
||||
* 各种细节优化。
|
||||
|
||||
### JSDelivr安装地址
|
||||
@@ -135,7 +133,7 @@ wget -O uninstall.sh https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scri
|
||||
|
||||
```
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install.sh | bash
|
||||
|
||||
curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
- 直接更新
|
||||
|
||||
@@ -1522,7 +1522,7 @@ fullchain.pem 粘贴到证书输入框
|
||||
self.__config['orders'][i]['auth_to'] = auth_to
|
||||
|
||||
# 是否到了允许重试的时间
|
||||
if 'next_retry_time' in self._config['orders'][i]:
|
||||
if 'next_retry_time' in self.__config['orders'][i]:
|
||||
timeout = self.__config['orders'][i][
|
||||
'next_retry_time'] - int(time.time())
|
||||
if timeout > 0:
|
||||
|
||||
@@ -27,7 +27,7 @@ from flask import request
|
||||
|
||||
class config_api:
|
||||
|
||||
__version = '0.12.3'
|
||||
__version = '0.13.1'
|
||||
__api_addr = 'data/api.json'
|
||||
|
||||
def __init__(self):
|
||||
@@ -693,10 +693,6 @@ class config_api:
|
||||
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)
|
||||
@@ -706,7 +702,14 @@ class config_api:
|
||||
mw.writeFile(api_file, json.dumps(data))
|
||||
return mw.returnJson(True, 'ok', token)
|
||||
|
||||
elif op_type == '2':
|
||||
api_file = self.__api_addr
|
||||
if not os.path.exists(api_file):
|
||||
return mw.returnJson(False, "先在API接口配置")
|
||||
else:
|
||||
tmp = mw.readFile(api_file)
|
||||
data = json.loads(tmp)
|
||||
|
||||
if op_type == '2':
|
||||
data['open'] = not data['open']
|
||||
stats = {True: '开启', False: '关闭'}
|
||||
if not 'token_crypt' in data:
|
||||
@@ -721,6 +724,7 @@ class config_api:
|
||||
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)
|
||||
@@ -820,7 +824,9 @@ class config_api:
|
||||
data['username'] = mw.M('users').where(
|
||||
"id=?", (1,)).getField('username')
|
||||
|
||||
# databases hook 获取
|
||||
data['hook_tag'] = request.args.get('tag', '')
|
||||
|
||||
# databases hook
|
||||
database_hook_file = 'data/hook_database.json'
|
||||
if os.path.exists(database_hook_file):
|
||||
df = mw.readFile(database_hook_file)
|
||||
@@ -829,7 +835,7 @@ class config_api:
|
||||
else:
|
||||
data['hook_database'] = []
|
||||
|
||||
# menu hook 获取
|
||||
# menu hook
|
||||
menu_hook_file = 'data/hook_menu.json'
|
||||
if os.path.exists(menu_hook_file):
|
||||
df = mw.readFile(menu_hook_file)
|
||||
@@ -838,4 +844,13 @@ class config_api:
|
||||
else:
|
||||
data['hook_menu'] = []
|
||||
|
||||
# global_static hook
|
||||
global_static_hook_file = 'data/hook_global_static.json'
|
||||
if os.path.exists(global_static_hook_file):
|
||||
df = mw.readFile(global_static_hook_file)
|
||||
df = json.loads(df)
|
||||
data['hook_global_static'] = df
|
||||
else:
|
||||
data['hook_global_static'] = []
|
||||
|
||||
return data
|
||||
|
||||
+1
-1
@@ -348,7 +348,7 @@ class Sql():
|
||||
except Exception as ex:
|
||||
return "error: " + str(ex)
|
||||
|
||||
def query(self, sql, param):
|
||||
def query(self, sql, param=()):
|
||||
# 执行SQL语句返回数据集
|
||||
self.__getConn()
|
||||
try:
|
||||
|
||||
+111
-2
@@ -247,8 +247,8 @@ class files_api:
|
||||
os.remove(task_log)
|
||||
return mw.returnJson(True, '任务已删除!')
|
||||
|
||||
# 上传文件
|
||||
def uploadFileApi(self):
|
||||
# 上传文件
|
||||
from werkzeug.utils import secure_filename
|
||||
from flask import request
|
||||
|
||||
@@ -263,6 +263,8 @@ class files_api:
|
||||
if os.path.exists(filename):
|
||||
s_path = filename
|
||||
p_stat = os.stat(s_path)
|
||||
|
||||
# print(filename)
|
||||
f.save(filename)
|
||||
os.chown(filename, p_stat.st_uid, p_stat.st_gid)
|
||||
os.chmod(filename, p_stat.st_mode)
|
||||
@@ -271,6 +273,86 @@ class files_api:
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnMsg(True, '上传成功!')
|
||||
|
||||
# 设置文件和目录权限
|
||||
def setMode(self, path):
|
||||
s_path = os.path.dirname(path)
|
||||
p_stat = os.stat(s_path)
|
||||
os.chown(path, p_stat.st_uid, p_stat.st_gid)
|
||||
os.chmod(path, p_stat.st_mode)
|
||||
|
||||
def uploadSegmentApi(self):
|
||||
# 分段上传
|
||||
path = request.form.get('path', '')
|
||||
name = request.form.get('name', '')
|
||||
size = request.form.get('size')
|
||||
start = request.form.get('start')
|
||||
dir_mode = request.form.get('dir_mode', '')
|
||||
file_mode = request.form.get('file_mode', '')
|
||||
|
||||
if not mw.fileNameCheck(name):
|
||||
return mw.returnJson(False, '文件名中不能包含特殊字符!')
|
||||
|
||||
if path == '/':
|
||||
return mw.returnJson(False, '不能直接上传文件到系统根目录!')
|
||||
|
||||
if name.find('./') != -1 or path.find('./') != -1:
|
||||
return mw.returnJson(False, '错误的参数')
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path, 493)
|
||||
if not dir_mode != '' or not file_mode != '':
|
||||
mw.setMode(path)
|
||||
|
||||
save_path = os.path.join(
|
||||
path, name + '.' + str(int(size)) + '.upload.tmp')
|
||||
d_size = 0
|
||||
if os.path.exists(save_path):
|
||||
d_size = os.path.getsize(save_path)
|
||||
|
||||
if d_size != int(start):
|
||||
return str(d_size)
|
||||
|
||||
f = open(save_path, 'ab')
|
||||
b64_data = request.form.get('b64_data', '0')
|
||||
if b64_data == '1':
|
||||
import base64
|
||||
b64_data = base64.b64decode(args.b64_data)
|
||||
f.write(b64_data)
|
||||
else:
|
||||
upload_files = request.files.getlist("blob")
|
||||
for tmp_f in upload_files:
|
||||
f.write(tmp_f.read())
|
||||
|
||||
f.close()
|
||||
f_size = os.path.getsize(save_path)
|
||||
if f_size != int(size):
|
||||
return str(f_size)
|
||||
|
||||
new_name = os.path.join(path, name)
|
||||
if os.path.exists(new_name):
|
||||
if new_name.find('.user.ini') != -1:
|
||||
mw.execShell("chattr -i " + new_name)
|
||||
try:
|
||||
os.remove(new_name)
|
||||
except:
|
||||
mw.execShell("rm -f %s" % new_name)
|
||||
|
||||
os.renames(save_path, new_name)
|
||||
|
||||
if dir_mode != '' and dir_mode != '':
|
||||
mode_tmp1 = dir_mode.split(',')
|
||||
mw.setMode(path, mode_tmp1[0])
|
||||
mw.setOwn(path, mode_tmp1[1])
|
||||
mode_tmp2 = file_mode.split(',')
|
||||
mw.setMode(new_name, mode_tmp2[0])
|
||||
mw.setOwn(new_name, mode_tmp2[1])
|
||||
else:
|
||||
self.setMode(new_name)
|
||||
|
||||
msg = mw.getInfo('上传文件[{1}] 到 [{2}]成功!', (new_name, path))
|
||||
mw.writeLog('文件管理', msg)
|
||||
return mw.returnMsg(True, '上传成功!')
|
||||
|
||||
def getRecycleBinApi(self):
|
||||
rPath = self.rPath
|
||||
if not os.path.exists(rPath):
|
||||
@@ -626,7 +708,7 @@ class files_api:
|
||||
return not path in nDirs
|
||||
|
||||
def getDirSize(self, path):
|
||||
if mw.getOs() == 'darwin':
|
||||
if mw.isAppleSystem():
|
||||
tmp = mw.execShell('du -sh ' + path)
|
||||
else:
|
||||
tmp = mw.execShell('du -sbh ' + path)
|
||||
@@ -905,6 +987,33 @@ class files_api:
|
||||
|
||||
return mw.getJson(data)
|
||||
|
||||
def execShellApi(self):
|
||||
# 执行SHELL命令
|
||||
shell = request.form.get('shell', '').strip()
|
||||
path = request.form.get('path', '').strip()
|
||||
disabled = ['vi', 'vim', 'top', 'passwd', 'su']
|
||||
tmp = shell.split(' ')
|
||||
if tmp[0] in disabled:
|
||||
return mw.returnJson(False, '禁止执行[{}]'.format(tmp[0]))
|
||||
shellStr = '''#!/bin/bash
|
||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||
export PATH
|
||||
cd %s
|
||||
%s
|
||||
''' % (path, shell)
|
||||
mw.writeFile('/tmp/panelShell.sh', shellStr)
|
||||
mw.execShell(
|
||||
'nohup bash /tmp/panelShell.sh > /tmp/panelShell.pl 2>&1 &')
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
def getExecShellMsgApi(self):
|
||||
# 取SHELL执行结果
|
||||
fileName = '/tmp/panelShell.pl'
|
||||
if not os.path.exists(fileName):
|
||||
return ''
|
||||
status = not mw.processExists('bash', None, '/tmp/panelShell.sh')
|
||||
return mw.returnJson(status, mw.getNumLines(fileName, 200))
|
||||
|
||||
def __get_stats(self, filename, path=None):
|
||||
filename = filename.replace('//', '/')
|
||||
try:
|
||||
|
||||
+12
-11
@@ -36,10 +36,10 @@ class firewall_api:
|
||||
iptables_file = mw.systemdCfgDir() + '/iptables.service'
|
||||
if os.path.exists('/usr/sbin/firewalld'):
|
||||
self.__isFirewalld = True
|
||||
elif os.path.exists(iptables_file):
|
||||
self.__isIptables = True
|
||||
elif os.path.exists('/usr/sbin/ufw'):
|
||||
self.__isUfw = True
|
||||
elif os.path.exists(iptables_file):
|
||||
self.__isIptables = True
|
||||
elif mw.isAppleSystem():
|
||||
self.__isMac = True
|
||||
|
||||
@@ -123,12 +123,12 @@ class firewall_api:
|
||||
address = port
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw delete deny from ' + address + ' to any')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isFirewalld:
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --remove-rich-rule=\'rule family=ipv4 source address="' + address + '" drop\'')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -D INPUT -s ' + address + ' -j DROP'
|
||||
mw.execShell(cmd)
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -149,14 +149,15 @@ class firewall_api:
|
||||
return mw.returnJson(False, '失败,不能删除当前面板端口!')
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw delete allow ' + port + '/tcp')
|
||||
elif self.__isIptables:
|
||||
mw.execShell(
|
||||
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
elif self.__isFirewalld:
|
||||
port = port.replace(':', '-')
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/tcp')
|
||||
mw.execShell(
|
||||
'firewall-cmd --permanent --zone=public --remove-port=' + port + '/udp')
|
||||
elif self.__isIptables:
|
||||
mw.execShell(
|
||||
'iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT')
|
||||
else:
|
||||
pass
|
||||
msg = mw.getInfo('删除防火墙放行端口[{1}]成功!', (port,))
|
||||
@@ -438,13 +439,13 @@ class firewall_api:
|
||||
def addAcceptPort(self, port):
|
||||
if self.__isUfw:
|
||||
mw.execShell('ufw allow ' + port + '/tcp')
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isFirewalld:
|
||||
port = port.replace(':', '-')
|
||||
cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp'
|
||||
mw.execShell(cmd)
|
||||
elif self.__isIptables:
|
||||
cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT'
|
||||
mw.execShell(cmd)
|
||||
else:
|
||||
pass
|
||||
return True
|
||||
|
||||
+54
-3
@@ -123,6 +123,23 @@ def getAcmeDir():
|
||||
return acme
|
||||
|
||||
|
||||
def getAcmeDomainDir(domain):
|
||||
acme_dir = getAcmeDir()
|
||||
acme_domain = acme_dir + '/' + domain
|
||||
acme_domain_ecc = acme_domain + '_ecc'
|
||||
if os.path.exists(acme_domain_ecc):
|
||||
acme_domain = acme_domain_ecc
|
||||
return acme_domain
|
||||
|
||||
|
||||
def fileNameCheck(filename):
|
||||
f_strs = [';', '&', '<', '>']
|
||||
for fs in f_strs:
|
||||
if filename.find(fs) != -1:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def triggerTask():
|
||||
isTask = getRunDir() + '/tmp/panelTask.pl'
|
||||
writeFile(isTask, 'True')
|
||||
@@ -988,7 +1005,7 @@ def getLocalIp():
|
||||
try:
|
||||
ipaddress = readFile(filename)
|
||||
if not ipaddress or ipaddress == '127.0.0.1':
|
||||
cmd = "curl -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
cmd = "curl --insecure -4 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
ip = execShell(cmd)
|
||||
result = ip[0].strip()
|
||||
if result == '':
|
||||
@@ -997,7 +1014,7 @@ def getLocalIp():
|
||||
return result
|
||||
return ipaddress
|
||||
except Exception as e:
|
||||
cmd = "curl -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
cmd = "curl --insecure -6 -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text"
|
||||
ip = execShell(cmd)
|
||||
result = ip[0].strip()
|
||||
if result == '':
|
||||
@@ -1122,6 +1139,15 @@ def setOwn(filename, user, group=None):
|
||||
return True
|
||||
|
||||
|
||||
def setMode(filename, mode):
|
||||
# 设置文件权限
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
mode = int(str(mode), 8)
|
||||
os.chmod(filename, mode)
|
||||
return True
|
||||
|
||||
|
||||
def checkPort(port):
|
||||
# 检查端口是否合法
|
||||
ports = ['21', '443', '888']
|
||||
@@ -1207,7 +1233,7 @@ def makeConf():
|
||||
file = getRunDir() + '/data/json/config.json'
|
||||
if not os.path.exists(file):
|
||||
c = {}
|
||||
c['title'] = '大圣面板'
|
||||
c['title'] = '金蝉面板'
|
||||
c['home'] = 'http://github/midoks/mdserver-web'
|
||||
c['recycle_bin'] = True
|
||||
c['template'] = 'default'
|
||||
@@ -1614,6 +1640,31 @@ def getSshDir():
|
||||
return '/root/.ssh'
|
||||
|
||||
|
||||
def processExists(pname, exe=None, cmdline=None):
|
||||
# 进程是否存在
|
||||
try:
|
||||
import psutil
|
||||
pids = psutil.pids()
|
||||
for pid in pids:
|
||||
try:
|
||||
p = psutil.Process(pid)
|
||||
if p.name() == pname:
|
||||
if not exe and not cmdline:
|
||||
return True
|
||||
else:
|
||||
if exe:
|
||||
if p.exe() == exe:
|
||||
return True
|
||||
if cmdline:
|
||||
if cmdline in p.cmdline():
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
except:
|
||||
return True
|
||||
|
||||
|
||||
def createRsa():
|
||||
# ssh-keygen -t rsa -P "" -C "midoks@163.com"
|
||||
ssh_dir = getSshDir()
|
||||
|
||||
@@ -91,7 +91,7 @@ class plugins_api:
|
||||
t = mw.readFile(menu_file)
|
||||
tlist = json.loads(t)
|
||||
for menu_data in tlist:
|
||||
if 'path' in menu_data:
|
||||
if tag == menu_data['name'] and 'path' in menu_data:
|
||||
tpath = self.menuGetAbsPath(tag, menu_data['path'])
|
||||
content = mw.readFile(tpath)
|
||||
data['plugin_content'] = content
|
||||
@@ -256,13 +256,14 @@ class plugins_api:
|
||||
data = json.loads(t)
|
||||
|
||||
for idx in range(len(data)):
|
||||
if data[idx]['title'] == info['title'] and data[idx]['name'] == info['name']:
|
||||
if data[idx]['name'] == info['name']:
|
||||
data.remove(data[idx])
|
||||
break
|
||||
mw.writeFile(hookPath, json.dumps(data))
|
||||
|
||||
def hookInstall(self, info):
|
||||
valid_hook = ['backup', 'database']
|
||||
valid_list_hook = ['menu']
|
||||
valid_list_hook = ['menu', 'global_static', 'site_cb']
|
||||
if 'hook' in info:
|
||||
hooks = info['hook']
|
||||
for h in hooks:
|
||||
@@ -280,7 +281,7 @@ class plugins_api:
|
||||
|
||||
def hookUninstall(self, info):
|
||||
valid_hook = ['backup', 'database']
|
||||
valid_list_hook = ['menu']
|
||||
valid_list_hook = ['menu', 'global_static', 'site_cb']
|
||||
if 'hook' in info:
|
||||
hooks = info['hook']
|
||||
for h in hooks:
|
||||
@@ -795,7 +796,8 @@ class plugins_api:
|
||||
for index in range(len(tmp_data)):
|
||||
plugins_info.append(tmp_data[index])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(json_file)
|
||||
print(mw.getTracebackInfo())
|
||||
|
||||
start = (page - 1) * pageSize
|
||||
end = start + pageSize
|
||||
|
||||
+42
-10
@@ -72,6 +72,30 @@ class site_api:
|
||||
mw.execShell("mkdir -p " + self.sslLetsDir +
|
||||
" && chmod -R 755 " + self.sslLetsDir)
|
||||
|
||||
def runHook(self, hook_name, func_name):
|
||||
# 站点操作Hook
|
||||
hook_file = 'data/hook_site_cb.json'
|
||||
hook_cfg = []
|
||||
if os.path.exists(hook_file):
|
||||
t = mw.readFile(hook_file)
|
||||
hook_cfg = json.loads(t)
|
||||
|
||||
hook_num = len(hook_cfg)
|
||||
if hook_num == 0:
|
||||
return
|
||||
|
||||
import plugins_api
|
||||
pa = plugins_api.plugins_api()
|
||||
|
||||
for x in range(hook_num):
|
||||
hook_data = hook_cfg[x]
|
||||
if func_name in hook_data:
|
||||
app_name = hook_data["name"]
|
||||
run_func = hook_data[func_name]['func']
|
||||
# print(app_name, run_func)
|
||||
pa.run(app_name, run_func)
|
||||
return True
|
||||
|
||||
##### ----- start ----- ###
|
||||
def listApi(self):
|
||||
limit = request.form.get('limit', '10')
|
||||
@@ -550,7 +574,7 @@ class site_api:
|
||||
return mw.returnJson(False, '使用中,先关闭再删除')
|
||||
mw.execShell('rm -rf ' + ssl_lets_dir)
|
||||
elif ssl_type == 'acme':
|
||||
ssl_acme_dir = mw.getAcmeDir() + '/' + site_name
|
||||
ssl_acme_dir = mw.getAcmeDomainDir(site_name)
|
||||
csr_acme_path = ssl_acme_dir + '/fullchain.cer' # 生成证书路径
|
||||
if mw.md5(mw.readFile(csr_acme_path)) == mw.md5(mw.readFile(csr_path)):
|
||||
return mw.returnJson(False, '使用中,先关闭再删除')
|
||||
@@ -587,9 +611,9 @@ class site_api:
|
||||
csr_path = self.sslLetsDir + '/' + site_name + '/fullchain.pem' # 生成证书路径
|
||||
key_path = self.sslLetsDir + '/' + site_name + '/privkey.pem' # 密钥文件路径
|
||||
elif ssl_type == 'acme':
|
||||
csr_path = mw.getAcmeDir() + '/' + site_name + '/fullchain.cer' # 生成证书路径
|
||||
key_path = mw.getAcmeDir() + '/' + site_name + '/' + \
|
||||
site_name + '.key' # 密钥文件路径
|
||||
acme_dir = mw.getAcmeDomainDir(site_name)
|
||||
csr_path = acme_dir + '/fullchain.cer' # 生成证书路径
|
||||
key_path = acme_dir + '/' + site_name + '.key' # 密钥文件路径
|
||||
|
||||
key = mw.readFile(key_path)
|
||||
csr = mw.readFile(csr_path)
|
||||
@@ -989,16 +1013,17 @@ class site_api:
|
||||
# print(cmd)
|
||||
result = mw.execShell(cmd)
|
||||
|
||||
src_path = acme_dir + '/' + domains[0]
|
||||
src_path = mw.getAcmeDomainDir(domains[0])
|
||||
src_cert = src_path + '/fullchain.cer'
|
||||
src_key = src_path + '/' + domains[0] + '.key'
|
||||
src_cert.replace("\*", "*")
|
||||
|
||||
msg = '签发失败,您尝试申请证书的失败次数已达上限!<p>1、检查域名是否绑定到对应站点</p>\
|
||||
<p>2、检查域名是否正确解析到本服务器,或解析还未完全生效</p>\
|
||||
<p>3、如果您的站点设置了反向代理,或使用了CDN,请先将其关闭</p>\
|
||||
<p>4、如果您的站点设置了301重定向,请先将其关闭</p>\
|
||||
<p>5、如果以上检查都确认没有问题,请尝试更换DNS服务商</p>'
|
||||
if not os.path.exists(src_cert.replace("\*", "*")):
|
||||
if not os.path.exists(src_cert):
|
||||
data = {}
|
||||
data['err'] = result
|
||||
data['out'] = result[0]
|
||||
@@ -1271,6 +1296,7 @@ class site_api:
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, domain_name, domain_port, mw.getDate()))
|
||||
|
||||
self.runHook('site_cb', 'add')
|
||||
return mw.returnJson(True, '域名添加成功!')
|
||||
|
||||
def addDirBindApi(self):
|
||||
@@ -1400,7 +1426,7 @@ class site_api:
|
||||
data['filename'] = filename
|
||||
return mw.getJson(data)
|
||||
|
||||
# 修改物理路径
|
||||
# 修改物理路径
|
||||
def setPathApi(self):
|
||||
mid = request.form.get('id', '')
|
||||
path = request.form.get('path', '')
|
||||
@@ -2529,16 +2555,18 @@ location ^~ {from} {\n\
|
||||
self.createRootDir(self.sitePath)
|
||||
self.nginxAddConf()
|
||||
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, self.siteName, self.sitePort, mw.getDate()))
|
||||
|
||||
# 添加更多域名
|
||||
for domain in siteMenu['domainlist']:
|
||||
self.addDomain(domain, self.siteName, pid)
|
||||
|
||||
mw.M('domain').add('pid,name,port,addtime',
|
||||
(pid, self.siteName, self.sitePort, mw.getDate()))
|
||||
|
||||
data = {}
|
||||
data['siteStatus'] = False
|
||||
mw.restartWeb()
|
||||
|
||||
self.runHook('site_cb', 'add')
|
||||
return mw.returnJson(True, '添加成功')
|
||||
|
||||
def deleteWSLogs(self, webname):
|
||||
@@ -2588,6 +2616,8 @@ location ^~ {from} {\n\
|
||||
mw.execShell('rm -rf ' + ssl_acme_dir)
|
||||
|
||||
mw.M('sites').where("id=?", (sid,)).delete()
|
||||
mw.M('domain').where("pid=?", (sid,)).delete()
|
||||
mw.M('domain').where("name=?", (webname,)).delete()
|
||||
|
||||
# binding domain delete
|
||||
binding_list = mw.M('binding').field(
|
||||
@@ -2605,6 +2635,8 @@ location ^~ {from} {\n\
|
||||
|
||||
mw.M('binding').where("pid=?", (sid,)).delete()
|
||||
mw.restartWeb()
|
||||
|
||||
self.runHook('site_cb', 'delete')
|
||||
return mw.returnJson(True, '站点删除成功!')
|
||||
|
||||
def setEndDate(self, sid, edate):
|
||||
|
||||
@@ -166,6 +166,33 @@ class system_api:
|
||||
except:
|
||||
return False
|
||||
|
||||
def getEnvInfoApi(self, get=None):
|
||||
serverInfo = {}
|
||||
serverInfo['status'] = True
|
||||
sdir = mw.getServerDir()
|
||||
|
||||
serverInfo['webserver'] = '未安装'
|
||||
if os.path.exists(sdir + '/openresty/nginx/sbin/nginx'):
|
||||
serverInfo['webserver'] = 'OpenResty'
|
||||
serverInfo['php'] = []
|
||||
phpversions = ['52', '53', '54', '55', '56', '70', '71',
|
||||
'72', '73', '74', '80', '81', '82', '83', '84']
|
||||
phpPath = sdir + '/php/'
|
||||
for pv in phpversions:
|
||||
if not os.path.exists(phpPath + pv + '/bin/php'):
|
||||
continue
|
||||
serverInfo['php'].append(pv)
|
||||
serverInfo['mysql'] = False
|
||||
if os.path.exists(sdir + '/mysql/bin/mysql'):
|
||||
serverInfo['mysql'] = True
|
||||
import psutil
|
||||
try:
|
||||
diskInfo = psutil.disk_usage('/www')
|
||||
except:
|
||||
diskInfo = psutil.disk_usage('/')
|
||||
serverInfo['disk'] = diskInfo[2]
|
||||
return mw.returnJson(True, 'ok', serverInfo)
|
||||
|
||||
def getPanelInfo(self, get=None):
|
||||
# 取面板配置
|
||||
address = mw.GetLocalIp()
|
||||
|
||||
@@ -33,7 +33,11 @@ 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
|
||||
if [ -f $GIT_PROJECT_DIR/exclude.list ];then
|
||||
rsync -vauP --delete --exclude-from="$GIT_PROJECT_DIR/exclude.list" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
else
|
||||
rsync -vauP --exclude=".*" $GIT_PROJECT_DIR/ $WEB_PATH
|
||||
fi
|
||||
fi
|
||||
|
||||
sysName=`uname`
|
||||
|
||||
@@ -228,11 +228,11 @@ label.checkbox_label span {
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
<span class="panel_setp_span">接收数据的面板地址</span>
|
||||
<input type="text" class="bt-input-text" name="psync_url" value="" placeholder="接收数据面板地址,如: http://127.0.0.1:8888">
|
||||
<input type="text" class="bt-input-text" name="sync_url" value="" placeholder="接收数据面板地址,如: http://127.0.0.1:8888">
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
<span class="panel_setp_span">接收数据的面板API</span>
|
||||
<input type="text" class="bt-input-text" name="psync_token" value="" placeholder="接收数据面板API密钥" />
|
||||
<input type="text" class="bt-input-text" name="sync_token" value="" placeholder="接收数据面板API密钥" />
|
||||
<a href="#" target="_blank" class="btlink ml5">获取API秘钥</a>
|
||||
</div>
|
||||
<div class="mtb20">
|
||||
@@ -243,8 +243,7 @@ label.checkbox_label span {
|
||||
<button class="btn btn-success infoNext">下一步</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pa15 psync_path" style="margin:0 50px">
|
||||
</div>
|
||||
<div class="pa15 psync_path" style="margin:0 50px;"></div>
|
||||
<div class="pa15 psync_data" style="text-align: left;">
|
||||
<div class="checkbox_conten">
|
||||
<div class="checkbox_data">
|
||||
@@ -253,7 +252,7 @@ label.checkbox_label span {
|
||||
<input type="checkbox" id="sites_All" checked>
|
||||
<span>网站</span>
|
||||
</label>
|
||||
<ul></ul>
|
||||
<ul id="sites_li"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="checkbox_data">
|
||||
@@ -262,7 +261,7 @@ label.checkbox_label span {
|
||||
<input type="checkbox" id="db_All" checked>
|
||||
<span>数据库</span>
|
||||
</label>
|
||||
<ul></ul>
|
||||
<ul id="db_li"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -286,6 +285,7 @@ label.checkbox_label span {
|
||||
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(700);
|
||||
resetPluginWinWidth(700);
|
||||
$.getScript( "/plugins/file?name=migration_api&f=js/app.js", function(){
|
||||
initStep();
|
||||
});
|
||||
|
||||
+1001
-13
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"ps": "[<span style='color:red;'>潜龙勿用</span>]一键迁移,仅网站数据和MySQL数据",
|
||||
"ps": "[<span style='color:red;'>潜龙勿用</span>]一键迁移,仅网站数据和MySQL数据(仅支持源码安装软件)",
|
||||
"name": "migration_api",
|
||||
"title": "一键迁移API",
|
||||
"shell": "install.sh",
|
||||
|
||||
+246
-22
@@ -1,4 +1,24 @@
|
||||
function maPost(method,args,callback){
|
||||
|
||||
function maPostNoMsg(method,args,callback){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
} else {
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
$.post('/plugins/run', {name:'migration_api', func:method, args:_args}, function(data) {
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
if(typeof(callback) == 'function'){
|
||||
callback(data);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
function maPost(method,args,callback, msg = '正在获取...'){
|
||||
var _args = null;
|
||||
if (typeof(args) == 'string'){
|
||||
_args = JSON.stringify(toArrayObject(args));
|
||||
@@ -6,7 +26,7 @@ function maPost(method,args,callback){
|
||||
_args = JSON.stringify(args);
|
||||
}
|
||||
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
var loadT = layer.msg(msg, { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'migration_api', func:method, args:_args}, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
@@ -30,6 +50,7 @@ function maAsyncPost(method,args){
|
||||
return syncPost('/plugins/run', {name:'migration_api', func:method, args:_args});
|
||||
}
|
||||
|
||||
|
||||
function maPostCallbak(method, args, callback){
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
@@ -58,43 +79,246 @@ function maPostCallbak(method, args, callback){
|
||||
}
|
||||
|
||||
|
||||
function initStep1(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
function selectProgress(val){
|
||||
$('.step_head li').removeClass('active');
|
||||
$('.step_head li').each(function(){
|
||||
var v = $(this).find('span').text();
|
||||
if (val == v){
|
||||
$(this).addClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initStep1(){
|
||||
var url = $('input[name="sync_url"]').val();
|
||||
var token = $('input[name="sync_token"]').val();
|
||||
maPost('step_one',{url:url,token:token}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
initStep2();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
},'API校验中...');
|
||||
}
|
||||
|
||||
function initStep2(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
});
|
||||
maPost('step_two',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
selectProgress(2);
|
||||
$('.psync_info').hide();
|
||||
|
||||
var info = rdata.data;
|
||||
|
||||
var body = '<div class="divtable">\
|
||||
<table class="table table-hover">\
|
||||
<thead>\
|
||||
<tr><th style="border-right:1px solid #ddd">服务</th><th>当前服务器</th><th>远程服务器</th></tr>\
|
||||
</thead>\
|
||||
<tbody>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">网站服务</td>\
|
||||
<td>'+info['local']['webserver']+'</td>\
|
||||
<td>'+info['remote']['webserver']+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">安装MySQL</td>\
|
||||
<td>'+(info['local']['mysql']?'是':'否')+'</td>\
|
||||
<td>'+(info['remote']['mysql']?'是':'否')+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">安装PHP</td>\
|
||||
<td>'+(info['local']['php'].join('/'))+'</td>\
|
||||
<td>'+(info['remote']['php'].join('/')) +'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td style="border-right:1px solid #ddd">可用磁盘</td>\
|
||||
<td>'+info['local']['disk']+'</td>\
|
||||
<td>'+info['remote']['disk'][0]['size'][0]+'</td>\
|
||||
</tr>\
|
||||
</tbody>\
|
||||
</table>\
|
||||
</div>';
|
||||
body += '<div class="line mtb20" style="text-align: left;">\
|
||||
<button class="btn btn-default btn-sm mr20 pathTestting">重新检测</button>\
|
||||
<button class="btn btn-default btn-sm mr20 pathBcak">上一步</button>\
|
||||
<button class="btn btn-success btn-sm psync-next pathNext">下一步</button>\
|
||||
</div>';
|
||||
|
||||
$('.psync_path').html(body);
|
||||
$('.psync_path').show();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
},'检测环境中...');
|
||||
}
|
||||
|
||||
function initStep3(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
maPost('step_three',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
showMsg(rdata.msg,function(){
|
||||
if (rdata.status){
|
||||
selectProgress(3);
|
||||
var pdata = rdata.data;
|
||||
var site_li = '';
|
||||
for (var i = 0; i < pdata.sites.length; i++) {
|
||||
site_li+='<li>\
|
||||
<label>\
|
||||
<input type="checkbox" data-id="'+i+'" id="sites_'+pdata.sites[i]['name']+'" value="'+pdata.sites[i]['name']+'" name="sites" checked="">\
|
||||
<span title="'+pdata.sites[i]['name']+'">'+pdata.sites[i]['name']+'</span>\
|
||||
</label>\
|
||||
</li>';
|
||||
}
|
||||
|
||||
$('#sites_li').html(site_li);
|
||||
|
||||
|
||||
var db_li = '';
|
||||
for (var i = 0; i < pdata.databases.length; i++) {
|
||||
db_li+='<li>\
|
||||
<label>\
|
||||
<input type="checkbox" data-id="'+i+'" id="sites_'+pdata.databases[i]['name']+'" value="'+pdata.databases[i]['name']+'" name="databases" checked="">\
|
||||
<span title="'+pdata.databases[i]['name']+'">'+pdata.databases[i]['name']+'</span>\
|
||||
</label>\
|
||||
</li>';
|
||||
}
|
||||
$('#db_li').html(db_li);
|
||||
|
||||
$('.psync_path').hide();
|
||||
$('.psync_data').show();
|
||||
}
|
||||
},{ icon: rdata.status ? 1 : 2 });
|
||||
});
|
||||
}
|
||||
|
||||
function renderMigrationProgress(){
|
||||
maPostNoMsg('get_speed',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
// console.log('speed:',rdata.data);
|
||||
if (rdata.status){
|
||||
if (rdata['data']['action'] == 'True'){
|
||||
var end = '<div class="line">\
|
||||
<div class="success text-center" style="padding: 10px 0 15px;">\
|
||||
<p>数据迁移完成,请务必检查数据完整性!</p>\
|
||||
<p style="font-size: 14px;margin-top:2px;color: #939292;">传输大小: '+toSize(rdata['data']['total_size'])+',耗时: '+rdata['data']['total_time']+',平均速度: '+toSize(rdata['data']['speed'])+'/s</p>\
|
||||
<p class="mtb15">\
|
||||
<button class="btn btn-success btn-sm mr5 okBtn">确定完成</button>\
|
||||
<a class="btn btn-default btn-sm" style="margin-left: 10px;" target="_blank" href="/files/download?filename='+rdata['data']['log_file']+'">迁移日志</a>\
|
||||
</p>\
|
||||
</div>\
|
||||
</div>';
|
||||
$('.psync_migrate').html(end);
|
||||
} else{
|
||||
$('.psync_migrate .action').text(rdata['data']['action']);
|
||||
$('.psync_migrate .done').text(rdata['data']['done']);
|
||||
$('.psync_migrate pre').text(rdata['data']['log']);
|
||||
|
||||
var p = (rdata['data']['all_speed']/rdata['data']['all_total'])*100;
|
||||
if (p>100){
|
||||
p = 100;
|
||||
}
|
||||
$('.psync_migrate .progress_info_bar').width(p+'%');
|
||||
$('.psync_migrate .progress_info').text(p+'%');
|
||||
|
||||
renderMigrationProgress();
|
||||
}
|
||||
} else{
|
||||
layer.msg(rdata.msg,{icon:1});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initStep4(){
|
||||
maPost('step_one',{}, function(rdata){
|
||||
console.log(rdata);
|
||||
var site_checked = '';
|
||||
$('input[name="sites"]:checked').each(function(){
|
||||
site_checked += $(this).val()+',';
|
||||
});
|
||||
|
||||
var databases_checked = '';
|
||||
$('input[name="databases"]:checked').each(function(){
|
||||
databases_checked+=$(this).val()+',';
|
||||
});
|
||||
|
||||
maPost('step_four',{sites:site_checked,databases:databases_checked}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
selectProgress(4);
|
||||
|
||||
var progress = '<div style="margin: 0 40px;">\
|
||||
<div class="line">\
|
||||
<div style="text-align:left"><span class="action">--</span>\
|
||||
<span style="margin-left: 20px;" class="done">当前: --</span><img src="/static/img/ing.gif"><a style="position: absolute;right: 40px;" class="btlink psync_close" onclick="migrate.close();">[取消]</a></div>\
|
||||
<div class="bt-progress" style="border-radius:0;height:20px;line-height:19px">\
|
||||
<div class="bt-progress-bar progress_info_bar" style="border-radius: 0px; height: 20px; width: 0%;">\
|
||||
<span class="bt-progress-text progress_info"></span></div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<pre style="height: 222px;text-align: left;margin:5px 38px 0;font-size: 12px;line-height: 20px;padding: 10px;background-color: #333;color: #fff;"></pre>\
|
||||
</div>';
|
||||
|
||||
|
||||
$('.psync_data').hide();
|
||||
$('.psync_migrate').html(progress);
|
||||
$('.psync_migrate').show();
|
||||
|
||||
renderMigrationProgress();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initStep(){
|
||||
console.log($('.infoNext'));
|
||||
maPost('get_conf',{}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
$('input[name="sync_url"]').val(rdata.data['url']);
|
||||
$('input[name="sync_token"]').val(rdata.data['token']);
|
||||
});
|
||||
|
||||
$('.infoNext').click(function(){
|
||||
var step = $('.step_head .active span').text();
|
||||
// console.log(step);
|
||||
// initStep1();
|
||||
switch(step){
|
||||
case '1':initStep1();break;
|
||||
case '2':initStep2();break;
|
||||
case '3':initStep3();break;
|
||||
case '4':initStep4();break;
|
||||
}
|
||||
initStep1();
|
||||
});
|
||||
|
||||
// 重新检测按钮
|
||||
$('.psync_path').on('click', '.pathTestting', function () {
|
||||
initStep2();
|
||||
});
|
||||
|
||||
$('.psync_path').on('click', '.pathBcak', function(){
|
||||
$('.psync_path').hide();
|
||||
$('.psync_info').show();
|
||||
selectProgress(1);
|
||||
});
|
||||
|
||||
$('.psync_path').on('click', '.pathNext', function(){
|
||||
initStep3();
|
||||
});
|
||||
|
||||
|
||||
$('.psync_data').on('click', '.dataBack', function(){
|
||||
$('.psync_data').hide();
|
||||
$('.psync_path').show();
|
||||
selectProgress(2);
|
||||
});
|
||||
|
||||
|
||||
$('.psync_data').on('click', '.dataMigrate', function(){
|
||||
initStep4();
|
||||
});
|
||||
|
||||
$('#sites_All').on('click',function(){
|
||||
var ch = $(this).prop('checked');
|
||||
$('#sites_li input').prop('checked',ch);
|
||||
});
|
||||
|
||||
$('#db_All').on('click',function(){
|
||||
var ch = $(this).prop('checked');
|
||||
$('#db_li input').prop('checked',ch);
|
||||
});
|
||||
|
||||
$('.psync_migrate').on('click', '.okBtn', function(){
|
||||
$('.psync_migrate').hide();
|
||||
$('.psync_info').show();
|
||||
selectProgress(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -62,6 +62,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log_replica_updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -66,6 +66,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log-slave-updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -62,6 +62,7 @@ binlog-ignore-db = performance_schema
|
||||
#slave
|
||||
log_replica_updates
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -70,6 +70,7 @@ log-slave-updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -72,6 +72,7 @@ log-slave-updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -73,6 +73,7 @@ binlog-ignore-db = performance_schema
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip-slave-start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
@@ -71,6 +71,7 @@ log_replica_updates = 1
|
||||
# Prevent replication from starting automatically with MySQL
|
||||
#skip_replica_start = 1
|
||||
#replicate-do-db
|
||||
slave_skip_errors=1062
|
||||
replicate-ignore-db = information_schema
|
||||
replicate-ignore-db = performance_schema
|
||||
replicate-ignore-db = mysql
|
||||
|
||||
+65
-12
@@ -48,19 +48,20 @@ def getInitDFile():
|
||||
|
||||
def getArgs():
|
||||
args = sys.argv[2:]
|
||||
|
||||
tmp = {}
|
||||
args_len = len(args)
|
||||
|
||||
if args_len == 1:
|
||||
t = args[0].strip('{').strip('}')
|
||||
t = t.split(':')
|
||||
if t.strip() == '':
|
||||
tmp = []
|
||||
else:
|
||||
t = t.split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
tmp[t[0]] = t[1]
|
||||
elif args_len > 1:
|
||||
for i in range(len(args)):
|
||||
t = args[i].split(':')
|
||||
t = args[i].split(':', 1)
|
||||
tmp[t[0]] = t[1]
|
||||
|
||||
return tmp
|
||||
|
||||
|
||||
@@ -842,12 +843,29 @@ def setDbBackup():
|
||||
return data[1]
|
||||
|
||||
scDir = mw.getRunDir() + '/scripts/backup.py'
|
||||
|
||||
cmd = 'python3 ' + scDir + ' database ' + args['name'] + ' 3'
|
||||
os.system(cmd)
|
||||
return mw.returnJson(True, 'ok')
|
||||
|
||||
|
||||
# 数据库密码处理
|
||||
def myPass(act, root):
|
||||
conf_file = getConf()
|
||||
mw.execShell("sed -i '/user=root/d' {}".format(conf_file))
|
||||
mw.execShell("sed -i '/password=/d' {}".format(conf_file))
|
||||
if act:
|
||||
mycnf = mw.readFile(conf_file)
|
||||
src_dump = "[mysqldump]\n"
|
||||
sub_dump = src_dump + "user=root\npassword=\"{}\"\n".format(root)
|
||||
if not mycnf:
|
||||
return False
|
||||
mycnf = mycnf.replace(src_dump, sub_dump)
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(conf_file, mycnf)
|
||||
return True
|
||||
return True
|
||||
|
||||
|
||||
def importDbExternal():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['file', 'name'])
|
||||
@@ -902,11 +920,16 @@ def importDbExternal():
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
|
||||
os.environ["MYSQL_PWD"] = pwd
|
||||
mysql_cmd = getServerDir() + '/bin/mysql -S ' + sock + ' -uroot -p' + \
|
||||
pwd + ' ' + name + ' < ' + import_sql
|
||||
my_cnf = getConf()
|
||||
|
||||
myPass(True, pwd)
|
||||
mysql_cmd = getServerDir() + '/bin/mysql --defaults-file=' + my_cnf + \
|
||||
' -uroot -p\"' + pwd + '\" -f ' + name + ' < ' + import_sql
|
||||
|
||||
# print(mysql_cmd)
|
||||
rdata = mw.execShell(mysql_cmd)
|
||||
myPass(False, pwd)
|
||||
# print(rdata)
|
||||
if ext != 'sql':
|
||||
os.remove(import_sql)
|
||||
|
||||
@@ -2371,6 +2394,25 @@ def initSlaveStatus(version=''):
|
||||
return initSlaveStatusSyncUser(version)
|
||||
|
||||
|
||||
def makeSyncUsercmd(u, version=''):
|
||||
mode = recognizeDbMode()
|
||||
sql = ''
|
||||
|
||||
ip = u['ip']
|
||||
port = u['port']
|
||||
username = u['user']
|
||||
password = u['pass']
|
||||
if mode == "gtid":
|
||||
sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \
|
||||
username + "', MASTER_PASSWORD='" + \
|
||||
password + "', MASTER_AUTO_POSITION=1"
|
||||
if version == '8.0':
|
||||
sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \
|
||||
username + "', SOURCE_PASSWORD='" + \
|
||||
password + "', MASTER_AUTO_POSITION=1"
|
||||
return sql
|
||||
|
||||
|
||||
def initSlaveStatusSyncUser(version=''):
|
||||
conn = pSqliteDb('slave_sync_user')
|
||||
data = conn.field('ip,port,user,pass,mode,cmd').find()
|
||||
@@ -2393,8 +2435,19 @@ def initSlaveStatusSyncUser(version=''):
|
||||
if local_mode != mode_name:
|
||||
return mw.returnJson(False, '同步模式不一致!')
|
||||
|
||||
t = db.query(u['cmd'])
|
||||
# print(t)
|
||||
if u['cmd'] == '' and local_mode == 'gtid':
|
||||
sql = makeSyncUsercmd(u, version)
|
||||
# print(sql)
|
||||
t = db.query(sql)
|
||||
else:
|
||||
if u['cmd'] == '':
|
||||
return mw.returnJson(False, '经典模式下,必须手写同步命令!')
|
||||
# print(u['cmd'])
|
||||
t = db.query(u['cmd'])
|
||||
isError = isSqlError(t)
|
||||
if isError:
|
||||
return isError
|
||||
|
||||
db.query("start slave user='{}' password='{}';".format(
|
||||
u['user'], u['pass']))
|
||||
return mw.returnJson(True, '初始化成功!')
|
||||
@@ -2613,7 +2666,7 @@ def doFullSyncUser(version=''):
|
||||
|
||||
if not os.path.exists(bak_file):
|
||||
dump_sql_data = getServerDir() + "/bin/mysqldump " + dmp_option + " --force --opt --default-character-set=utf8 --single-transaction -h" + ip + " -P" + \
|
||||
port + " -u" + user + " -p" + apass + " " + sync_db + " > " + bak_file
|
||||
port + " -u" + user + " -p\"" + apass + "\" " + sync_db + " > " + bak_file
|
||||
mw.execShell(dump_sql_data)
|
||||
|
||||
writeDbSyncStatus({'code': 2, 'msg': '本地导入数据...', 'progress': 40})
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
{
|
||||
"hook":[
|
||||
{
|
||||
"tag":"site_cb",
|
||||
"site_cb": {
|
||||
"title":"网站统计",
|
||||
"name":"op_waf",
|
||||
"add":{"func":"reload"},
|
||||
"update":{"func":"reload"},
|
||||
"delete":{"func":"reload"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"title":"OP防火墙",
|
||||
"tip":"soft",
|
||||
"name":"op_waf",
|
||||
@@ -12,5 +24,5 @@
|
||||
"home":"https://github.com/loveshell/ngx_lua_waf",
|
||||
"date":"2019-04-21",
|
||||
"pid": "1",
|
||||
"versions": ["0.2.5"]
|
||||
"versions": ["0.2.6"]
|
||||
}
|
||||
@@ -204,8 +204,8 @@ def initDreplace():
|
||||
mw.writeFile(file_bin, content)
|
||||
mw.execShell('chmod +x ' + file_bin)
|
||||
|
||||
# config replace
|
||||
confReplace()
|
||||
# config replace
|
||||
confReplace()
|
||||
|
||||
# systemd
|
||||
# /usr/lib/systemd/system
|
||||
|
||||
@@ -59,11 +59,11 @@ Install_openresty()
|
||||
mkdir -p ${openrestyDir}
|
||||
echo '正在安装脚本文件...' > $install_tmp
|
||||
|
||||
# wget -O openresty-1.21.4.1.tar.gz https://openresty.org/download/openresty-1.21.4.1.tar.gz
|
||||
if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then
|
||||
wget -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://openresty.org/download/openresty-${VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
|
||||
cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz
|
||||
|
||||
# --with-openssl=$serverPath/source/lib/openssl-1.0.2q
|
||||
|
||||
@@ -47,7 +47,8 @@ Install_phpmyadmin()
|
||||
|
||||
mkdir -p ${serverPath}/phpmyadmin
|
||||
mkdir -p ${serverPath}/source/phpmyadmin
|
||||
|
||||
echo "${1}" > ${serverPath}/phpmyadmin/version.pl
|
||||
|
||||
VER=$1
|
||||
|
||||
FDIR=phpMyAdmin-${VER}-all-languages
|
||||
@@ -67,7 +68,7 @@ Install_phpmyadmin()
|
||||
cd $serverPath/phpmyadmin/ && mv $FDIR phpmyadmin
|
||||
|
||||
|
||||
echo "${1}" > ${serverPath}/phpmyadmin/version.pl
|
||||
|
||||
echo '安装完成' > $install_tmp
|
||||
|
||||
cd ${rootPath} && python3 ${rootPath}/plugins/phpmyadmin/index.py start
|
||||
|
||||
@@ -26,7 +26,6 @@ AutoRename no
|
||||
AnonymousCantUpload no
|
||||
MaxDiskUsage 99
|
||||
CustomerProof yes
|
||||
PassivePortRange 48000 50000
|
||||
PIDFile {$SERVER_PATH}/pureftp/etc/pure-ftpd.pid
|
||||
PureDB {$SERVER_PATH}/pureftp/etc/pureftpd.pdb
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@ serverPath=$(dirname "$rootPath")
|
||||
|
||||
install_tmp=${rootPath}/tmp/mw_install.pl
|
||||
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
sysName=`uname`
|
||||
echo "use system: ${sysName}"
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ bash ${rootPath}/scripts/getos.sh
|
||||
OSNAME=`cat ${rootPath}/data/osname.pl`
|
||||
|
||||
|
||||
if [ -f ${rootPath}/bin/activate ];then
|
||||
source ${rootPath}/bin/activate
|
||||
fi
|
||||
|
||||
if id www &> /dev/null ;then
|
||||
echo "www uid is `id -u www`"
|
||||
echo "www shell is `grep "^www:" /etc/passwd |cut -d':' -f7 `"
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
#
|
||||
# Discuz Sphinx Config File
|
||||
#
|
||||
|
||||
indexer
|
||||
{
|
||||
mem_limit = 32M
|
||||
write_buffer = 64M
|
||||
}
|
||||
|
||||
searchd
|
||||
{
|
||||
listen = 9312
|
||||
listen = 9306:mysql41
|
||||
log = {$SERVER_APP}/index/searchd.log
|
||||
query_log = {$SERVER_APP}/index/query.log
|
||||
read_timeout = 5
|
||||
max_children = 0
|
||||
pid_file = {$SERVER_APP}/index/searchd.pid
|
||||
seamless_rotate = 1
|
||||
preopen_indexes = 1
|
||||
unlink_old = 1
|
||||
#workers = threads # for RT to work
|
||||
binlog_path = {$SERVER_APP}/index/binlog
|
||||
}
|
||||
|
||||
|
||||
source pre_forum_thread
|
||||
{
|
||||
type = mysql
|
||||
sql_host = 127.0.0.1
|
||||
sql_user = bbs
|
||||
sql_pass = bbs
|
||||
sql_db = bbs
|
||||
sql_port = 3306
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 1, MAX(tid) FROM bbs_forum_thread
|
||||
sql_query = SELECT t.tid as id,t.tid,t.subject,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
|
||||
FROM bbs_forum_thread AS t WHERE t.tid>=$start AND t.tid<=$end
|
||||
sql_query_range = SELECT (SELECT MIN(tid) FROM bbs_forum_thread),maxid FROM bbs_common_sphinxcounter WHERE indexid=1
|
||||
|
||||
sql_range_step = 5000
|
||||
sql_attr_uint = tid
|
||||
|
||||
sql_attr_uint = digest
|
||||
sql_attr_uint = displayorder
|
||||
sql_attr_uint = authorid
|
||||
sql_attr_uint = special
|
||||
sql_attr_timestamp =lastpost
|
||||
}
|
||||
|
||||
index pre_forum_thread
|
||||
{
|
||||
source = pre_forum_thread
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/index
|
||||
|
||||
min_word_len = 2
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
}
|
||||
|
||||
|
||||
# threads_minute
|
||||
source pre_forum_thread_minute : pre_forum_thread
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_range = SELECT maxid-1,(SELECT MAX(tid) FROM bbs_forum_thread) FROM bbs_common_sphinxcounter WHERE indexid=1
|
||||
}
|
||||
|
||||
# threads_minute
|
||||
index pre_forum_thread_minute : pre_forum_thread
|
||||
{
|
||||
source = pre_forum_thread_minute
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_thread_minute
|
||||
}
|
||||
|
||||
#posts
|
||||
source pre_forum_post : pre_forum_thread
|
||||
{
|
||||
type = mysql
|
||||
sql_query_pre =
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 2, MAX(pid) FROM bbs_forum_post
|
||||
sql_query = SELECT p.pid AS id,p.tid,p.subject,p.message,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
|
||||
FROM bbs_forum_post AS p LEFT JOIN bbs_forum_thread AS t USING(tid) where p.pid >=$start and p.pid <=$end \
|
||||
AND p.first=1
|
||||
sql_query_range = SELECT (SELECT MIN(pid) FROM bbs_forum_post),maxid FROM bbs_common_sphinxcounter WHERE indexid=2
|
||||
sql_range_step = 5000
|
||||
sql_attr_uint = tid
|
||||
sql_attr_uint = digest
|
||||
sql_attr_uint= displayorder
|
||||
sql_attr_uint = authorid
|
||||
sql_attr_uint = special
|
||||
sql_attr_timestamp = lastpost
|
||||
}
|
||||
|
||||
#posts
|
||||
index pre_forum_post
|
||||
{
|
||||
source = pre_forum_post
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post
|
||||
|
||||
min_word_len = 2
|
||||
html_strip = 1
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
}
|
||||
|
||||
#pre_forum_post_minute
|
||||
source pre_forum_post_minute : pre_forum_post
|
||||
{
|
||||
sql_query_pre = SET NAMES UTF8
|
||||
sql_query_pre = SET SESSION query_cache_type=OFF
|
||||
sql_query_range = SELECT maxid-1,(SELECT MAX(pid) FROM bbs_forum_post) FROM bbs_common_sphinxcounter WHERE indexid=2
|
||||
}
|
||||
|
||||
#pre_forum_post_minute
|
||||
index pre_forum_post_minute : pre_forum_post
|
||||
{
|
||||
source = pre_forum_thread
|
||||
path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post_minute
|
||||
}
|
||||
|
||||
+19
-18
@@ -25,7 +25,7 @@ class App():
|
||||
|
||||
self.__host_dir = self.getServerDir() + '/host'
|
||||
if not os.path.exists(self.__host_dir):
|
||||
os.makedirs(self.__host_dir)
|
||||
mw.execShell('mkdir -p ' + self.__host_dir)
|
||||
|
||||
def getPluginName(self):
|
||||
return 'webssh'
|
||||
@@ -145,24 +145,25 @@ class App():
|
||||
|
||||
def get_server_list(self):
|
||||
host_list = []
|
||||
for name in os.listdir(self.__host_dir):
|
||||
info_file = self.__host_dir + '/' + name + '/info.json'
|
||||
if not os.path.exists(info_file):
|
||||
continue
|
||||
try:
|
||||
info_tmp = self.getSshInfo(info_file)
|
||||
host_info = {}
|
||||
host_info['host'] = name
|
||||
host_info['port'] = info_tmp['port']
|
||||
host_info['ps'] = info_tmp['ps']
|
||||
# host_info['sort'] = int(info_tmp['sort'])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# if os.path.exists(info_file):
|
||||
# os.remove(info_file)
|
||||
# continue
|
||||
if os.path.exists(self.__host_dir):
|
||||
for name in os.listdir(self.__host_dir):
|
||||
info_file = self.__host_dir + '/' + name + '/info.json'
|
||||
if not os.path.exists(info_file):
|
||||
continue
|
||||
try:
|
||||
info_tmp = self.getSshInfo(info_file)
|
||||
host_info = {}
|
||||
host_info['host'] = name
|
||||
host_info['port'] = info_tmp['port']
|
||||
host_info['ps'] = info_tmp['ps']
|
||||
# host_info['sort'] = int(info_tmp['sort'])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# if os.path.exists(info_file):
|
||||
# os.remove(info_file)
|
||||
# continue
|
||||
|
||||
host_list.append(host_info)
|
||||
host_list.append(host_info)
|
||||
|
||||
host_list = sorted(host_list, key=lambda x: x['host'], reverse=False)
|
||||
return mw.returnJson(True, 'ok!', host_list)
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
"css_path":"menu/index.css",
|
||||
"js_path":"js/webssh.js"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag":"global_static",
|
||||
"global_static": {
|
||||
"title":"终端管理",
|
||||
"name":"webssh",
|
||||
"css_path":"menu/ico.css"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id":3,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
/* menu start */
|
||||
.menu .menu_plugin_webssh {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMBJREFUeNpiYKAQMM6cOVMASBuQozk9Pf0AC5AuAOJ6cgwAWt7IhMQvRKIfAPEEYgxhQWL3o9EFpBgwAeifQhKdD7YI5oWPUMEEmAQR4COyATBwAIgdgIacB2IFYkxhQouWB0BsCA3E86QGIsxvDSBXgGIDSxr5ALTgAk4XADWAQt4fiB2BChcAaQVoGoHheLwuAGqagBz/UNsciQ4DEgE/zAUfQM4DOt+eRANAYTMRZADIrxfIdMUFSnMzA0CAAQD0hjqnYxWD2gAAAABJRU5ErkJggg==");
|
||||
}
|
||||
|
||||
.menu .current .menu_plugin_webssh:hover {
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQXAJ6ipUFITySRPIiMkDFRQuXm5jJKQy1kQCGeOzBXQSl3PiWLPVhfZSxrQCpxP9na2yeEPTREQ8LExmRqb5OXm/Hx8TU9RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjMyQjYwMTU3OTA2QTExRUJCN0NFQUUwQjRDMzM4RDJDIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjMyQjYwMTU4OTA2QTExRUJCN0NFQUUwQjRDMzM4RDJDIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MzJCNjAxNTU5MDZBMTFFQkI3Q0VBRTBCNEMzMzhEMkMiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MzJCNjAxNTY5MDZBMTFFQkI3Q0VBRTBCNEMzMzhEMkMiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4B//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAAAh+QQFMgAXACwAAAAAEAAQAAAFU6AljmRpBVOqrqtFVXAsy9Q7VMMDzHHN/5UawGQC1CiWg4IoOiINAoGB6BxBENSjyIE4oFKMprYhIFgYkvTQpWWOqm6RcVBI2+/2AuXL6k8CcSYhACH5BAUyABcALAcACQAFAAIAAAUIYJSMBLGcSggAIfkEBTIAFwAsBwAJAAUAAgAABQhgMI0MI51ACAAh+QQFMgAXACwHAAkABQACAAAFCGCUjASxnEoIADs=");
|
||||
}
|
||||
/* menu end */
|
||||
@@ -1,15 +1,4 @@
|
||||
|
||||
/* menu start */
|
||||
.menu .menu_plugin_webssh {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAMBJREFUeNpiYKAQMM6cOVMASBuQozk9Pf0AC5AuAOJ6cgwAWt7IhMQvRKIfAPEEYgxhQWL3o9EFpBgwAeifQhKdD7YI5oWPUMEEmAQR4COyATBwAIgdgIacB2IFYkxhQouWB0BsCA3E86QGIsxvDSBXgGIDSxr5ALTgAk4XADWAQt4fiB2BChcAaQVoGoHheLwuAGqagBz/UNsciQ4DEgE/zAUfQM4DOt+eRANAYTMRZADIrxfIdMUFSnMzA0CAAQD0hjqnYxWD2gAAAABJRU5ErkJggg==");
|
||||
}
|
||||
|
||||
.menu .current .menu_plugin_webssh:hover {
|
||||
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQXAJ6ipUFITySRPIiMkDFRQuXm5jJKQy1kQCGeOzBXQSl3PiWLPVhfZSxrQCpxP9na2yeEPTREQ8LExmRqb5OXm/Hx8TU9RAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjMyQjYwMTU3OTA2QTExRUJCN0NFQUUwQjRDMzM4RDJDIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjMyQjYwMTU4OTA2QTExRUJCN0NFQUUwQjRDMzM4RDJDIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MzJCNjAxNTU5MDZBMTFFQkI3Q0VBRTBCNEMzMzhEMkMiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MzJCNjAxNTY5MDZBMTFFQkI3Q0VBRTBCNEMzMzhEMkMiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4B//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAAAh+QQFMgAXACwAAAAAEAAQAAAFU6AljmRpBVOqrqtFVXAsy9Q7VMMDzHHN/5UawGQC1CiWg4IoOiINAoGB6BxBENSjyIE4oFKMprYhIFgYkvTQpWWOqm6RcVBI2+/2AuXL6k8CcSYhACH5BAUyABcALAcACQAFAAIAAAUIYJSMBLGcSggAIfkEBTIAFwAsBwAJAAUAAgAABQhgMI0MI51ACAAh+QQFMgAXACwHAAkABQACAAAFCGCUjASxnEoIADs=");
|
||||
}
|
||||
/* menu end */
|
||||
|
||||
|
||||
.xterm{
|
||||
position: inherit;
|
||||
}
|
||||
|
||||
@@ -191,8 +191,10 @@ def pSqliteDb(dbname='web_logs', site_name='unset', name="logs"):
|
||||
conn = mw.M(dbname).dbPos(db_dir, name)
|
||||
|
||||
conn.execute("PRAGMA synchronous = 0")
|
||||
conn.execute("PRAGMA page_size = 4096")
|
||||
conn.execute("PRAGMA cache_size = 8000")
|
||||
conn.execute("PRAGMA page_size = 32768")
|
||||
conn.execute("PRAGMA journal_mode = wal")
|
||||
conn.execute("PRAGMA journal_size_limit = 1073741824")
|
||||
return conn
|
||||
|
||||
|
||||
@@ -263,6 +265,8 @@ def initDreplace():
|
||||
loadLuaSiteFile()
|
||||
loadDebugLogFile()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
mw.execShell("chown -R www:www " + getServerDir())
|
||||
return 'ok'
|
||||
|
||||
|
||||
@@ -277,9 +281,6 @@ def start():
|
||||
import tool_task
|
||||
tool_task.createBgTask()
|
||||
|
||||
if not mw.isAppleSystem():
|
||||
mw.execShell("chown -R www:www " + getServerDir())
|
||||
|
||||
# issues:326
|
||||
luaRestart()
|
||||
return 'ok'
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
{
|
||||
"sort": 7,
|
||||
"hook":[
|
||||
{
|
||||
"tag":"site_cb",
|
||||
"site_cb": {
|
||||
"title":"网站统计",
|
||||
"name":"webstats",
|
||||
"add":{"func":"reload"},
|
||||
"update":{"func":"reload"},
|
||||
"delete":{"func":"reload"}
|
||||
}
|
||||
}
|
||||
],
|
||||
"sort": "7",
|
||||
"ps": "网站统计报表",
|
||||
"name": "webstats",
|
||||
"title": "网站统计",
|
||||
"shell": "install.sh",
|
||||
"versions":["0.2.4"],
|
||||
"versions":["0.2.5"],
|
||||
"tip": "soft",
|
||||
"install_pre_inspection":true,
|
||||
"checks": "server/webstats",
|
||||
|
||||
@@ -1084,6 +1084,7 @@ end
|
||||
function _M.get_client_ip(self)
|
||||
local client_ip = "unknown"
|
||||
local cdn = auto_config['cdn']
|
||||
local request_header = ngx.req.get_headers()
|
||||
if cdn == true then
|
||||
for _,v in ipairs(auto_config['cdn_headers']) do
|
||||
if request_header[v] ~= nil and request_header[v] ~= "" then
|
||||
|
||||
+8
-7
@@ -179,7 +179,6 @@ def requestCheck():
|
||||
|
||||
|
||||
def isLogined():
|
||||
# print('isLogined', session)
|
||||
if 'login' in session and 'username' in session and session['login'] == True:
|
||||
userInfo = mw.M('users').where(
|
||||
"id=?", (1,)).field('id,username,password').find()
|
||||
@@ -445,7 +444,6 @@ def login_temp_user(token):
|
||||
|
||||
@app.route('/api/<reqClass>/<reqAction>', methods=['POST', 'GET'])
|
||||
def api(reqClass=None, reqAction=None, reqData=None):
|
||||
|
||||
comReturn = common.local()
|
||||
if comReturn:
|
||||
return comReturn
|
||||
@@ -458,15 +456,18 @@ def api(reqClass=None, reqAction=None, reqData=None):
|
||||
request_time = request.form.get('request_time', '')
|
||||
request_token = request.form.get('request_token', '')
|
||||
request_ip = request.remote_addr
|
||||
request_ip = request_ip.replace('::ffff:', '')
|
||||
|
||||
token_md5 = mw.md5(str(request_time) + mw.md5(data['token_crypt']))
|
||||
# print(request_time, request_token)
|
||||
if not mw.inArray(data['limit_addr'], request_ip):
|
||||
return mw.returnJson(False, 'IP校验失败,您的访问IP为[' + request_ip + ']')
|
||||
|
||||
local_token = mw.deCrypt(data['token'], data['token_crypt'])
|
||||
token_md5 = mw.md5(str(request_time) + mw.md5(local_token))
|
||||
|
||||
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, '请指定请求方法类')
|
||||
|
||||
@@ -477,7 +478,7 @@ def api(reqClass=None, reqAction=None, reqData=None):
|
||||
'plugins_api', 'system_api', 'site_api', 'task_api')
|
||||
className = reqClass + '_api'
|
||||
if not className in classFile:
|
||||
return "external api request error"
|
||||
return mw.returnJson(False, 'external api request error')
|
||||
|
||||
eval_str = "__import__('" + className + "')." + className + '()'
|
||||
newInstance = eval(eval_str)
|
||||
|
||||
@@ -1110,7 +1110,7 @@ function reName(type, fileName) {
|
||||
</div>',
|
||||
success:function(){
|
||||
$("#newFileName").focus().keyup(function(e){
|
||||
if(e.keyCode == 13) $("#ReNameBtn").click();
|
||||
if(e.keyCode == 13) $(".layui-layer-btn0").click();
|
||||
});
|
||||
},
|
||||
yes:function(){
|
||||
|
||||
@@ -648,7 +648,11 @@ function onlineEditFile(k, f) {
|
||||
"Ctrl-S": function() {
|
||||
$("#textBody").text(t.getValue());
|
||||
onlineEditFile(2, f)
|
||||
}
|
||||
},
|
||||
"Cmd-S":function() {
|
||||
$("#textBody").text(t.getValue());
|
||||
onlineEditFile(2, f)
|
||||
},
|
||||
},
|
||||
mode: d,
|
||||
lineNumbers: true,
|
||||
|
||||
@@ -2,35 +2,42 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>{{data['title']}}</title>
|
||||
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
|
||||
<link href="/static/bootstrap-3.3.5/css/bootstrap.min.css?v={{config.version}}" rel="stylesheet">
|
||||
<link href="/static/css/site.css?v={{config.version}}" rel="stylesheet">
|
||||
<link href="/static/codemirror/lib/codemirror.css?v={{config.version}}" rel="stylesheet">
|
||||
<script src="/static/language/Simplified_Chinese/lan.js?v={{config.version}}"></script>
|
||||
<!--[if lte IE 9]>
|
||||
<script src="/static/js/requestAnimationFrame.js"></script>
|
||||
<![endif]-->
|
||||
<!-- 统计一下用户量,让我的开发更有激情 -->
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FC74BB2RGD"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'G-FC74BB2RGD');
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>{{data['title']}}</title>
|
||||
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
|
||||
<link href="/static/bootstrap-3.3.5/css/bootstrap.min.css?v={{config.version}}" rel="stylesheet">
|
||||
<link href="/static/css/site.css?v={{config.version}}" rel="stylesheet">
|
||||
<link href="/static/codemirror/lib/codemirror.css?v={{config.version}}" rel="stylesheet">
|
||||
<script src="/static/language/Simplified_Chinese/lan.js?v={{config.version}}"></script>
|
||||
<!--[if lte IE 9]>
|
||||
<script src="/static/js/requestAnimationFrame.js"></script>
|
||||
<![endif]-->
|
||||
<!-- 统计一下用户量,让我的开发更有激情 -->
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-FC74BB2RGD"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'G-FC74BB2RGD');
|
||||
</script>
|
||||
|
||||
|
||||
{% for menu in data['hook_menu'] %}
|
||||
{% if menu['js_path'] %}
|
||||
<!-- 加载插件css -->
|
||||
<link href="/plugins/file?name={{menu['name']}}&v={{config.version}}&f={{menu['css_path']}}" rel="stylesheet" />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for menu in data['hook_menu'] %}
|
||||
{% if menu['css_path'] and data['hook_tag'] == menu['name'] %}
|
||||
<!-- 加载插件css -->
|
||||
<link href="/plugins/file?name={{menu['name']}}&v={{config.version}}&f={{menu['css_path']}}" rel="stylesheet" />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<!-- 全局静态HOOK -->
|
||||
{% for menu in data['hook_global_static'] %}
|
||||
{% if menu['css_path'] %}
|
||||
<link href="/plugins/file?name={{menu['name']}}&v={{config.version}}&f={{menu['css_path']}}" rel="stylesheet" />
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -85,9 +92,9 @@
|
||||
<div class="footer bgw">mdserver-web ©2018-∞ Linux面板 (<a class="btlink" target="_blank" href="//github.com/midoks/mdserver-web">源码</a>) <span style="margin-left:5px;">/</span>
|
||||
<a class="btlink" style="margin-left:5px;" href="//github.com/midoks/mdserver-web/wiki" target="_blank">WIKI</a><span style="margin-left:5px;">/</span>
|
||||
<a class='btlink panel_ad_list_mode' style="margin-left:5px;">AD</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -158,8 +165,14 @@ if (thisPath.indexOf('?')>-1){
|
||||
<script src="/static/laydate/laydate.js?v={{config.version}}"></script>
|
||||
|
||||
{% for menu in data['hook_menu'] %}
|
||||
{% if menu['js_path'] and data['hook_tag'] == menu['name'] %}
|
||||
<script src="/plugins/file?name={{menu['name']}}&f={{menu['js_path']}}&v={{config.version}}"></script>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<!-- 全局静态HOOK -->
|
||||
{% for menu in data['hook_global_static'] %}
|
||||
{% if menu['js_path'] %}
|
||||
<!-- 加载插件js -->
|
||||
<script src="/plugins/file?name={{menu['name']}}&f={{menu['js_path']}}&v={{config.version}}"></script>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
+29
-15
@@ -5,6 +5,7 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
if sys.platform != 'darwin':
|
||||
os.chdir('/www/server/mdserver-web')
|
||||
@@ -50,7 +51,6 @@ class backupTools:
|
||||
mw.execShell(cmd)
|
||||
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
|
||||
print(filename)
|
||||
if not os.path.exists(filename):
|
||||
log = "网站[" + name + "]备份失败!"
|
||||
@@ -83,6 +83,27 @@ class backupTools:
|
||||
if num < 1:
|
||||
break
|
||||
|
||||
def getConf(self, mtype='mysql'):
|
||||
path = mw.getServerDir() + '/' + mtype + '/etc/my.cnf'
|
||||
return path
|
||||
|
||||
# 数据库密码处理
|
||||
def mypass(self, act, root):
|
||||
conf_file = self.getConf('mysql')
|
||||
mw.execShell("sed -i '/user=root/d' {}".format(conf_file))
|
||||
mw.execShell("sed -i '/password=/d' {}".format(conf_file))
|
||||
if act:
|
||||
mycnf = mw.readFile(conf_file)
|
||||
src_dump = "[mysqldump]\n"
|
||||
sub_dump = src_dump + "user=root\npassword=\"{}\"\n".format(root)
|
||||
if not mycnf:
|
||||
return False
|
||||
mycnf = mycnf.replace(src_dump, sub_dump)
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(conf_file, mycnf)
|
||||
return True
|
||||
return True
|
||||
|
||||
def backupDatabase(self, name, count):
|
||||
db_path = mw.getServerDir() + '/mysql'
|
||||
db_name = 'mysql'
|
||||
@@ -104,17 +125,11 @@ class backupTools:
|
||||
filename = backup_path + "/db_" + name + "_" + \
|
||||
time.strftime('%Y%m%d_%H%M%S', time.localtime()) + ".sql.gz"
|
||||
|
||||
import re
|
||||
mysql_root = mw.M('config').dbPos(db_path, db_name).where(
|
||||
"id=?", (1,)).getField('mysql_root')
|
||||
|
||||
mycnf = mw.readFile(db_path + '/etc/my.cnf')
|
||||
rep = "\[mysqldump\]\nuser=root"
|
||||
sea = "[mysqldump]\n"
|
||||
subStr = sea + "user=root\npassword=" + mysql_root + "\n"
|
||||
mycnf = mycnf.replace(sea, subStr)
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
|
||||
my_cnf = self.getConf('mysql')
|
||||
self.mypass(True, mysql_root)
|
||||
|
||||
# mw.execShell(db_path + "/bin/mysqldump --opt --default-character-set=utf8 " +
|
||||
# name + " | gzip > " + filename)
|
||||
@@ -125,8 +140,10 @@ class backupTools:
|
||||
# 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)
|
||||
cmd = db_path + "/bin/mysqldump --defaults-file=" + my_cnf + " --force --opt --default-character-set=utf8 " + \
|
||||
name + " | gzip > " + filename
|
||||
# print(cmd)
|
||||
mw.execShell(cmd)
|
||||
|
||||
if not os.path.exists(filename):
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
@@ -136,10 +153,7 @@ class backupTools:
|
||||
"----------------------------------------------------------------------------")
|
||||
return
|
||||
|
||||
mycnf = mw.readFile(db_path + '/etc/my.cnf')
|
||||
mycnf = mycnf.replace(subStr, sea)
|
||||
if len(mycnf) > 100:
|
||||
mw.writeFile(db_path + '/etc/my.cnf', mycnf)
|
||||
self.mypass(False, mysql_root)
|
||||
|
||||
endDate = time.strftime('%Y/%m/%d %X', time.localtime())
|
||||
outTime = time.time() - startTime
|
||||
|
||||
+24
-12
@@ -196,32 +196,44 @@ error_logs()
|
||||
|
||||
mw_update()
|
||||
{
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
else
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
|
||||
curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/master/scripts/install.sh | bash
|
||||
fi
|
||||
}
|
||||
|
||||
mw_update_dev()
|
||||
{
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl --insecure -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
else
|
||||
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/update_dev.sh | bash
|
||||
curl --insecure -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/update_dev.sh | bash
|
||||
fi
|
||||
cd /www/server/mdserver-web
|
||||
}
|
||||
|
||||
mw_mirror()
|
||||
{
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
fi
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
bash <(curl --insecure -sSL https://raw.githubusercontent.com/midoks/change-linux-mirrors/main/change-mirrors.sh)
|
||||
else
|
||||
bash <(curl -sSL https://raw.githubusercontent.com/midoks/change-linux-mirrors/main/change-mirrors.sh)
|
||||
bash <(curl --insecure -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
|
||||
fi
|
||||
cd /www/server/mdserver-web
|
||||
}
|
||||
|
||||
+27
-9
@@ -56,6 +56,16 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# cn=$(curl --insecure -fsSL -m 10 https://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://ghproxy.com/"
|
||||
fi
|
||||
|
||||
if [ $OSNAME != "macos" ];then
|
||||
if id www &> /dev/null ;then
|
||||
echo ""
|
||||
@@ -71,11 +81,8 @@ if [ $OSNAME != "macos" ];then
|
||||
mkdir -p /www/backup/site
|
||||
|
||||
# https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/install.sh
|
||||
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
|
||||
if [ ! -d /www/server/mdserver-web ];then
|
||||
if [ ! -z "$cn" ];then
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -sSLo /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip
|
||||
else
|
||||
curl -sSLo /tmp/master.zip https://codeload.github.com/midoks/mdserver-web/zip/master
|
||||
@@ -89,8 +96,8 @@ if [ $OSNAME != "macos" ];then
|
||||
|
||||
# install acme.sh
|
||||
if [ ! -d /root/.acme.sh ];then
|
||||
if [ ! -z "$cn" ];then
|
||||
curl -sSL -o /tmp/acme.tar.gz https://ghproxy.com/github.com/acmesh-official/acme.sh/archive/master.tar.gz
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -sSLo /tmp/acme.tar.gz https://gitee.com/neilpang/acme.sh/repository/archive/master.tar.gz
|
||||
tar xvzf /tmp/acme.tar.gz -C /tmp
|
||||
cd /tmp/acme.sh-master
|
||||
bash acme.sh install
|
||||
@@ -103,10 +110,21 @@ if [ $OSNAME != "macos" ];then
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "use system version: ${OSNAME}"
|
||||
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
|
||||
if [ "${OSNAME}" == "macos" ];then
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/install/macos.sh | bash
|
||||
else
|
||||
curl -fsSL ${HTTP_PREFIX}https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install/macos.sh | bash
|
||||
fi
|
||||
else
|
||||
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
|
||||
fi
|
||||
|
||||
if [ "${OSNAME}" == "macos" ];then
|
||||
echo "macos end"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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}'`
|
||||
|
||||
+18
-18
@@ -46,31 +46,31 @@ apt install -y wget curl lsof unzip tar cron expect locate
|
||||
apt install -y python3-pip python3-dev python3-venv
|
||||
|
||||
|
||||
# if [ -f /usr/sbin/ufw ];then
|
||||
# if [ "$SSH_PORT" != "" ];then
|
||||
# ufw allow $SSH_PORT/tcp
|
||||
# else
|
||||
# ufw allow 22/tcp
|
||||
# fi
|
||||
if [ -f /usr/sbin/ufw ];then
|
||||
# look
|
||||
# ufw status
|
||||
ufw enable
|
||||
if [ "$SSH_PORT" != "" ];then
|
||||
ufw allow $SSH_PORT/tcp
|
||||
else
|
||||
ufw allow 22/tcp
|
||||
fi
|
||||
|
||||
# ufw allow 80/tcp
|
||||
# ufw allow 443/tcp
|
||||
# ufw allow 888/tcp
|
||||
# fi
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow 888/tcp
|
||||
fi
|
||||
|
||||
# if [ -f /usr/sbin/ufw ];then
|
||||
# ufw disable
|
||||
# fi
|
||||
|
||||
if [ ! -f /usr/sbin/firewalld ];then
|
||||
if [ ! -f /usr/sbin/ufw ];then
|
||||
# look
|
||||
# firewall-cmd --list-all
|
||||
# apt remove -y firewalld
|
||||
|
||||
apt install -y firewalld
|
||||
systemctl enable firewalld
|
||||
#取消服务锁定
|
||||
systemctl unmask firewalld
|
||||
systemctl start firewalld
|
||||
|
||||
|
||||
if [ "$SSH_PORT" != "" ];then
|
||||
firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp
|
||||
@@ -81,13 +81,13 @@ if [ ! -f /usr/sbin/firewalld ];then
|
||||
firewall-cmd --permanent --zone=public --add-port=443/tcp
|
||||
firewall-cmd --permanent --zone=public --add-port=888/tcp
|
||||
|
||||
systemctl start firewalld
|
||||
|
||||
# fix:debian10 firewalld faq
|
||||
# https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled/fang-huo-qiang#debian-10-firewalld-0.6.3-error-commandfailed-usrsbinip6tablesrestorewn-failed-ip6tablesrestore-v1.8
|
||||
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
|
||||
|
||||
firewall-cmd --reload
|
||||
#安装时不开启
|
||||
systemctl stop firewalld
|
||||
fi
|
||||
|
||||
#fix zlib1g-dev fail
|
||||
|
||||
@@ -36,8 +36,6 @@ if [ ! -d $DEV/server/lib ]; then
|
||||
cd $DEV/server/mdserver-web/scripts && bash lib.sh
|
||||
fi
|
||||
|
||||
pip3 install mysqlclient
|
||||
|
||||
chmod 755 $DEV/server/mdserver-web/data
|
||||
if [ -f $DEV/server/mdserver-web/bin/activate ];then
|
||||
cd $DEV/server/mdserver-web && python3 -m venv $DEV/server/mdserver-web
|
||||
@@ -47,8 +45,6 @@ else
|
||||
cd $DEV/server/mdserver-web && pip3 install -r $DEV/server/mdserver-web/requirements.txt
|
||||
fi
|
||||
|
||||
pip3 install mysqlclient
|
||||
|
||||
|
||||
cd $DEV/server/mdserver-web && ./cli.sh start
|
||||
cd $DEV/server/mdserver-web && ./cli.sh stop
|
||||
|
||||
@@ -83,9 +83,6 @@ if [ ! -f /usr/sbin/firewalld ];then
|
||||
#取消服务锁定
|
||||
systemctl unmask firewalld
|
||||
systemctl start firewalld
|
||||
|
||||
sed -i 's#AllowZoneDrifting=yes#AllowZoneDrifting=no#g' /etc/firewalld/firewalld.conf
|
||||
firewall-cmd --reload
|
||||
|
||||
# look
|
||||
# firewall-cmd --list-all
|
||||
@@ -102,7 +99,7 @@ if [ ! -f /usr/sbin/firewalld ];then
|
||||
# firewall-cmd --permanent --zone=public --add-port=3306/tcp
|
||||
# firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp
|
||||
|
||||
# sed -i 's#AllowZoneDrifting=yes#AllowZoneDrifting=no#g' /etc/firewalld/firewalld.conf
|
||||
sed -i 's#AllowZoneDrifting=yes#AllowZoneDrifting=no#g' /etc/firewalld/firewalld.conf
|
||||
firewall-cmd --reload
|
||||
|
||||
#安装时不开启
|
||||
@@ -134,11 +131,14 @@ if [ $VERSION_ID -ge 8 ];then
|
||||
gmp-devel kernel-devel libXpm-devel libaio-devel libcap libcurl libcurl-devel libevent libevent-devel \
|
||||
libicu-devel libidn libidn-devel libmcrypt libmcrypt-devel libmemcached libmemcached-devel \
|
||||
libpng libpng-devel libstdc++.so.6 libtirpc libtirpc-devel libtool libtool-libs libwebp libwebp-devel \
|
||||
libxml2 libxml2-devel libxslt libxslt-devel lsof make mysql-devel ncurses ncurses-devel net-tools \
|
||||
libxml2 libxml2-devel libxslt libxslt-devel libarchive lsof make mysql-devel ncurses ncurses-devel net-tools \
|
||||
oniguruma oniguruma-devel patch pcre pcre-devel perl perl-Data-Dumper perl-devel procps psmisc python3-devel \
|
||||
readline-devel rpcgen sqlite-devel tar unzip vim-minimal wget zip zlib zlib-devel ;
|
||||
do
|
||||
dnf $REPOS install -y $rpms;
|
||||
if [ "$?" != "0" ];then
|
||||
dnf install -y $rpms;
|
||||
fi
|
||||
done
|
||||
else
|
||||
# CentOS 7
|
||||
|
||||
+20
-24
@@ -27,31 +27,26 @@ localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
|
||||
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
|
||||
echo "SSH PORT:${SSH_PORT}"
|
||||
|
||||
# if [ -f /usr/sbin/ufw ];then
|
||||
if [ -f /usr/sbin/ufw ];then
|
||||
# look
|
||||
# ufw status
|
||||
ufw enable
|
||||
|
||||
# # look
|
||||
# # ufw status
|
||||
# ufw enable
|
||||
if [ "$SSH_PORT" != "" ];then
|
||||
ufw allow $SSH_PORT/tcp
|
||||
else
|
||||
ufw allow 22/tcp
|
||||
fi
|
||||
|
||||
# if [ "$SSH_PORT" != "" ];then
|
||||
# ufw allow $SSH_PORT/tcp
|
||||
# else
|
||||
# ufw allow 22/tcp
|
||||
# fi
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow 888/tcp
|
||||
fi
|
||||
|
||||
# ufw allow 80/tcp
|
||||
# ufw allow 443/tcp
|
||||
# ufw allow 888/tcp
|
||||
# fi
|
||||
|
||||
# if [ -f /usr/sbin/ufw ];then
|
||||
# ufw disable
|
||||
# fi
|
||||
|
||||
if [ ! -f /usr/sbin/firewalld ];then
|
||||
if [ ! -f /usr/sbin/ufw ];then
|
||||
apt install -y firewalld
|
||||
systemctl enable firewalld
|
||||
systemctl start firewalld
|
||||
|
||||
|
||||
if [ "$SSH_PORT" != "" ];then
|
||||
firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp
|
||||
@@ -63,17 +58,18 @@ if [ ! -f /usr/sbin/firewalld ];then
|
||||
firewall-cmd --permanent --zone=public --add-port=443/tcp
|
||||
firewall-cmd --permanent --zone=public --add-port=888/tcp
|
||||
|
||||
systemctl start firewalld
|
||||
|
||||
# fix:debian10 firewalld faq
|
||||
# https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled/fang-huo-qiang#debian-10-firewalld-0.6.3-error-commandfailed-usrsbinip6tablesrestorewn-failed-ip6tablesrestore-v1.8
|
||||
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
|
||||
|
||||
firewall-cmd --reload
|
||||
|
||||
# #安装时不开启
|
||||
# systemctl stop firewalld
|
||||
fi
|
||||
|
||||
#安装时不开启
|
||||
systemctl stop firewalld
|
||||
|
||||
|
||||
apt install -y devscripts
|
||||
apt install -y net-tools
|
||||
apt install -y python3-dev
|
||||
|
||||
+40
-5
@@ -5,7 +5,7 @@ export PATH
|
||||
is64bit=`getconf LONG_BIT`
|
||||
|
||||
echo -e "您正在安装的是\033[31mmdserver-web测试版\033[0m,非开发测试用途请使用正式版 install.sh !"
|
||||
echo -e "You are installing\033[31mmdserver-web dev version\033[0m, normally use install.sh for production.\n"
|
||||
echo -e "You are installing\033[31m mdserver-web dev version\033[0m, normally use install.sh for production.\n"
|
||||
sleep 1
|
||||
|
||||
{
|
||||
@@ -60,6 +60,20 @@ else
|
||||
fi
|
||||
|
||||
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://ghproxy.com/"
|
||||
fi
|
||||
|
||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
# HTTP_PREFIX="https://"
|
||||
# if [ ! -z "$cn" ];then
|
||||
# HTTP_PREFIX="https://ghproxy.com/"
|
||||
# fi
|
||||
|
||||
if [ $OSNAME != "macos" ];then
|
||||
mkdir -p /www/server
|
||||
mkdir -p /www/wwwroot
|
||||
@@ -68,7 +82,13 @@ if [ $OSNAME != "macos" ];then
|
||||
mkdir -p /www/backup/site
|
||||
|
||||
if [ ! -d /www/server/mdserver-web ];then
|
||||
curl -sSLo /tmp/dev.zip https://github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
|
||||
|
||||
if [ "$LOCAL_ADDR" == "common" ];then
|
||||
curl -sSLo /tmp/dev.zip ${HTTP_PREFIX}github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
|
||||
else
|
||||
curl -sSLo /tmp/dev.zip https://gitee.com/midoks/mdserver-web/repository/archive/dev.zip
|
||||
fi
|
||||
|
||||
cd /tmp && unzip /tmp/dev.zip
|
||||
mv -f /tmp/mdserver-web-dev /www/server/mdserver-web
|
||||
rm -rf /tmp/dev.zip
|
||||
@@ -77,8 +97,9 @@ if [ $OSNAME != "macos" ];then
|
||||
|
||||
# install acme.sh
|
||||
if [ ! -d /root/.acme.sh ];then
|
||||
if [ ! -z "$cn" ];then
|
||||
curl -sSL -o /tmp/acme.tar.gz https://ghproxy.com/github.com/acmesh-official/acme.sh/archive/master.tar.gz
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
# curl -sSL -o /tmp/acme.tar.gz ${HTTP_PREFIX}github.com/acmesh-official/acme.sh/archive/master.tar.gz
|
||||
curl -sSLo /tmp/acme.tar.gz https://gitee.com/neilpang/acme.sh/repository/archive/master.tar.gz
|
||||
tar xvzf /tmp/acme.tar.gz -C /tmp
|
||||
cd /tmp/acme.sh-master
|
||||
bash acme.sh install
|
||||
@@ -92,7 +113,21 @@ if [ $OSNAME != "macos" ];then
|
||||
fi
|
||||
|
||||
echo "use system version: ${OSNAME}"
|
||||
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
|
||||
|
||||
if [ "${OSNAME}" == "macos" ];then
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -fsSL https://gitee.com/midoks/mdserver-web/raw/dev/scripts/install/macos.sh | bash
|
||||
else
|
||||
curl -fsSL ${HTTP_PREFIX}https://raw.githubusercontent.com/midoks/mdserver-web/dev/scripts/install/macos.sh | bash
|
||||
fi
|
||||
else
|
||||
cd /www/server/mdserver-web && bash scripts/install/${OSNAME}.sh
|
||||
fi
|
||||
|
||||
if [ "${OSNAME}" == "macos" ];then
|
||||
echo "macos end"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
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}'`
|
||||
|
||||
+10
-2
@@ -47,9 +47,17 @@ else
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://ghproxy.com/"
|
||||
fi
|
||||
|
||||
PIPSRC="https://pypi.python.org/simple"
|
||||
if [ ! -z "$cn" ];then
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
PIPSRC="https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
fi
|
||||
|
||||
|
||||
+11
-2
@@ -55,8 +55,17 @@ else
|
||||
fi
|
||||
|
||||
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://ghproxy.com/"
|
||||
fi
|
||||
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -sSLo /tmp/master.zip https://gitee.com/midoks/mdserver-web/repository/archive/master.zip
|
||||
else
|
||||
curl -sSLo /tmp/master.zip https://codeload.github.com/midoks/mdserver-web/zip/master
|
||||
|
||||
+10
-2
@@ -54,8 +54,16 @@ else
|
||||
OSNAME='unknow'
|
||||
fi
|
||||
|
||||
cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
if [ ! -z "$cn" ];then
|
||||
# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
|
||||
HTTP_PREFIX="https://"
|
||||
LOCAL_ADDR=common
|
||||
ping -c 1 github.com > /dev/null 2>&1
|
||||
if [ "$?" != "0" ];then
|
||||
LOCAL_ADDR=cn
|
||||
HTTP_PREFIX="https://ghproxy.com/"
|
||||
fi
|
||||
|
||||
if [ "$LOCAL_ADDR" != "common" ];then
|
||||
curl -sSLo /tmp/dev.zip https://gitee.com/midoks/mdserver-web/repository/archive/dev.zip
|
||||
else
|
||||
curl -sSLo /tmp/dev.zip https://github.com/midoks/mdserver-web/archive/refs/heads/dev.zip
|
||||
|
||||
@@ -198,7 +198,7 @@ def set_panel_username(username=None):
|
||||
def getServerIp():
|
||||
version = sys.argv[2]
|
||||
ip = mw.execShell(
|
||||
"curl -{} -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text".format(version))
|
||||
"curl --insecure -{} -sS --connect-timeout 5 -m 60 https://v6r.ipip.net/?format=text".format(version))
|
||||
print(ip[0])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user