#!/bin/bash # Keepalived notify_master: dieser Node hat die VIP übernommen. # # KEIN Auto-Promote — Split-Brain-Schutz durch manuelle Promotion. # Admin muss "edgeguard-ctl promote" ausführen wenn PG-Failover gewünscht. logger -t keepalived -p daemon.warning \ "MASTER: VIP übernommen — PG-Rolle ist noch '$(cat /var/lib/edgeguard/pg_role 2>/dev/null || echo standby)'. Für PG-Failover: edgeguard-ctl promote" # Dienste reloaden/starten damit sie die neu aktiven VIPs binden. # Squid + Unbound + HAProxy binden beim Start an spezifische IPs — war der Dienst # während des BACKUP-Zustands gecrasht oder gestoppt, muss er gestartet werden. for svc in squid.service unbound.service haproxy.service; do if systemctl is-active --quiet "$svc"; then systemctl reload "$svc" 2>/dev/null || systemctl restart "$svc" 2>/dev/null || true else systemctl start "$svc" 2>/dev/null || true fi done logger -t keepalived -p daemon.info "MASTER: squid/unbound/haproxy reload-or-start nach VIP-Übernahme" # Alert an die API schicken (best-effort, ignoriert Fehler) curl -sf --max-time 3 -X POST \ -H "Content-Type: application/json" \ -d '{"level":"warning","message":"Keepalived MASTER: VIP übernommen. Wenn PG-Failover gewünscht: edgeguard-ctl promote ausführen.","source":"keepalived"}' \ http://127.0.0.1:9443/api/v1/internal/alert > /dev/null 2>&1 || true