diff --git a/src/jlmkr/actions/restart.py b/src/jlmkr/actions/restart.py new file mode 100644 index 0000000..1740230 --- /dev/null +++ b/src/jlmkr/actions/restart.py @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers +# +# SPDX-License-Identifier: LGPL-3.0-only + + +import subprocess +import time + +from actions.start import start_jail +from actions.stop import stop_jail +from utils.console import eprint + + +def restart_jail(jail_name): + """ + Restart jail with given name. + """ + + returncode = stop_jail(jail_name) + if returncode != 0: + eprint("Abort restart.") + return returncode + + return start_jail(jail_name) diff --git a/src/jlmkr/donor/jlmkr.py b/src/jlmkr/donor/jlmkr.py index e2a5634..b70d4be 100755 --- a/src/jlmkr/donor/jlmkr.py +++ b/src/jlmkr/donor/jlmkr.py @@ -187,20 +187,8 @@ def shell_jail(args): return subprocess.run(["machinectl", "shell"] + args).returncode -from actions.start import add_hook, start_jail - - -def restart_jail(jail_name): - """ - Restart jail with given name. - """ - - returncode = stop_jail(jail_name) - if returncode != 0: - eprint("Abort restart.") - return returncode - - return start_jail(jail_name) +from actions.start import start_jail +from actions.restart import restart_jail def cleanup(jail_path):