diff options
| author | Paul Buetow <paul@buetow.org> | 2024-03-20 18:37:39 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-03-20 18:37:39 +0200 |
| commit | d3922f5c819dd9dea0bb7ac8a0108ab060df04f0 (patch) | |
| tree | 2e033368ee48e6b52ad4fd438bbebd0d8cb1ce25 | |
| parent | 51f1a20a766d7795e18259d2c03f135fb5ee4138 (diff) | |
add health-based DNS failover
| -rw-r--r-- | frontends/scripts/dns-failover.ksh | 15 |
1 files changed, 15 insertions, 0 deletions
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) }') |
