diff --git a/src/jlmkr/actions/exec.py b/src/jlmkr/actions/exec.py new file mode 100644 index 0000000..eba8b2f --- /dev/null +++ b/src/jlmkr/actions/exec.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers +# +# SPDX-License-Identifier: LGPL-3.0-only + +import subprocess + + +def exec_jail(jail_name, cmd): + """ + Execute a command in the jail with given name. + """ + return subprocess.run( + [ + "systemd-run", + "--machine", + jail_name, + "--quiet", + "--pipe", + "--wait", + "--collect", + "--service-type=exec", + *cmd, + ] + ).returncode diff --git a/src/jlmkr/donor/jlmkr.py b/src/jlmkr/donor/jlmkr.py index b70d4be..772601b 100755 --- a/src/jlmkr/donor/jlmkr.py +++ b/src/jlmkr/donor/jlmkr.py @@ -141,24 +141,7 @@ from utils.chroot import Chroot from utils.console import eprint, fail from utils.jail_dataset import get_jail_path, get_jail_config_path, get_jail_rootfs_path - -def exec_jail(jail_name, cmd): - """ - Execute a command in the jail with given name. - """ - return subprocess.run( - [ - "systemd-run", - "--machine", - jail_name, - "--quiet", - "--pipe", - "--wait", - "--collect", - "--service-type=exec", - *cmd, - ] - ).returncode +from actions.exec import exec_jail def status_jail(jail_name, args):