commit
732bdd5a1c
3
cmd.md
3
cmd.md
|
|
@ -4,6 +4,9 @@
|
|||
- 面板相关命令
|
||||
|
||||
```
|
||||
mw start | 启动面板服务器
|
||||
mw stop | 停止面板服务器
|
||||
mw restart | 重启面板服务器
|
||||
mw default | 显示登录信息
|
||||
mw db | 快捷连接MySQL
|
||||
mw redis | 快捷连接Redis
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ apt install -y python3-venv
|
|||
apt install -y libncurses5
|
||||
apt install -y libncurses5-dev
|
||||
apt install -y bzip2
|
||||
apt install -y p7zip-full
|
||||
|
||||
apt install -y libnuma1
|
||||
apt install -y libaio1
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ $PKGMGR install -y curl-devel libmcrypt libmcrypt-devel python3-devel
|
|||
$PKGMGR install -y net-tools
|
||||
$PKGMGR install -y unixODBC-devel
|
||||
|
||||
$PKGMGR install -y p7zip
|
||||
$PKGMGR install -y p7zip-plugins
|
||||
|
||||
$PKGMGR install -y libncurses*
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ apt install -y libncurses5
|
|||
apt install -y libncurses5-dev
|
||||
apt install -y software-properties-common
|
||||
apt install -y bzip2
|
||||
apt install -y p7zip-full
|
||||
|
||||
apt install -y libnuma1
|
||||
apt install -y libaio1
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ else
|
|||
echo "openresty alreay exist!"
|
||||
fi
|
||||
|
||||
# redis
|
||||
if [ ! -d /www/server/redis ];then
|
||||
cd /www/server/mdserver-web/plugins/redis && bash install.sh install 7.4.3
|
||||
else
|
||||
echo "redis alreay exist!"
|
||||
fi
|
||||
|
||||
|
||||
# php
|
||||
if [ ! -d /www/server/php/71 ];then
|
||||
|
|
|
|||
|
|
@ -69,6 +69,13 @@ def execShell(cmdstring, cwd=None, timeout=None, shell=True):
|
|||
error = str(e)
|
||||
return (success, error)
|
||||
|
||||
def checkBinExist(name):
|
||||
d = execShell('which ' + name)
|
||||
if d[0] != '':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def getTracebackInfo():
|
||||
import traceback
|
||||
|
|
|
|||
|
|
@ -450,10 +450,10 @@ function getFiles(Path) {
|
|||
<a class='btlink' href='javascript:;' onclick=\"cutFile('" + rdata.path +"/"+ fmp[0]+ "')\">剪切</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"reName(0,'" + fmp[0] + "');\">重命名</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"setChmod(0,'" + rdata.path + "/"+fmp[0] + "');\">权限</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"zip('" + rdata.path +"/" +fmp[0] + "');\">压缩</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"deleteDir('" + rdata.path +"/"+ fmp[0] + "')\">删除</a></span>\
|
||||
</td>\
|
||||
</tr>";
|
||||
// <a class='btlink' href='javascript:;' onclick=\"zip('" + rdata.path +"/" +fmp[0] + "');\">压缩</a> | \
|
||||
} else {
|
||||
//图标展示
|
||||
$("#set_icon").addClass("active");
|
||||
|
|
@ -490,10 +490,12 @@ function getFiles(Path) {
|
|||
var displayCompress = 1;
|
||||
if(isCompressFile(fmp[0])){
|
||||
bodyZip = "<a class='btlink' href='javascript:;' onclick=\"unCompressFile('" + rdata.path +"/" +fmp[0] + "')\">解压</a> | ";
|
||||
} else {
|
||||
bodyZip = "<a class='btlink' href='javascript:;' onclick=\"zip('" + rdata.path +"/" +fmp[0] + "');\">压缩</a> | ";
|
||||
}
|
||||
|
||||
if(isText(fmp[0])){
|
||||
bodyZip = "<a class='btlink' href='javascript:;' onclick=\"onlineEditFile(0,'" + rdata.path +"/"+ fmp[0] + "')\">编辑</a> | ";
|
||||
bodyZip += "<a class='btlink' href='javascript:;' onclick=\"onlineEditFile(0,'" + rdata.path +"/"+ fmp[0] + "')\">编辑</a> | ";
|
||||
}
|
||||
|
||||
if(isImage(fmp[0])){
|
||||
|
|
@ -515,8 +517,7 @@ function getFiles(Path) {
|
|||
<span><a class='btlink' href='javascript:;' onclick=\"copyFile('" + rdata.path +"/"+ fmp[0] + "')\">复制</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"cutFile('" + rdata.path +"/"+ fmp[0] + "')\">剪切</a> | \
|
||||
<a class='btlink' href='javascript:;' onclick=\"reName(0,'" + fmp[0] + "')\">重命名</a> | \
|
||||
<a class='btlink' href=\"javascript:setChmod(0,'" + rdata.path +"/"+ fmp[0] + "');\">权限</a> | \
|
||||
<a class='btlink' href=\"javascript:zip('" + rdata.path +"/" +fmp[0] + "');\">压缩</a> | "
|
||||
<a class='btlink' href=\"javascript:setChmod(0,'" + rdata.path +"/"+ fmp[0] + "');\">权限</a> | "
|
||||
+ bodyZip
|
||||
+ download
|
||||
+ "<a class='btlink' href='javascript:;' onclick=\"deleteFile('" + rdata.path +"/"+ fmp[0] + "')\">删除</a>\
|
||||
|
|
@ -1307,67 +1308,100 @@ function pasteTo(path,copyName,cutName,fileName){
|
|||
|
||||
//压缩目录
|
||||
function zip(dirName,submits) {
|
||||
var path = $("#DirPathPlace input").val();
|
||||
var dirNameArr = dirName.split('/');
|
||||
var fileName = dirNameArr[dirNameArr.length-1];
|
||||
var pathName = dirName.replace('/'+fileName,'');
|
||||
var randStr = getRandomString(6);
|
||||
|
||||
if(submits != undefined){
|
||||
if(dirName.indexOf(',') == -1){
|
||||
tmp = $("#sfile").val().split('/');
|
||||
sfile = encodeURIComponent(tmp[tmp.length-1]);
|
||||
}else{
|
||||
sfile = encodeURIComponent(dirName);
|
||||
}
|
||||
|
||||
dfile = encodeURIComponent($("#dfile").val());
|
||||
layer.closeAll();
|
||||
layer.msg(lan.files.zip_the, {icon: 16,time: 0,shade: [0.3, '#000']});
|
||||
$.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type=tar&path='+encodeURIComponent(path), function(rdata) {
|
||||
var sfile = $("#sfile").val();
|
||||
var path = $("#path").val();
|
||||
var ztype = $('select[name="z_type"]').val();
|
||||
var dfile = $("#dfile").val();
|
||||
|
||||
layer.msg('正在压缩,请稍候...', {icon: 16,time: 0,shade: [0.3, '#000']});
|
||||
$.post('/files/zip', 'sfile=' + sfile + '&dfile=' + dfile + '&type='+ztype+'&path='+encodeURIComponent(path), function(rdata) {
|
||||
layer.closeAll();
|
||||
if(rdata == null || rdata == undefined){
|
||||
layer.msg(lan.files.zip_ok,{icon:1});
|
||||
getFiles(path)
|
||||
layer.msg('服务器正在后台压缩文件,请稍候刷新文件列表查看进度!',{icon:1});
|
||||
getFiles($("#DirPathPlace input").val());
|
||||
reloadFiles();
|
||||
return;
|
||||
}
|
||||
layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
|
||||
if(rdata.status) getFiles(path);
|
||||
|
||||
showMsg(rdata.msg, function(){
|
||||
if(rdata.status) {
|
||||
getFiles($("#DirPathPlace input").val());
|
||||
}
|
||||
},{icon: rdata.status ? 1 : 2});
|
||||
},'json');
|
||||
return
|
||||
}
|
||||
|
||||
param = dirName;
|
||||
if(dirName.indexOf(',') != -1){
|
||||
tmp = path.split('/');
|
||||
dirName = path + '/' + tmp[tmp.length-1];
|
||||
}
|
||||
|
||||
|
||||
var defaultDfile = pathName+'/'+fileName+'_'+randStr+'.tar.gz';
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
shift: 5,
|
||||
closeBtn: 1,
|
||||
area: '650px',
|
||||
title: lan.files.zip_title,
|
||||
content: '<div class="bt-form pd20 pb70">'
|
||||
+'<div class="line noborder">'
|
||||
+'<input type="text" class="form-control" id="sfile" value="' +param + '" placeholder="" style="display:none" />'
|
||||
+'<span>'+lan.files.zip_to+'</span>\
|
||||
<input type="text" class="bt-input-text" id="dfile" value="'+dirName + '.tar.gz" placeholder="'+lan.files.zip_to+'" style="width: 75%; display: inline-block; margin: 0px 10px 0px 20px;" />\
|
||||
<span class="glyphicon glyphicon-folder-open cursor" onclick="changePath(\'dfile\')"></span>'
|
||||
+'</div>'
|
||||
+'<div class="bt-form-submit-btn">'
|
||||
+'<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>'
|
||||
+'<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="zip(\'' + param + '\',1)">'+lan.files.file_menu_zip+'</button>'
|
||||
+'</div>'
|
||||
title: '压缩文件['+fileName+']',
|
||||
btn: ['确定','取消'],
|
||||
content: '<div class="bt-form pd20">'
|
||||
+ '<div class="line noborder">'
|
||||
+ '<span class="tname">压缩类型</span>\
|
||||
<div class="info-r">\
|
||||
<select class="bt-input-text mr5" name="z_type" style="width:458px;">\
|
||||
<option value="tar_gz" selected>tar.gz (推荐)</option>\
|
||||
<option value="zip">zip (通用格式)</option>\
|
||||
<option value="rar">rar (WinRAR对中文兼容较好)</option>\
|
||||
<option value="7z">7z (压缩率极高的压缩格式)</option>\
|
||||
</select>\
|
||||
</div>\
|
||||
</div>'
|
||||
//
|
||||
+ '<div class="line noborder">'
|
||||
+ '<input type="text" id="sfile" value="' + fileName + '" style="display:none" />'
|
||||
+ '<input type="text" id="path" value="' + pathName + '" style="display:none" />'
|
||||
+ '<span class="tname">压缩路径</span>\
|
||||
<input type="text" class="bt-input-text" id="dfile" value="' + defaultDfile + '" placeholder="压缩到" style="width: 75%; display: inline-block; margin: 0px 10px 0px 0px;" />\
|
||||
<span id="change_dir" class="glyphicon glyphicon-folder-open cursor"></span>'
|
||||
+ '</div>'
|
||||
+'</div>',
|
||||
success:function(){
|
||||
$("#dfile").change(function(){
|
||||
var dfile = $(this).val()
|
||||
tmp = dfile.split('.');
|
||||
if(tmp[tmp.length-1] != 'gz'){
|
||||
var path = $("#DirPathPlace input").val();
|
||||
tmp = path.split('/');
|
||||
dfile += '/' + tmp[tmp.length-1] + '.tar.gz'
|
||||
$(this).val(dfile.replace(/\/\//g,'/'))
|
||||
$('#change_dir').click(function(){
|
||||
changePathCallback('dfile', function(val){
|
||||
var z_type = $('select[name="z_type"]').val();
|
||||
$('#dfile').val(val+'/'+fileName+'_'+randStr+'.'+z_type.replace('_','.'));
|
||||
$('#path').val(val);
|
||||
});
|
||||
});
|
||||
|
||||
$('select[name="z_type"]').change(function(){
|
||||
var z_type = $(this).val();
|
||||
var path = $('#path').val();
|
||||
var newPathName = path+'/'+fileName+'_'+randStr;
|
||||
if (z_type == 'tar_gz') {
|
||||
$("#dfile").val(newPathName + '.tar.gz');
|
||||
} else if (z_type == 'zip') {
|
||||
$("#dfile").val(newPathName + '.zip');
|
||||
} else if (z_type == 'rar') {
|
||||
$("#dfile").val(newPathName + '.rar');
|
||||
} else if (z_type == 'gz') {
|
||||
$("#dfile").val(newPathName + '.gz');
|
||||
} else if (z_type == '7z') {
|
||||
$("#dfile").val(newPathName + '.7z');
|
||||
}
|
||||
});
|
||||
|
||||
$("#dfile").change(function(){
|
||||
var dfile = $(this).val();
|
||||
$(this).val(dfile.replace(/\/\//g,'/'));
|
||||
});
|
||||
},
|
||||
btn1: function(index){
|
||||
zip(dirName,1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1424,7 +1458,7 @@ function unZip(fileName, type) {
|
|||
function isCompressFile(fileName){
|
||||
var ext = fileName.split('.');
|
||||
var extName = ext[ext.length-1].toLowerCase();
|
||||
var support = ['zip','gz','tgz','rar'];
|
||||
var support = ['zip','gz','tgz','rar','7z'];
|
||||
for (x in support) {
|
||||
if (support[x]==extName){
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -140,11 +140,14 @@ def uncompress(sfile, dfile, path):
|
|||
if suffix_gz == tar_gz:
|
||||
extension = suffix_gz
|
||||
|
||||
if not extension in ['tar.gz', 'gz', 'zip', 'rar']:
|
||||
if not extension in ['tar.gz', 'gz', 'zip', 'rar', '7z']:
|
||||
return mw.returnData(False, '现在仅支持gz,zip,rar格式解压!')
|
||||
|
||||
if mw.isAppleSystem() and extension == 'rar':
|
||||
return mw.returnData(False, 'macosx暂时不支持rar格式解压')
|
||||
if extension == 'rar' and not mw.checkBinExist('rar'):
|
||||
return mw.returnData(False, 'rar解压命令不存在,请安装!')
|
||||
if extension == '7z' and not mw.checkBinExist('7z'):
|
||||
return mw.returnData(False, '7z解药命令不存在,请安装!')
|
||||
|
||||
|
||||
cmd = "cd " + path + " "
|
||||
try:
|
||||
|
|
@ -152,15 +155,18 @@ def uncompress(sfile, dfile, path):
|
|||
if extension == 'zip':
|
||||
cmd += "&& unzip -o -d '" + dfile + "' '" + sfile + "' > " + tmps + " 2>&1 &"
|
||||
mw.execShell(cmd)
|
||||
if extension == 'tar.gz':
|
||||
elif extension == 'tar.gz':
|
||||
cmd += "&& tar -zxvf " + sfile + " -C " + dfile + " > " + tmps + " 2>&1 &"
|
||||
mw.execShell(cmd)
|
||||
if extension == 'gz':
|
||||
elif extension == 'gz':
|
||||
cmd += "&& gunzip -k " + sfile + " > " + tmps + " 2>&1 &"
|
||||
mw.execShell(cmd)
|
||||
if extension == 'rar':
|
||||
elif extension == 'rar':
|
||||
cmd += "&& unrar x " + sfile + " " + dfile + " > " + tmps + " 2>&1 &"
|
||||
mw.execShell(cmd)
|
||||
elif extension == '7z':
|
||||
cmd += "&& 7z x " + sfile + " -r -o" + dfile + " > " + tmps + " 2>&1 &"
|
||||
mw.execShell(cmd)
|
||||
|
||||
if os.path.exists(dfile):
|
||||
setFileAccept(dfile)
|
||||
|
|
@ -286,8 +292,13 @@ def zip(sfile, dfile, stype, path):
|
|||
try:
|
||||
tmps = mw.getPanelDir() + '/logs/panel_exec.log'
|
||||
if stype == 'zip':
|
||||
mw.execShell("cd '" + path + "' && zip '" + dfile +
|
||||
"' -r '" + sfile + "' > " + tmps + " 2>&1")
|
||||
mw.execShell("cd '" + path + "' && zip '" + dfile + "' -r '" + sfile + "' > " + tmps + " 2>&1")
|
||||
elif stype == '7z':
|
||||
mw.execShell("cd '" + path + "' && 7z a '" + dfile + "' -r '" + sfile + "' > " + tmps + " 2>&1")
|
||||
elif stype == 'tar_gz':
|
||||
mw.execShell("cd '" + path + "' && tar -zcvf '" + dfile + "' " + sfile + " > " + tmps + " 2>&1")
|
||||
elif stype == 'rar':
|
||||
mw.execShell("cd '" + path + "' && rar a '" + dfile + "' '" + sfile + "' > " + tmps + " 2>&1")
|
||||
else:
|
||||
sfiles = ''
|
||||
for sfile in sfile.split(','):
|
||||
|
|
@ -298,8 +309,8 @@ def zip(sfile, dfile, stype, path):
|
|||
setFileAccept(dfile)
|
||||
mw.writeLog("文件管理", '文件[{1}]压缩[{2}]成功!', (sfile, dfile))
|
||||
return mw.returnData(True, '文件压缩成功!')
|
||||
except:
|
||||
return mw.returnData(False, '文件压缩失败!')
|
||||
except Exception as e:
|
||||
return mw.returnData(False, '文件压缩失败:'+str(e))
|
||||
|
||||
def unzip(sfile, dfile, stype, path):
|
||||
if not os.path.exists(sfile):
|
||||
|
|
|
|||
Loading…
Reference in New Issue