Created
February 19, 2016 06:45
-
-
Save sreimers/c5ed3e1381d3d34bc5d9 to your computer and use it in GitHub Desktop.
Hetzner simple Failover Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#------------------------------------------------------------ | |
# title :failover.sh | |
# description :This script will call hetzner failover api | |
# author :Sebastian Reimers <[email protected]> | |
# 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
I would suggest getting the variable
lhost
from hetzner:This would work on a freshly booted machine where nothing is in /tmp.