From: Shane Jaroch Date: Wed, 21 Jan 2026 01:44:48 +0000 (-0500) Subject: Fix sitemap generation: Use correct config per ENV and prefix Git URLs X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=7472b6eea74d4b3399da92e0b14c67c435de6534;p=nutratech%2Fvps-root.git Fix sitemap generation: Use correct config per ENV and prefix Git URLs --- diff --git a/Makefile b/Makefile index b85101d..43685ef 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ VPS := $(VPS_USER)@$(VPS_HOST) .PHONY: stage/nginx stage/nginx: ##H @Remote Stage files on the remote VPS @echo "Staging files on $(VPS_HOST) (ENV=$(ENV))..." - python3 scripts/gen_services_map.py + python3 scripts/gen_services_map.py etc/nginx/conf.d/default.$(ENV).conf ssh $(VPS) 'rm -rf ~/.nginx-staging && mkdir -p ~/.nginx-staging/etc/nginx/conf.d ~/.nginx-staging/scripts/gitweb-simplefrontend' scp -q -r etc/nginx/conf.d/*.conf $(VPS):~/.nginx-staging/etc/nginx/conf.d/ scp -q etc/gitweb.conf $(VPS):~/.nginx-staging/etc/gitweb.conf diff --git a/scripts/gen_services_map.py b/scripts/gen_services_map.py index c5bc363..5b4270f 100755 --- a/scripts/gen_services_map.py +++ b/scripts/gen_services_map.py @@ -64,31 +64,45 @@ def parse_file(path, pattern, is_version=False): return items -def get_all_services(): +import sys +import argparse + +def get_all_services(custom_config_path=None): # Regex to find "Version X: Description" lines version_pattern = re.compile(r"^\s*#\s*Version\s+(\w+):\s*(.+)$", re.MULTILINE) service_pattern = re.compile(r"^\s*#\s*Service:\s*(.+?)\s*\|\s*(.+)$", re.MULTILINE) services_git = parse_file(NGINX_CONF, version_pattern, is_version=True) - # Locate default.conf - # On Server: Read the live deployed config - live_default = Path("/etc/nginx/conf.d/default.conf") - # On Local: Read default.dev.conf - local_dev = REPO_ROOT / "etc/nginx/conf.d/default.dev.conf" - - if live_default.exists(): - DEFAULT_CONF = live_default - print(f"Using live config: {DEFAULT_CONF}") + DEFAULT_CONF = None + if custom_config_path: + p = Path(custom_config_path) + if p.exists(): + DEFAULT_CONF = p + print(f"Using custom config: {DEFAULT_CONF}") + else: + print(f"Error: Custom config not found at {p}") + sys.exit(1) else: - DEFAULT_CONF = local_dev - print(f"Using local config: {DEFAULT_CONF}") + # Locate default.conf fallback (old logic) + # On Server: Read the live deployed config + live_default = Path("/etc/nginx/conf.d/default.conf") + # On Local: Read default.dev.conf + local_dev = REPO_ROOT / "etc/nginx/conf.d/default.dev.conf" + + if live_default.exists(): + DEFAULT_CONF = live_default + print(f"Using live config: {DEFAULT_CONF}") + else: + DEFAULT_CONF = local_dev + print(f"Using local config: {DEFAULT_CONF}") services_other = parse_file(DEFAULT_CONF, service_pattern, is_version=False) return services_git, services_other + def generate_html(title, groups): """ groups: list of tuples (header_name, services_list) @@ -111,9 +125,19 @@ def generate_html(title, groups): return HTML_TEMPLATE.format(title=title, content=content_html) + def main(): + parser = argparse.ArgumentParser(description="Generate HTML services map from Nginx config") + parser.add_argument("config_path", nargs="?", help="Path to the Nginx configuration file") + args = parser.parse_args() + print(f"Reading configs...") - services_git, services_other = get_all_services() + services_git, services_other = get_all_services(args.config_path) + + # Prefix Git services with the correct domain + for s in services_git: + if s["url"].startswith("/"): + s["url"] = f"https://git.nutra.tk{s['url']}" # Output 1: Git Services Only print(f"Generating Git Services map with {len(services_git)} items...") @@ -147,3 +171,4 @@ def main(): if __name__ == "__main__": main() +