Fix startup
This commit is contained in:
parent
d7b30011b0
commit
a15d5d10f5
33
jlmkr.py
33
jlmkr.py
|
@ -307,7 +307,7 @@ def add_hook(jail_path, systemd_run_additional_args, hook_command, hook_type):
|
||||||
systemd_run_additional_args += [f"--property={hook_type}={hook_file}"]
|
systemd_run_additional_args += [f"--property={hook_type}={hook_file}"]
|
||||||
|
|
||||||
|
|
||||||
def start_jail(jail_name, check_startup_enabled=False):
|
def start_jail(jail_name):
|
||||||
"""
|
"""
|
||||||
Start jail with given name.
|
Start jail with given name.
|
||||||
"""
|
"""
|
||||||
|
@ -315,9 +315,9 @@ def start_jail(jail_name, check_startup_enabled=False):
|
||||||
f"Skipped starting jail {jail_name}. It appears to be running already..."
|
f"Skipped starting jail {jail_name}. It appears to be running already..."
|
||||||
)
|
)
|
||||||
|
|
||||||
if not check_startup_enabled and jail_is_running(jail_name):
|
if jail_is_running(jail_name):
|
||||||
eprint(skip_start_message)
|
eprint(skip_start_message)
|
||||||
return 1
|
return 0
|
||||||
|
|
||||||
jail_path = get_jail_path(jail_name)
|
jail_path = get_jail_path(jail_name)
|
||||||
jail_config_path = get_jail_config_path(jail_name)
|
jail_config_path = get_jail_config_path(jail_name)
|
||||||
|
@ -328,18 +328,6 @@ def start_jail(jail_name, check_startup_enabled=False):
|
||||||
eprint("Aborting...")
|
eprint("Aborting...")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Only start if the startup setting is enabled in the config
|
|
||||||
if check_startup_enabled:
|
|
||||||
if config.get("startup") == "1":
|
|
||||||
# We should start this jail based on the startup config...
|
|
||||||
if jail_is_running(jail_name):
|
|
||||||
# ...but we can skip if it's already running
|
|
||||||
eprint(skip_start_message)
|
|
||||||
return 0
|
|
||||||
else:
|
|
||||||
# Skip starting this jail since the startup config setting is not enabled
|
|
||||||
return 0
|
|
||||||
|
|
||||||
systemd_run_additional_args = [
|
systemd_run_additional_args = [
|
||||||
f"--unit={SYMLINK_NAME}-{jail_name}",
|
f"--unit={SYMLINK_NAME}-{jail_name}",
|
||||||
f"--working-directory=./{jail_path}",
|
f"--working-directory=./{jail_path}",
|
||||||
|
@ -1443,12 +1431,17 @@ def startup_jails():
|
||||||
if returncode != 0:
|
if returncode != 0:
|
||||||
eprint("Failed to install jailmaker. Abort startup.")
|
eprint("Failed to install jailmaker. Abort startup.")
|
||||||
return returncode
|
return returncode
|
||||||
|
|
||||||
|
start_failure = False
|
||||||
for jail_name in get_all_jail_names():
|
for jail_name in get_all_jail_names():
|
||||||
returncode = start_jail(jail_name, True)
|
config = parse_config(get_jail_config_path(jail_name))
|
||||||
eprint(f"Failed to start jail {jail_name}. Abort startup.")
|
if config and config.get("startup") == "1":
|
||||||
return returncode
|
if start_jail(jail_name) != 0:
|
||||||
|
start_failure = True
|
||||||
|
|
||||||
|
if start_failure:
|
||||||
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue