Skip to content

Commit

Permalink
Extract restart action
Browse files Browse the repository at this point in the history
  • Loading branch information
jonct committed Jul 15, 2024
1 parent ef479d7 commit d26e8cc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
24 changes: 24 additions & 0 deletions src/jlmkr/actions/restart.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 2 additions & 14 deletions src/jlmkr/donor/jlmkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d26e8cc

Please sign in to comment.