From d3922f5c819dd9dea0bb7ac8a0108ab060df04f0 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 20 Mar 2024 18:37:39 +0200 Subject: add health-based DNS failover --- frontends/scripts/dns-failover.ksh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'frontends/scripts') diff --git a/frontends/scripts/dns-failover.ksh b/frontends/scripts/dns-failover.ksh index 4042ee3..6566a5e 100644 --- a/frontends/scripts/dns-failover.ksh +++ b/frontends/scripts/dns-failover.ksh @@ -18,6 +18,21 @@ determine_master_and_standby () { standby=$tmp fi + local -i health_ok=1 + if ! ftp -4 -o - https://$master/index.txt | grep "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 + echo "https://$master IPv6 health check failed" + health_ok=0 + fi + + if [ $health_ok -eq 0 ]; then + local tmp=$master + master=$standby + standby=$tmp + fi + echo "Master is $master, standby is $standby" MASTER_A=$(host $master | awk '/has address/ { print $(NF) }') -- cgit v1.2.3