mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Merge branch 'bug/backups-restore/download' into 'dev'
Bug/backups restore/download See merge request crafty-controller/crafty-commander!197
This commit is contained in:
commit
eda9f44b5f
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
@ -513,10 +514,13 @@ class Controller:
|
|||||||
server_data = self.servers.get_server_data_by_id(old_server_id)
|
server_data = self.servers.get_server_data_by_id(old_server_id)
|
||||||
old_bu_path = server_data['backup_path']
|
old_bu_path = server_data['backup_path']
|
||||||
Server_Perms_Controller.backup_role_swap(old_server_id, new_server_id)
|
Server_Perms_Controller.backup_role_swap(old_server_id, new_server_id)
|
||||||
|
if not helper.is_os_windows():
|
||||||
backup_path = helper.validate_traversal(helper.backup_path, old_bu_path)
|
backup_path = helper.validate_traversal(helper.backup_path, old_bu_path)
|
||||||
if helper.is_os_windows():
|
if helper.is_os_windows():
|
||||||
backup_path = helper.wtol_path(backup_path)
|
backup_path = helper.validate_traversal(helper.wtol_path(helper.backup_path), helper.wtol_path(old_bu_path))
|
||||||
|
backup_path = helper.wtol_path(str(backup_path))
|
||||||
backup_path.replace(' ', '^ ')
|
backup_path.replace(' ', '^ ')
|
||||||
|
backup_path = Path(backup_path)
|
||||||
backup_path_components = list(backup_path.parts)
|
backup_path_components = list(backup_path.parts)
|
||||||
backup_path_components[-1] = new_uuid
|
backup_path_components[-1] = new_uuid
|
||||||
new_bu_path = pathlib.PurePath(os.path.join(*backup_path_components))
|
new_bu_path = pathlib.PurePath(os.path.join(*backup_path_components))
|
||||||
|
@ -178,6 +178,10 @@ class Server:
|
|||||||
#Register an shedule for polling server stats when running
|
#Register an shedule for polling server stats when running
|
||||||
logger.info(f"Polling server statistics {self.name} every {5} seconds")
|
logger.info(f"Polling server statistics {self.name} every {5} seconds")
|
||||||
console.info(f"Polling server statistics {self.name} every {5} seconds")
|
console.info(f"Polling server statistics {self.name} every {5} seconds")
|
||||||
|
try:
|
||||||
|
self.server_scheduler.add_job(self.realtime_stats, 'interval', seconds=5, id="stats_"+str(self.server_id))
|
||||||
|
except:
|
||||||
|
self.server_scheduler.remove_job('stats_'+str(self.server_id))
|
||||||
self.server_scheduler.add_job(self.realtime_stats, 'interval', seconds=5, id="stats_"+str(self.server_id))
|
self.server_scheduler.add_job(self.realtime_stats, 'interval', seconds=5, id="stats_"+str(self.server_id))
|
||||||
|
|
||||||
|
|
||||||
@ -514,6 +518,7 @@ class Server:
|
|||||||
proc.kill()
|
proc.kill()
|
||||||
# kill the main process we are after
|
# kill the main process we are after
|
||||||
logger.info('Sending SIGKILL to parent')
|
logger.info('Sending SIGKILL to parent')
|
||||||
|
self.server_scheduler.remove_job("stats_"+str(self.server_id))
|
||||||
self.process.kill()
|
self.process.kill()
|
||||||
|
|
||||||
def get_start_time(self):
|
def get_start_time(self):
|
||||||
|
@ -337,6 +337,7 @@ class AjaxHandler(BaseHandler):
|
|||||||
zip_name = bleach.clean(self.get_argument('zip_file', None))
|
zip_name = bleach.clean(self.get_argument('zip_file', None))
|
||||||
svr_obj = self.controller.servers.get_server_obj(server_id)
|
svr_obj = self.controller.servers.get_server_obj(server_id)
|
||||||
server_data = self.controller.servers.get_server_data_by_id(server_id)
|
server_data = self.controller.servers.get_server_data_by_id(server_id)
|
||||||
|
if server_data['type'] == 'minecraft-java':
|
||||||
backup_path = svr_obj.backup_path
|
backup_path = svr_obj.backup_path
|
||||||
if helper.validate_traversal(backup_path, zip_name):
|
if helper.validate_traversal(backup_path, zip_name):
|
||||||
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
||||||
@ -351,6 +352,20 @@ class AjaxHandler(BaseHandler):
|
|||||||
self.controller.remove_server(server_id, True)
|
self.controller.remove_server(server_id, True)
|
||||||
self.redirect('/panel/dashboard')
|
self.redirect('/panel/dashboard')
|
||||||
|
|
||||||
|
else:
|
||||||
|
backup_path = svr_obj.backup_path
|
||||||
|
if helper.validate_traversal(backup_path, zip_name):
|
||||||
|
tempDir = helper.unzip_backup_archive(backup_path, zip_name)
|
||||||
|
new_server = self.controller.import_bedrock_zip_server(svr_obj.server_name,
|
||||||
|
tempDir,
|
||||||
|
server_data['executable'],
|
||||||
|
server_data['server_port'])
|
||||||
|
new_server_id = new_server
|
||||||
|
new_server = self.controller.get_server_data(new_server)
|
||||||
|
self.controller.rename_backup_dir(server_id, new_server_id, new_server['server_uuid'])
|
||||||
|
self.controller.remove_server(server_id, True)
|
||||||
|
self.redirect('/panel/dashboard')
|
||||||
|
|
||||||
elif page == "unzip_server":
|
elif page == "unzip_server":
|
||||||
path = self.get_argument('path', None)
|
path = self.get_argument('path', None)
|
||||||
if helper.check_file_exists(path):
|
if helper.check_file_exists(path):
|
||||||
|
@ -253,6 +253,10 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
|
|
||||||
function restore_backup(filename, id){
|
function restore_backup(filename, id){
|
||||||
var token = getCookie("_xsrf")
|
var token = getCookie("_xsrf")
|
||||||
|
var dialog = bootbox.dialog({
|
||||||
|
message: '<i class="fa fa-spin fa-spinner"></i> {{ translate('serverBackups', 'restoring', data['lang']) }}',
|
||||||
|
closeButton: false
|
||||||
|
});
|
||||||
|
|
||||||
console.log('Sending Command to restore backup: ' + filename)
|
console.log('Sending Command to restore backup: ' + filename)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -264,10 +268,6 @@ const server_id = new URLSearchParams(document.location.search).get('id')
|
|||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var dialog = bootbox.dialog({
|
|
||||||
message: '<i class="fa fa-spin fa-spinner"></i> {{ translate('serverBackups', 'restoring', data['lang']) }}',
|
|
||||||
closeButton: false
|
|
||||||
});
|
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
location.href=('/panel/dashboard');
|
location.href=('/panel/dashboard');
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
@ -849,7 +849,7 @@
|
|||||||
function downloadFileE(event) {
|
function downloadFileE(event) {
|
||||||
path = event.target.parentElement.getAttribute('data-path');
|
path = event.target.parentElement.getAttribute('data-path');
|
||||||
name = event.target.parentElement.getAttribute('data-name');
|
name = event.target.parentElement.getAttribute('data-name');
|
||||||
window.location.href = `/panel/download_file?id=${server_id}&path=${path}&name=${name}`;
|
window.location.href = `/panel/download_file?id=${serverId}&path=${path}&name=${name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renameItemE(event) {
|
function renameItemE(event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user