Extract restart action

This commit is contained in:
jonct 2024-07-15 02:01:35 -04:00
parent ef479d7052
commit d26e8cc518
No known key found for this signature in database
2 changed files with 26 additions and 14 deletions

View File

@ -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
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)

View File

@ -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):