mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'dev' into bugfix/master-server-dir
This commit is contained in:
commit
c1c99f315b
@ -13,12 +13,15 @@
|
||||
- Bump Cryptography/pyOpenSSL for CVE-2023-23931 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/554))
|
||||
- Fix debug logging to only display with the -v (verbose) flag ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/560))
|
||||
- Optimize world size calculation ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/550))
|
||||
- Only copy bedrock_server executable on update ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/562))
|
||||
- Fix bug where unloaded servers could not be deleted ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/566))
|
||||
### Tweaks
|
||||
- Cleanup authentication helpers ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/545))
|
||||
- Optimize file upload progress WS ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/546))
|
||||
- Truncate sidebar servers to a max of 10 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/552))
|
||||
- Upgrade to FA 6. Add Translations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/549))([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/558))
|
||||
- Forge installer and Java Detection improvements ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/559))
|
||||
- Crafty log clean up -config option ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/563))
|
||||
### Lang
|
||||
- Add additional translations to backups page strings ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/543))
|
||||
- Add additional missing translations ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/549))
|
||||
|
@ -283,27 +283,31 @@ class FileHelpers:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def unzip_file(zip_path):
|
||||
new_dir_list = zip_path.split("/")
|
||||
new_dir = ""
|
||||
for i in range(len(new_dir_list) - 1):
|
||||
if i == 0:
|
||||
new_dir += new_dir_list[i]
|
||||
else:
|
||||
new_dir += "/" + new_dir_list[i]
|
||||
|
||||
def unzip_file(zip_path, server_update=False):
|
||||
ignored_names = ["server.properties", "permissions.json", "allowlist.json"]
|
||||
# Get directory without zipfile name
|
||||
new_dir = pathlib.Path(zip_path).parents[0]
|
||||
# make sure we're able to access the zip file
|
||||
if Helpers.check_file_perms(zip_path) and os.path.isfile(zip_path):
|
||||
# make sure the directory we're unzipping this to exists
|
||||
Helpers.ensure_dir_exists(new_dir)
|
||||
# we'll make a temporary directory to unzip this to.
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
try:
|
||||
with zipfile.ZipFile(zip_path, "r") as zip_ref:
|
||||
# we'll extract this to the temp dir using zipfile module
|
||||
zip_ref.extractall(temp_dir)
|
||||
full_root_path = temp_dir
|
||||
for item in os.listdir(full_root_path):
|
||||
if os.path.isdir(os.path.join(full_root_path, item)):
|
||||
# we'll iterate through the top level directory moving everything
|
||||
# out of the temp directory and into it's final home.
|
||||
for item in os.listdir(temp_dir):
|
||||
# if the file is one of our ignored names we'll skip it
|
||||
if item in ignored_names and server_update:
|
||||
continue
|
||||
# we handle files and dirs differently or we'll crash out.
|
||||
if os.path.isdir(os.path.join(temp_dir, item)):
|
||||
try:
|
||||
FileHelpers.move_dir_exist(
|
||||
os.path.join(full_root_path, item),
|
||||
os.path.join(temp_dir, item),
|
||||
os.path.join(new_dir, item),
|
||||
)
|
||||
except Exception as ex:
|
||||
@ -311,7 +315,7 @@ class FileHelpers:
|
||||
else:
|
||||
try:
|
||||
FileHelpers.move_file(
|
||||
os.path.join(full_root_path, item),
|
||||
os.path.join(temp_dir, item),
|
||||
os.path.join(new_dir, item),
|
||||
)
|
||||
except Exception as ex:
|
||||
|
@ -441,6 +441,7 @@ class Helpers:
|
||||
"reset_secrets_on_next_boot": False,
|
||||
"monitored_mounts": mounts,
|
||||
"dir_size_poll_freq_minutes": 5,
|
||||
"crafty_logs_delete_after_days": 0,
|
||||
}
|
||||
|
||||
def get_all_settings(self):
|
||||
|
@ -1320,7 +1320,7 @@ class ServerInstance:
|
||||
unzip_path = os.path.join(self.settings["path"], "bedrock_server.zip")
|
||||
unzip_path = self.helper.wtol_path(unzip_path)
|
||||
# unzips archive that was downloaded.
|
||||
FileHelpers.unzip_file(unzip_path)
|
||||
FileHelpers.unzip_file(unzip_path, server_update=True)
|
||||
# adjusts permissions for execution if os is not windows
|
||||
if not self.helper.is_os_windows():
|
||||
os.chmod(
|
||||
@ -1334,6 +1334,7 @@ class ServerInstance:
|
||||
logger.critical(
|
||||
f"Failed to download bedrock executable for update \n{e}"
|
||||
)
|
||||
downloaded = False
|
||||
|
||||
if downloaded:
|
||||
logger.info("Executable updated successfully. Starting Server")
|
||||
|
@ -751,10 +751,42 @@ class TasksManager:
|
||||
logger.debug("Could not clear out file from import directory")
|
||||
|
||||
def log_watcher(self):
|
||||
self.controller.servers.check_for_old_logs()
|
||||
self.check_for_old_logs()
|
||||
self.scheduler.add_job(
|
||||
self.controller.servers.check_for_old_logs,
|
||||
self.check_for_old_logs,
|
||||
"interval",
|
||||
hours=6,
|
||||
id="log-mgmt",
|
||||
)
|
||||
|
||||
def check_for_old_logs(self):
|
||||
# check for server logs first
|
||||
self.controller.servers.check_for_old_logs()
|
||||
# check for crafty logs now
|
||||
logs_path = os.path.join(self.controller.project_root, "logs")
|
||||
logs_delete_after = int(
|
||||
self.helper.get_setting("crafty_logs_delete_after_days")
|
||||
)
|
||||
latest_log_files = [
|
||||
"session.log",
|
||||
"schedule.log",
|
||||
"tornado-access.log",
|
||||
"session.log",
|
||||
"commander.log",
|
||||
]
|
||||
# we won't delete if delete logs after is set to 0
|
||||
if logs_delete_after != 0:
|
||||
log_files = list(
|
||||
filter(
|
||||
lambda val: val not in latest_log_files,
|
||||
os.listdir(logs_path),
|
||||
)
|
||||
)
|
||||
for log_file in log_files:
|
||||
log_file_path = os.path.join(logs_path, log_file)
|
||||
if Helpers.check_file_exists(
|
||||
log_file_path
|
||||
) and Helpers.is_file_older_than_x_days(
|
||||
log_file_path, logs_delete_after
|
||||
):
|
||||
os.remove(log_file_path)
|
||||
|
@ -539,6 +539,7 @@ class PanelHandler(BaseHandler):
|
||||
"auto_start": server_temp_obj["auto_start"],
|
||||
"crash_detection": server_temp_obj["crash_detection"],
|
||||
"show_status": server_temp_obj["show_status"],
|
||||
"ignored_exits": server_temp_obj["ignored_exits"],
|
||||
},
|
||||
"running": False,
|
||||
"crashed": False,
|
||||
|
Loading…
Reference in New Issue
Block a user