-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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 utils.console import eprint | ||
from utils.jail_dataset import jail_is_running | ||
|
||
|
||
def stop_jail(jail_name): | ||
""" | ||
Stop jail with given name and wait until stopped. | ||
""" | ||
|
||
if not jail_is_running(jail_name): | ||
return 0 | ||
|
||
returncode = subprocess.run(["machinectl", "poweroff", jail_name]).returncode | ||
if returncode != 0: | ||
eprint("Error while stopping jail.") | ||
return returncode | ||
|
||
print(f"Wait for {jail_name} to stop", end="", flush=True) | ||
|
||
while jail_is_running(jail_name): | ||
time.sleep(1) | ||
print(".", end="", flush=True) | ||
|
||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters