Merge pull request #856 from midoks/dev

可迁移ssh终端配置
This commit is contained in:
Mr Chen
2026-02-01 18:15:42 +08:00
committed by GitHub
3 changed files with 107 additions and 3 deletions
+9
View File
@@ -269,6 +269,15 @@ label.checkbox_label span {
<ul id="db_li"></ul> <ul id="db_li"></ul>
</div> </div>
</div> </div>
<div class="checkbox_data">
<div class="checkbox_item">
<label class="checkbox_label">
<input type="checkbox" id="plugin_All" checked>
<span>插件</span>
</label>
<ul id="plugin_li"></ul>
</div>
</div>
</div> </div>
<div class="line mtb20" style="margin:20px 0 0 50px"> <div class="line mtb20" style="margin:20px 0 0 50px">
<button class="btn btn-default btn-sm mr20 dataBack">上一步</button> <button class="btn btn-default btn-sm mr20 dataBack">上一步</button>
+75 -2
View File
@@ -76,6 +76,16 @@ class classApi:
t = {'name': i} t = {'name': i}
databases.append(t) databases.append(t)
data['databases'] = databases data['databases'] = databases
plugin = []
for i in args['plugin']:
# print('db:', i)
if i == '':
continue
t = {'name': i}
plugin.append(t)
data['plugin'] = plugin
return data return data
def fock_process(self, args): def fock_process(self, args):
@@ -753,6 +763,59 @@ class classApi:
except: except:
self.error(mw.getTracebackInfo()) self.error(mw.getTracebackInfo())
def print_directory_tree(self, directory, prefix=""):
"""递归打印目录树结构"""
items = sorted(os.listdir(directory))
for i, item in enumerate(items):
item_path = os.path.join(directory, item)
is_last = i == len(items) - 1
if os.path.isdir(item_path):
print(f"{prefix}{'└── ' if is_last else '├── '}{item}/")
extension = " " if is_last else "│ "
self.print_directory_tree(item_path, prefix + extension)
else:
print(f"{prefix}{'└── ' if is_last else '├── '}{item}")
def upload_dir(self, src, dst):
"""递归打印目录树结构"""
items = sorted(os.listdir(src))
for i, item in enumerate(items):
item_path = os.path.join(src, item)
is_last = i == len(items) - 1
if os.path.isdir(item_path):
# print("dir:",item_path, dst+'/'+item)
self.upload_dir(item_path, dst+'/'+item)
else:
# print("file:",item_path, dst+'/'+item)
self.upload_file(item_path, dst+'/'+item)
def sync_plugin_webssh(self):
name = "webssh"
webssh_dir = mw.getServerDir()+'/'+name
# 递归遍历所有文件和目录并打印
print(f"\n目录树结构: {webssh_dir}")
print("=" * 50)
if os.path.exists(webssh_dir):
# self.print_directory_tree(webssh_dir)
self.upload_dir(webssh_dir, "/www/server/"+name)
else:
print(f"目录不存在: {webssh_dir}")
print("=" * 50)
def sync_plugin(self):
data = getCfgData()
plugin = self._SYNC_INFO['plugin']
for x in plugin:
if x['name'] == 'webssh':
self.sync_plugin_webssh()
return True
def run(self): def run(self):
# 开始迁移 # 开始迁移
# self.upload_file("/tmp/mysql-boost-5.7.39.tar.gz", "/tmp/mysql-boost-5.7.39.tar.gz") # self.upload_file("/tmp/mysql-boost-5.7.39.tar.gz", "/tmp/mysql-boost-5.7.39.tar.gz")
@@ -761,6 +824,7 @@ class classApi:
self.sync_site() self.sync_site()
self.sync_database() self.sync_database()
# self.sync_path() # self.sync_path()
self.sync_plugin()
self.write_speed('action', 'True') self.write_speed('action', 'True')
write_log('|-所有项目迁移完成!') write_log('|-所有项目迁移完成!')
@@ -904,7 +968,7 @@ def get_src_config(args):
data['webserver'] = 'OpenResty' data['webserver'] = 'OpenResty'
data['php'] = [] data['php'] = []
phpversions = ['52', '53', '54', '55', '56', '70', '71', phpversions = ['52', '53', '54', '55', '56', '70', '71',
'72', '73', '74', '80', '81', '82', '83', '84'] '72', '73', '74', '80', '81', '82', '83', '84', '85']
phpPath = sdir + '/php/' phpPath = sdir + '/php/'
for pv in phpversions: for pv in phpversions:
if not os.path.exists(phpPath + pv + '/bin/php'): if not os.path.exists(phpPath + pv + '/bin/php'):
@@ -952,6 +1016,13 @@ def get_src_info(args):
my_db_pos = mw.getServerDir() + '/mysql' my_db_pos = mw.getServerDir() + '/mysql'
conn = mw.M('databases').dbPos(my_db_pos, 'mysql') conn = mw.M('databases').dbPos(my_db_pos, 'mysql')
data['databases'] = conn.field('id,name,ps').order("id desc").select() data['databases'] = conn.field('id,name,ps').order("id desc").select()
data['plugin'] = []
plugin_webssh_name = "webssh"
webssh_dir = mw.getServerDir() + '/'+plugin_webssh_name
if os.path.exists(webssh_dir):
data['plugin'].append(plugin_webssh_name)
return data return data
@@ -1000,11 +1071,13 @@ def stepFour():
sites = args['sites'] sites = args['sites']
databases = args['databases'] databases = args['databases']
plugin = args['plugin']
data = getCfgData() data = getCfgData()
args = { args = {
'sites': sites.strip(',').split(','), 'sites': sites.strip(',').split(','),
'databases': databases.strip(',').split(',') 'databases': databases.strip(',').split(','),
'plugin': plugin.strip(',').split(',')
} }
api = classApi(data['url'], data['app_id'],data['app_secret']) api = classApi(data['url'], data['app_id'],data['app_secret'])
return api.set_sync_info(args) return api.set_sync_info(args)
+23 -1
View File
@@ -187,6 +187,18 @@ function initStep3(){
} }
$('#db_li').html(db_li); $('#db_li').html(db_li);
var plugin_li = '';
for (var i = 0; i < pdata.plugin.length; i++) {
plugin_li+='<li>\
<label>\
<input type="checkbox" data-id="'+i+'" id="plugin_'+pdata.plugin[i]+'" value="'+pdata.plugin[i]+'" name="plugin" checked="">\
<span title="'+pdata.plugin[i]+'">'+pdata.plugin[i]+'</span>\
</label>\
</li>';
}
$('#plugin_li').html(plugin_li);
$('.psync_path').hide(); $('.psync_path').hide();
$('.psync_data').show(); $('.psync_data').show();
} }
@@ -242,7 +254,12 @@ function initStep4(){
databases_checked+=$(this).val()+','; databases_checked+=$(this).val()+',';
}); });
maPost('step_four',{sites:site_checked,databases:databases_checked}, function(rdata){ var plugin_checked = '';
$('input[name="plugin"]:checked').each(function(){
plugin_checked+=$(this).val()+',';
});
maPost('step_four',{sites:site_checked,databases:databases_checked,plugin:plugin_checked}, function(rdata){
var rdata = $.parseJSON(rdata.data); var rdata = $.parseJSON(rdata.data);
selectProgress(4); selectProgress(4);
@@ -318,6 +335,11 @@ function initStep(){
$('#db_li input').prop('checked',ch); $('#db_li input').prop('checked',ch);
}); });
$('#plugin_All').on('click',function(){
var ch = $(this).prop('checked');
$('#plugin_li input').prop('checked',ch);
});
$('.psync_migrate').on('click', '.okBtn', function(){ $('.psync_migrate').on('click', '.okBtn', function(){
$('.psync_migrate').hide(); $('.psync_migrate').hide();
$('.psync_info').show(); $('.psync_info').show();