Align NOMAD Pi-hole replica with stack SOP

This commit is contained in:
Fizzlepoof
2026-05-15 15:43:17 +00:00
parent f3469e35fd
commit ce167138cf
5 changed files with 19 additions and 12 deletions

View File

@@ -27,22 +27,27 @@ def main() -> int:
env = load_env(ENV_FILE)
required = [
'LAN_INTERFACE', 'VIP_CIDR', 'KEEPALIVED_ROUTER_ID', 'KEEPALIVED_STATE',
'KEEPALIVED_PRIORITY', 'KEEPALIVED_PASSWORD', 'PD_PIHOLE_WEB_PORT'
'KEEPALIVED_PRIORITY', 'KEEPALIVED_PASSWORD'
]
missing = [k for k in required if not env.get(k)]
if missing:
print(f'Missing required vars in {ENV_FILE}: {", ".join(missing)}', file=sys.stderr)
return 1
web_port = env.get('PIHOLE_WEB_PORT') or env.get('PD_PIHOLE_WEB_PORT') or env.get('SERENITY_PIHOLE_WEB_PORT') or env.get('RPI4_PIHOLE_WEB_PORT')
if not web_port:
print('Missing Pi-hole web port in .env (set PIHOLE_WEB_PORT or node-specific port variable).', file=sys.stderr)
return 1
keepalived_password = env['KEEPALIVED_PASSWORD']
if len(keepalived_password) > 8:
print('KEEPALIVED_PASSWORD must be 8 characters or fewer for VRRP PASS auth.', file=sys.stderr)
return 1
try:
web_port_hex = f"{int(env['PD_PIHOLE_WEB_PORT']):04X}"
web_port_hex = f"{int(web_port):04X}"
except ValueError:
print('PD_PIHOLE_WEB_PORT must be an integer.', file=sys.stderr)
print('Pi-hole web port must be an integer.', file=sys.stderr)
return 1
router_id_name = f"pihole_{re.sub(r'[^a-z0-9]+', '_', env['KEEPALIVED_STATE'].lower())}"
@@ -55,6 +60,7 @@ def main() -> int:
'NOPREEMPT_LINE': nopreempt_line,
}
replacements.update({k: env[k] for k in required})
replacements['PIHOLE_WEB_PORT'] = web_port
for key, value in replacements.items():
rendered = rendered.replace('${' + key + '}', value)