Skip to content

Commit

Permalink
Merge pull request #224 from midoks/dev
Browse files Browse the repository at this point in the history
0.10.1
  • Loading branch information
midoks authored Oct 29, 2022
2 parents 034aaed + 4344d77 commit 7589c14
Show file tree
Hide file tree
Showing 24 changed files with 728 additions and 199 deletions.
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443:
```


### 版本更新 0.10.0
### 版本更新 0.10.1

* OP防火墙优化。
* OP防火墙-添加URL白名单功能。
* 网站统计优化。
* 添加`FTP存储空间`插件。
* 初始安装IPv6安装。
* phpMyAdmin优化。
* MySQL添加外部导入功能。
* OpenResty添加性能调整功能。
* 优化ubuntu22.04安装过程。
* Debian9友好,【SSH终端 1.0】无法使用。
* phpMyAdmin优化,需要卸载重装。
* 文件管理解压直接覆盖FIX。
* 优化文件多选的BUG。


### JSDelivr安装地址
Expand All @@ -116,6 +117,12 @@ curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/instal
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/update.sh | bash
```

- 卸载脚本

```
curl -fsSL https://cdn.jsdelivr.net/gh/midoks/mdserver-web@latest/scripts/uninstall.sh | bash
```

### 备用地址

- 初始安装
Expand All @@ -131,6 +138,12 @@ curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/update.sh | bash
```

- 卸载脚本

```
curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/uninstall.sh | bash
```


### 通用软件安装[命令行安装]

Expand Down
2 changes: 1 addition & 1 deletion class/core/config_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class config_api:

__version = '0.10.0.1'
__version = '0.10.1'

def __init__(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion class/core/files_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def unzip(self, sfile, dfile, stype, path):
try:
tmps = mw.getRunDir() + '/tmp/panelExec.log'
if stype == 'zip':
os.system("cd " + path + " && unzip -d '" + dfile +
os.system("cd " + path + " && unzip -o -d '" + dfile +
"' '" + sfile + "' > " + tmps + " 2>&1 &")
else:
sfiles = ''
Expand Down
10 changes: 6 additions & 4 deletions class/core/mw.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def writeFile(filename, str):
return False


def backFile(self, file, act=None):
def backFile(file, act=None):
"""
@name 备份配置文件
@param file 需要备份的文件
Expand All @@ -420,10 +420,12 @@ def backFile(self, file, act=None):
file_type = "_bak"
if act:
file_type = "_def"
execShell("/usr/bin/cp -p {0} {1}".format(file, file + file_type))

# print("cp -p {0} {1}".format(file, file + file_type))
execShell("cp -p {0} {1}".format(file, file + file_type))

def restoreFile(self, file, act=None):

def restoreFile(file, act=None):
"""
@name 还原配置文件
@param file 需要还原的文件
Expand All @@ -432,7 +434,7 @@ def restoreFile(self, file, act=None):
file_type = "_bak"
if act:
file_type = "_def"
execShell("/usr/bin/cp -p {1} {0}".format(file, file + file_type))
execShell("cp -p {1} {0}".format(file, file + file_type))


def HttpGet(url, timeout=10):
Expand Down
110 changes: 107 additions & 3 deletions plugins/mysql/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,69 @@ def setDbBackup():
return mw.returnJson(True, 'ok')


def importDbExternal():
args = getArgs()
data = checkArgs(args, ['file', 'name'])
if not data[0]:
return data[1]

file = args['file']
name = args['name']

import_dir = mw.getRootDir() + '/backup/import/'

file_path = import_dir + file
if not os.path.exists(file_path):
return mw.returnJson(False, '文件突然消失?')

exts = ['sql', 'gz', 'zip']
tmp = file.split('.')
ext = tmp[len(tmp) - 1]
if ext not in exts:
return mw.returnJson(False, '导入数据库格式不对!')

tmp = file.split('/')
tmpFile = tmp[len(tmp) - 1]
tmpFile = tmpFile.replace('.sql.' + ext, '.sql')
tmpFile = tmpFile.replace('.' + ext, '.sql')
tmpFile = tmpFile.replace('tar.', '')

# print(tmpFile)
import_sql = ""
if file.find("sql.gz") > -1:
cmd = 'cd ' + import_dir + ' && gzip -dc ' + \
file + " > " + import_dir + tmpFile
info = mw.execShell(cmd)
if info[1] == "":
import_sql = import_dir + tmpFile

if file.find(".zip") > -1:
cmd = 'cd ' + import_dir + ' && unzip -o ' + file
mw.execShell(cmd)
import_sql = import_dir + tmpFile

if file.find("tar.gz") > -1:
cmd = 'cd ' + import_dir + ' && tar -zxvf ' + file
mw.execShell(cmd)
import_sql = import_dir + tmpFile

if import_sql == "":
return mw.returnJson(False, '未找SQL文件')

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

# print(mysql_cmd)
os.system(mysql_cmd)
os.remove(import_sql)

return mw.returnJson(True, 'ok')


def importDbBackup():
args = getArgs()
data = checkArgs(args, ['file', 'name'])
Expand Down Expand Up @@ -855,13 +918,17 @@ def importDbBackup():

def deleteDbBackup():
args = getArgs()
data = checkArgs(args, ['filename'])
data = checkArgs(args, ['filename', 'path'])
if not data[0]:
return data[1]

path = args['path']
full_file = ""
bkDir = mw.getRootDir() + '/backup/database'

os.remove(bkDir + '/' + args['filename'])
full_file = bkDir + '/' + args['filename']
if path != "":
full_file = path + "/" + args['filename']
os.remove(full_file)
return mw.returnJson(True, 'ok')


Expand Down Expand Up @@ -893,6 +960,39 @@ def getDbBackupList():
return mw.returnJson(True, 'ok', rr)


def getDbBackupImportList():

bkImportDir = mw.getRootDir() + '/backup/import'
if not os.path.exists(bkImportDir):
os.mkdir(bkImportDir)

blist = os.listdir(bkImportDir)

rr = []
for x in range(0, len(blist)):
name = blist[x]
p = bkImportDir + '/' + name
data = {}
data['name'] = name

rsize = os.path.getsize(p)
data['size'] = mw.toSize(rsize)

t = os.path.getctime(p)
t = time.localtime(t)

data['time'] = time.strftime('%Y-%m-%d %H:%M:%S', t)
rr.append(data)

data['file'] = p

rdata = {
"list": rr,
"upload_dir": bkImportDir,
}
return mw.returnJson(True, 'ok', rdata)


def getDbList():
args = getArgs()
page = 1
Expand Down Expand Up @@ -2427,10 +2527,14 @@ def uninstallPreInspection(version):
print(setDbBackup())
elif func == 'import_db_backup':
print(importDbBackup())
elif func == 'import_db_external':
print(importDbExternal())
elif func == 'delete_db_backup':
print(deleteDbBackup())
elif func == 'get_db_backup_list':
print(getDbBackupList())
elif func == 'get_db_backup_import_list':
print(getDbBackupImportList())
elif func == 'add_db':
print(addDb())
elif func == 'del_db':
Expand Down
Loading

0 comments on commit 7589c14

Please sign in to comment.