Extract restart action
This commit is contained in:
parent
ef479d7052
commit
d26e8cc518
|
@ -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)
|
|
@ -187,20 +187,8 @@ def shell_jail(args):
|
||||||
return subprocess.run(["machinectl", "shell"] + args).returncode
|
return subprocess.run(["machinectl", "shell"] + args).returncode
|
||||||
|
|
||||||
|
|
||||||
from actions.start import add_hook, start_jail
|
from actions.start import start_jail
|
||||||
|
from actions.restart import restart_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)
|
|
||||||
|
|
||||||
|
|
||||||
def cleanup(jail_path):
|
def cleanup(jail_path):
|
||||||
|
|
Loading…
Reference in New Issue