only update records and notify if IP has changed
Build and Push Container / build-and-push (push) Successful in 1m19s
Build and Push Container / build-and-push (push) Successful in 1m19s
This commit is contained in:
@@ -154,12 +154,13 @@ def _update_route53_records(
|
||||
logger.info("Skipping IPv4 for %s (global skip or no IPv4 available)", record["record"])
|
||||
else:
|
||||
logger.info("Updating IPv4 for %s -> %s", record["record"], public_ipv4)
|
||||
route53_update_ipv4(
|
||||
changed = route53_update_ipv4(
|
||||
hosted_zone_id=ROUTE53_HOSTED_ZONE_ID, # type: ignore[arg-type]
|
||||
record=record["record"],
|
||||
public_ipv4=public_ipv4,
|
||||
)
|
||||
updated_ipv4.add(record["record"])
|
||||
if changed:
|
||||
updated_ipv4.add(record["record"])
|
||||
|
||||
if record.get("skip_ipv6"):
|
||||
logger.info("Skipping IPv6 for %s (skip_ipv6=true)", record["record"])
|
||||
@@ -167,12 +168,13 @@ def _update_route53_records(
|
||||
logger.info("Skipping IPv6 for %s (global skip or no IPv6 available)", record["record"])
|
||||
else:
|
||||
logger.info("Updating IPv6 for %s -> %s", record["record"], public_ipv6)
|
||||
route53_update_ipv6(
|
||||
changed = route53_update_ipv6(
|
||||
hosted_zone_id=ROUTE53_HOSTED_ZONE_ID, # type: ignore[arg-type]
|
||||
record=record["record"],
|
||||
public_ipv6=public_ipv6,
|
||||
)
|
||||
updated_ipv6.add(record["record"])
|
||||
if changed:
|
||||
updated_ipv6.add(record["record"])
|
||||
|
||||
logger.info("=== Done processing Route53 record: %s ===", record["record"])
|
||||
|
||||
@@ -185,15 +187,7 @@ def _update_unifi_records(
|
||||
public_ipv6: str | None,
|
||||
) -> tuple[set[str], set[str]]:
|
||||
logger.info("Processing %d UniFi record(s)", len(unifi_config["records"]))
|
||||
updated_ipv4: set[str] = set()
|
||||
updated_ipv6: set[str] = set()
|
||||
for record in unifi_config["records"]:
|
||||
domain = record["record"]
|
||||
if public_ipv4 and not record.get("skip_ipv4"):
|
||||
updated_ipv4.add(domain)
|
||||
if public_ipv6 and not record.get("skip_ipv6"):
|
||||
updated_ipv6.add(domain)
|
||||
unifi_update_records(
|
||||
updated_ipv4, updated_ipv6 = unifi_update_records(
|
||||
unifi_config=unifi_config,
|
||||
ipv4=public_ipv4,
|
||||
ipv6=public_ipv6,
|
||||
@@ -329,13 +323,19 @@ def main() -> None:
|
||||
|
||||
if route53_records:
|
||||
if route53_success:
|
||||
send_ntfy_notification("Route53 Update Successful", f"Records updated:\n{route53_text}", priority=4)
|
||||
has_changes = bool(route53_updated_ipv4 or route53_updated_ipv6)
|
||||
ntfy_priority = 4 if has_changes else 2
|
||||
ntfy_title = "Route53 IP Changed" if has_changes else "Route53 IP Unchanged"
|
||||
send_ntfy_notification(ntfy_title, f"Records updated:\n{route53_text}", priority=ntfy_priority)
|
||||
else:
|
||||
send_ntfy_notification("Route53 Update Failed", f"Records:\n{route53_text}", priority=2)
|
||||
|
||||
if unifi_records:
|
||||
if unifi_success:
|
||||
send_ntfy_notification("UniFi Update Successful", f"Records updated:\n{unifi_text}", priority=4)
|
||||
has_changes = bool(unifi_updated_ipv4 or unifi_updated_ipv6)
|
||||
ntfy_priority = 4 if has_changes else 2
|
||||
ntfy_title = "UniFi IP Changed" if has_changes else "UniFi IP Unchanged"
|
||||
send_ntfy_notification(ntfy_title, f"Records updated:\n{unifi_text}", priority=ntfy_priority)
|
||||
else:
|
||||
send_ntfy_notification("UniFi Update Failed", f"Records:\n{unifi_text}", priority=2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user