From bd7f372f9735eb8f02d9c70b0e823b10b3a8f862 Mon Sep 17 00:00:00 2001 From: bain Date: Fri, 17 Nov 2023 14:11:10 +0100 Subject: [PATCH] remove auto and custom sites distinction --- nginx_configurator/certs.py | 5 +---- nginx_configurator/main.py | 20 +++----------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/nginx_configurator/certs.py b/nginx_configurator/certs.py index 264a4f9..4c98384 100644 --- a/nginx_configurator/certs.py +++ b/nginx_configurator/certs.py @@ -61,10 +61,7 @@ def gather_autossl_directives(nginx_conf: Path): def get_site_files(nginx_dir: Path) -> List[Path]: names = [] - for file in (nginx_dir / "sites/auto").iterdir(): - if file.is_file() and re.match(r"\d+-.+\.conf", file.name): - names.append(file) - for file in (nginx_dir / "sites/custom").iterdir(): + for file in (nginx_dir / "sites").iterdir(): if file.is_file() and re.match(r"\d+-.+\.conf", file.name): names.append(file) diff --git a/nginx_configurator/main.py b/nginx_configurator/main.py index 10cd5ea..0949fe6 100644 --- a/nginx_configurator/main.py +++ b/nginx_configurator/main.py @@ -215,7 +215,7 @@ def new(ctx): # assume the user wants to edit the file if we are opening the editor service_file = Path( - NGINX_DIR / "sites" / ("custom" if should_open_editor else "auto") / filename + NGINX_DIR / "sites" / filename ) ok = False @@ -227,9 +227,6 @@ def new(ctx): break if new_cfg: config = new_cfg - else: - # correct previous assumption - service_file = NGINX_DIR / "sites/auto" / filename else: ok, out = test_config(config, service_file) if not ok: @@ -241,7 +238,6 @@ def new(ctx): if choice == "abort": break should_open_editor = True - service_file = NGINX_DIR / "sites/custom" / filename if not ok: Path(f"/etc/nginx/ssl/{id}.conf").unlink(missing_ok=True) @@ -261,12 +257,8 @@ def shell_complete_service(ctx, param, incomplete): def edit(ctx, service: str): """Edit a service""" filename = service if service.endswith(".conf") else service + ".conf" - auto = True - file = NGINX_DIR / "sites/auto" / filename - if not file.exists(): - auto = False - file = NGINX_DIR / "sites/custom" / filename + file = NGINX_DIR / "sites" / filename if not file.exists(): click.secho(f"Service {filename} does not exist", fg="red") @@ -281,9 +273,6 @@ def edit(ctx, service: str): if not ok: exit(1) - if auto: - file = file.rename(NGINX_DIR / "sites/custom" / filename) - file.write_text(new_cfg) ctx.invoke(reload) @@ -296,10 +285,7 @@ def delete(ctx, service: str): """Delete a service""" filename = service if service.endswith(".conf") else service + ".conf" - file = NGINX_DIR / "sites/auto" / filename - if not file.exists(): - file = NGINX_DIR / "sites/custom" / filename - + file = NGINX_DIR / "sites" / filename if not file.exists(): click.secho(f"Service {filename} does not exist", fg="red") exit(1)