From aecc42cd300e186ccab85c4bf8deed1b0dd602d9 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 21 Mar 2024 20:33:39 +0200 Subject: make CRON send out an email on DNS failover change --- frontends/scripts/dns-failover.ksh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'frontends/scripts') diff --git a/frontends/scripts/dns-failover.ksh b/frontends/scripts/dns-failover.ksh index 6fced80..c2879f3 100644 --- a/frontends/scripts/dns-failover.ksh +++ b/frontends/scripts/dns-failover.ksh @@ -87,7 +87,7 @@ failover_zone () { if diff -u $zone_file.old.noserial.tmp $zone_file.new.noserial.tmp; then echo "The zone $zone_file hasn't changed" rm $zone_file.*.tmp - return + return 0 fi cp $zone_file $zone_file.bak @@ -103,7 +103,7 @@ failover_zone () { echo "Reloading nsd" nsd-control reload zone_is_ok $zone - exit 1 + return 2 fi for cleanup in invalid bak; do @@ -113,21 +113,22 @@ failover_zone () { done echo "Failover of zone $zone to $MASTER completed" - return 0 + return 1 } main () { - local -r mail_tmp=$(mktemp) - - determine_master_and_standby | tee $mail_tmp + local -i ec=0 + if ! determine_master_and_standby; then + ec=1 + fi for zone_file in $ZONES_DIR/*.zone; do - failover_zone $zone_file - done | tee -a $mail_tmp + if ! failover_zone $zone_file; then + ec=1 + fi + done - if grep -q 'Failover.*completed' $mail_tmp; then - cat $mail_tmp | mail -s 'DNS failover performed' root - fi - rm $mail_tmp + # ec other than 0 will tell CRON to send out an email! + exit $ec } main -- cgit v1.2.3