Skip to content

Instantly share code, notes, and snippets.

@sitano
Created May 18, 2015 13:09
Show Gist options
  • Save sitano/d147496436d688fccc50 to your computer and use it in GitHub Desktop.
Save sitano/d147496436d688fccc50 to your computer and use it in GitHub Desktop.
Consul 0.4.x startup WAN reconnect script
#!/bin/bash
. /etc/environment
PUBLIC_IPV4=`cat /etc/network/interfaces | grep -A 2 'iface eth0' | head -n +2 | tail -n 1 | awk '{print $2}'`
PRIVATE_IPV4=`cat /etc/network/interfaces | grep -A 2 'iface eth1' | head -n +2 | tail -n 1 | awk '{print $2}'`
SERVERS=(DATACENTER1 DATACENTER2 DATACENTER3)
for SERVER in "${SERVERS[@]}"; do
curl http://${PRIVATE_IPV4}:8500/v1/agent/join/${SERVER}.mysupercompany.com:8302?wan=1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment