summaryrefslogtreecommitdiff
path: root/frontends/scripts/dns-failover.ksh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-03-21 20:33:39 +0200
committerPaul Buetow <paul@buetow.org>2024-03-21 20:33:39 +0200
commitaecc42cd300e186ccab85c4bf8deed1b0dd602d9 (patch)
treeceda31ad460bce760771835e27cb290ca41926a1 /frontends/scripts/dns-failover.ksh
parent95c2365df04de6b8bfa964f672ab77aeb3ec792e (diff)
make CRON send out an email on DNS failover change
Diffstat (limited to 'frontends/scripts/dns-failover.ksh')
-rw-r--r--frontends/scripts/dns-failover.ksh25
1 files changed, 13 insertions, 12 deletions
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