mirror of
https://git.nolog.cz/NoLog.cz/nginx-configurator.git
synced 2025-01-31 03:43:35 +01:00
remove auto and custom sites distinction
This commit is contained in:
parent
01724ea897
commit
bd7f372f97
2 changed files with 4 additions and 21 deletions
|
@ -61,10 +61,7 @@ def gather_autossl_directives(nginx_conf: Path):
|
||||||
|
|
||||||
def get_site_files(nginx_dir: Path) -> List[Path]:
|
def get_site_files(nginx_dir: Path) -> List[Path]:
|
||||||
names = []
|
names = []
|
||||||
for file in (nginx_dir / "sites/auto").iterdir():
|
for file in (nginx_dir / "sites").iterdir():
|
||||||
if file.is_file() and re.match(r"\d+-.+\.conf", file.name):
|
|
||||||
names.append(file)
|
|
||||||
for file in (nginx_dir / "sites/custom").iterdir():
|
|
||||||
if file.is_file() and re.match(r"\d+-.+\.conf", file.name):
|
if file.is_file() and re.match(r"\d+-.+\.conf", file.name):
|
||||||
names.append(file)
|
names.append(file)
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ def new(ctx):
|
||||||
|
|
||||||
# assume the user wants to edit the file if we are opening the editor
|
# assume the user wants to edit the file if we are opening the editor
|
||||||
service_file = Path(
|
service_file = Path(
|
||||||
NGINX_DIR / "sites" / ("custom" if should_open_editor else "auto") / filename
|
NGINX_DIR / "sites" / filename
|
||||||
)
|
)
|
||||||
|
|
||||||
ok = False
|
ok = False
|
||||||
|
@ -227,9 +227,6 @@ def new(ctx):
|
||||||
break
|
break
|
||||||
if new_cfg:
|
if new_cfg:
|
||||||
config = new_cfg
|
config = new_cfg
|
||||||
else:
|
|
||||||
# correct previous assumption
|
|
||||||
service_file = NGINX_DIR / "sites/auto" / filename
|
|
||||||
else:
|
else:
|
||||||
ok, out = test_config(config, service_file)
|
ok, out = test_config(config, service_file)
|
||||||
if not ok:
|
if not ok:
|
||||||
|
@ -241,7 +238,6 @@ def new(ctx):
|
||||||
if choice == "abort":
|
if choice == "abort":
|
||||||
break
|
break
|
||||||
should_open_editor = True
|
should_open_editor = True
|
||||||
service_file = NGINX_DIR / "sites/custom" / filename
|
|
||||||
|
|
||||||
if not ok:
|
if not ok:
|
||||||
Path(f"/etc/nginx/ssl/{id}.conf").unlink(missing_ok=True)
|
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):
|
def edit(ctx, service: str):
|
||||||
"""Edit a service"""
|
"""Edit a service"""
|
||||||
filename = service if service.endswith(".conf") else service + ".conf"
|
filename = service if service.endswith(".conf") else service + ".conf"
|
||||||
auto = True
|
|
||||||
|
|
||||||
file = NGINX_DIR / "sites/auto" / filename
|
file = NGINX_DIR / "sites" / filename
|
||||||
if not file.exists():
|
|
||||||
auto = False
|
|
||||||
file = NGINX_DIR / "sites/custom" / filename
|
|
||||||
|
|
||||||
if not file.exists():
|
if not file.exists():
|
||||||
click.secho(f"Service {filename} does not exist", fg="red")
|
click.secho(f"Service {filename} does not exist", fg="red")
|
||||||
|
@ -281,9 +273,6 @@ def edit(ctx, service: str):
|
||||||
if not ok:
|
if not ok:
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
if auto:
|
|
||||||
file = file.rename(NGINX_DIR / "sites/custom" / filename)
|
|
||||||
|
|
||||||
file.write_text(new_cfg)
|
file.write_text(new_cfg)
|
||||||
|
|
||||||
ctx.invoke(reload)
|
ctx.invoke(reload)
|
||||||
|
@ -296,10 +285,7 @@ def delete(ctx, service: str):
|
||||||
"""Delete a service"""
|
"""Delete a service"""
|
||||||
filename = service if service.endswith(".conf") else service + ".conf"
|
filename = service if service.endswith(".conf") else service + ".conf"
|
||||||
|
|
||||||
file = NGINX_DIR / "sites/auto" / filename
|
file = NGINX_DIR / "sites" / filename
|
||||||
if not file.exists():
|
|
||||||
file = NGINX_DIR / "sites/custom" / filename
|
|
||||||
|
|
||||||
if not file.exists():
|
if not file.exists():
|
||||||
click.secho(f"Service {filename} does not exist", fg="red")
|
click.secho(f"Service {filename} does not exist", fg="red")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue