Don't stop and wait if jail is not running
This commit is contained in:
parent
c908b077c2
commit
c4a5dd1c75
19
jlmkr.py
19
jlmkr.py
|
@ -457,6 +457,7 @@ def restart_jail(jail_name):
|
||||||
"""
|
"""
|
||||||
Restart jail with given name.
|
Restart jail with given name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
returncode = stop_jail_and_wait(jail_name)
|
returncode = stop_jail_and_wait(jail_name)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
eprint("Abort restart.")
|
eprint("Abort restart.")
|
||||||
|
@ -470,7 +471,7 @@ def cleanup(jail_path):
|
||||||
Cleanup after aborted jail creation.
|
Cleanup after aborted jail creation.
|
||||||
"""
|
"""
|
||||||
if os.path.isdir(jail_path):
|
if os.path.isdir(jail_path):
|
||||||
eprint(f"Cleaning up: {jail_path}")
|
eprint(f"Cleaning up: {jail_path}.")
|
||||||
shutil.rmtree(jail_path)
|
shutil.rmtree(jail_path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1107,6 +1108,9 @@ def stop_jail_and_wait(jail_name):
|
||||||
Wait for jail with given name to stop.
|
Wait for jail with given name to stop.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not jail_is_running(jail_name):
|
||||||
|
return 0
|
||||||
|
|
||||||
returncode = stop_jail(jail_name)
|
returncode = stop_jail(jail_name)
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
eprint("Error while stopping jail.")
|
eprint("Error while stopping jail.")
|
||||||
|
@ -1136,15 +1140,14 @@ def remove_jail(jail_name):
|
||||||
check = input(f'\nCAUTION: Type "{jail_name}" to confirm jail deletion!\n\n')
|
check = input(f'\nCAUTION: Type "{jail_name}" to confirm jail deletion!\n\n')
|
||||||
|
|
||||||
if check == jail_name:
|
if check == jail_name:
|
||||||
|
print()
|
||||||
jail_path = get_jail_path(jail_name)
|
jail_path = get_jail_path(jail_name)
|
||||||
if jail_is_running(jail_name):
|
returncode = stop_jail_and_wait(jail_name)
|
||||||
print()
|
if returncode != 0:
|
||||||
returncode = stop_jail_and_wait(jail_name)
|
return returncode
|
||||||
if returncode != 0:
|
|
||||||
return returncode
|
|
||||||
|
|
||||||
print(f"\nCleaning up: {jail_path}")
|
print()
|
||||||
shutil.rmtree(jail_path)
|
cleanup(jail_path)
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
eprint("Wrong name, nothing happened.")
|
eprint("Wrong name, nothing happened.")
|
||||||
|
|
Loading…
Reference in New Issue