From 01e1156832e7df049f94b764dd35f091ca76571c Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:51:01 +0200 Subject: [PATCH] Accept config template from stdin Closes #208 --- jlmkr.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jlmkr.py b/jlmkr.py index a90267e..748111a 100755 --- a/jlmkr.py +++ b/jlmkr.py @@ -1276,10 +1276,14 @@ def create_jail(**kwargs): if jail_config_path: # TODO: fallback to default values for e.g. distro and release if they are not in the config file - print(f"Creating jail {jail_name} from config template {jail_config_path}.") - if jail_config_path not in config.read(jail_config_path): - eprint(f"Failed to read config template {jail_config_path}.") - return 1 + if jail_config_path == "-": + print(f"Creating jail {jail_name} from config template passed via stdin.") + config.read_string(sys.stdin.read()) + else: + print(f"Creating jail {jail_name} from config template {jail_config_path}.") + if jail_config_path not in config.read(jail_config_path): + eprint(f"Failed to read config template {jail_config_path}.") + return 1 else: print(f"Creating jail {jail_name} with default config.") config.read_string(DEFAULT_CONFIG) @@ -1936,7 +1940,7 @@ def main(): commands["create"].add_argument( "-c", # "--config", - help="path to config file template", + help="path to config file template or - for stdin", ) commands["create"].add_argument( "-gi", #