From a08149daeaa4163ac94b4f54d81e8e486cc5126e Mon Sep 17 00:00:00 2001 From: jonct <2807816+jonct@users.noreply.github.com> Date: Mon, 15 Jul 2024 02:09:38 -0400 Subject: [PATCH] Extract log action --- src/jlmkr/actions/log.py | 16 ++++++++++++++++ src/jlmkr/donor/jlmkr.py | 12 +----------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/jlmkr/actions/log.py diff --git a/src/jlmkr/actions/log.py b/src/jlmkr/actions/log.py new file mode 100644 index 0000000..b0e7b32 --- /dev/null +++ b/src/jlmkr/actions/log.py @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers +# +# SPDX-License-Identifier: LGPL-3.0-only + +import subprocess + +from utils.paths import SHORTNAME + + +def log_jail(jail_name, args): + """ + Show the log file of the jail with given name. + """ + return subprocess.run( + ["journalctl", "-u", f"{SHORTNAME}-{jail_name}", *args] + ).returncode diff --git a/src/jlmkr/donor/jlmkr.py b/src/jlmkr/donor/jlmkr.py index 9325280..ca4bf44 100755 --- a/src/jlmkr/donor/jlmkr.py +++ b/src/jlmkr/donor/jlmkr.py @@ -143,17 +143,7 @@ from utils.jail_dataset import get_jail_path, get_jail_config_path, get_jail_roo from actions.exec import exec_jail from actions.status import status_jail - - -def log_jail(jail_name, args): - """ - Show the log file of the jail with given name. - """ - return subprocess.run( - ["journalctl", "-u", f"{SHORTNAME}-{jail_name}", *args] - ).returncode - - +from actions.log import log_jail from actions.shell import shell_jail from actions.start import start_jail from actions.restart import restart_jail