Accept config template from stdin

Closes #208
This commit is contained in:
Jip-Hop 2024-06-28 15:51:01 +02:00
parent e1f1d07872
commit 01e1156832
1 changed files with 9 additions and 5 deletions

View File

@ -1276,6 +1276,10 @@ 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
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}.")
@ -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", #