summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-03-20 18:45:37 +0200
committerPaul Buetow <paul@buetow.org>2024-03-20 18:45:37 +0200
commitfa359bb8b9e42d3d5cd30d92ea7c8184aa16b827 (patch)
tree54a6aa1ed1bb1015c782b66f68594f117eda2f9a /frontends
parentd3922f5c819dd9dea0bb7ac8a0108ab060df04f0 (diff)
add failover notification mail
Diffstat (limited to 'frontends')
-rw-r--r--frontends/scripts/dns-failover.ksh13
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