Extract exec action
This commit is contained in:
parent
d26e8cc518
commit
dbb3dd4e22
|
@ -0,0 +1,24 @@
|
||||||
|
# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers <https://github.com/Jip-Hop/jailmaker>
|
||||||
|
#
|
||||||
|
# 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
|
|
@ -141,24 +141,7 @@ from utils.chroot import Chroot
|
||||||
from utils.console import eprint, fail
|
from utils.console import eprint, fail
|
||||||
from utils.jail_dataset import get_jail_path, get_jail_config_path, get_jail_rootfs_path
|
from utils.jail_dataset import get_jail_path, get_jail_config_path, get_jail_rootfs_path
|
||||||
|
|
||||||
|
from actions.exec import exec_jail
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
def status_jail(jail_name, args):
|
def status_jail(jail_name, args):
|
||||||
|
|
Loading…
Reference in New Issue