Skip to content

Instantly share code, notes, and snippets.

@retraut
Forked from sreimers/failover.sh
Created February 1, 2017 19:03
Show Gist options
  • Save retraut/f046c409cfe44b08132a5d4c090c78d5 to your computer and use it in GitHub Desktop.
Save retraut/f046c409cfe44b08132a5d4c090c78d5 to your computer and use it in GitHub Desktop.
Hetzner simple Failover Script
#!/bin/bash
#------------------------------------------------------------
# title :failover.sh
# description :This script will call hetzner failover api
# author :Sebastian Reimers <support@miete-admin.de>
# date :18.02.2016
# version :0.1
#------------------------------------------------------------
# settings
hlogin=""
hpassword=""
hserver="https://robot-ws.your-server.de/failover"
failoverip=""
#------------------------------------------------------------
lhost=$(cat /tmp/failover_last)
chost=$(curl http://10.10.1.1/host.html 2>/dev/null)
if [ "$lhost" != "$chost" ]; then
echo "$lhost != $chost"
curl -u $hlogin:$hpassword $hserver/$failoverip -d active_server_ip=$chost
echo $chost > /tmp/failover_last
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment