diff options
| author | Paul Buetow <paul@buetow.org> | 2024-03-20 18:45:37 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-03-20 18:45:37 +0200 |
| commit | fa359bb8b9e42d3d5cd30d92ea7c8184aa16b827 (patch) | |
| tree | 54a6aa1ed1bb1015c782b66f68594f117eda2f9a /frontends/scripts/dns-failover.ksh | |
| parent | d3922f5c819dd9dea0bb7ac8a0108ab060df04f0 (diff) | |
add failover notification mail
Diffstat (limited to 'frontends/scripts/dns-failover.ksh')
| -rw-r--r-- | frontends/scripts/dns-failover.ksh | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/frontends/scripts/dns-failover.ksh b/frontends/scripts/dns-failover.ksh index 6566a5e..580dc03 100644 --- a/frontends/scripts/dns-failover.ksh +++ b/frontends/scripts/dns-failover.ksh @@ -19,10 +19,10 @@ determine_master_and_standby () { fi local -i health_ok=1 - if ! ftp -4 -o - https://$master/index.txt | grep "Welcome to $master"; then + if ! ftp -4 -o - https://$master/index.txt | grep -q "Welcome to $master"; then echo "https://$master IPv4 health check failed" health_ok=0 - elif ! ftp -6 -o - https://$master/index.txt | grep "Welcome to $master"; then + elif ! ftp -6 -o - https://$master/index.txt | grep -q "Welcome to $master"; then echo "https://$master IPv6 health check failed" health_ok=0 fi @@ -112,7 +112,12 @@ main () { determine_master_and_standby for zone_file in $ZONES_DIR/*.zone; do failover_zone $zone_file - done + done } -main +main | tee /tmp/dns-failover-notification.tmp + +if grep -q 'Failover.*completed' /tmp/dns-failover-notification.tmp; then + cat /tmp/dns-failover-notification.tmp | mail -s 'DNS failover performed' root + rm /tmp/dns-failover-notification.tmp +fi |
