diff --git a/debian/services/lib.sh b/debian/services/lib.sh index ffd7b198e0f4581fa7ada8add84b9726d93d1f5d..32a93e0857846e5dad3c809bbdfb86849e03bac8 100644 --- a/debian/services/lib.sh +++ b/debian/services/lib.sh @@ -10,6 +10,20 @@ if [ -z "${DOMAIN}" ]; then exit 1 fi +resolveall() { + local name="$1" + local port="$2" + getent hosts ${name} | awk "{print \$1 \":${port}\"}" +} + +commaseplist() { + local out= + for arg in "$@" ; do + out="${out}${out:+,}${arg}" + done + echo "${out}" +} + set_public_ip() { # Try to guess the public IP of this host if unset, resolving the # fully-qualified host name. @@ -24,5 +38,6 @@ set_public_ip() { set_etcd_params() { local default_etcd_server="etcd.${DOMAIN}" ETCD_SERVER="${ETCD_SERVER:-${default_etcd_server}}" - ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-servers=localhost:4001,${ETCD_SERVER}" + local server_ips=$(commaseplist localhost:4001 $(resolveall ${ETCD_SERVER} 4001)) + ETCD_OPTIONS="${ETCD_OPTIONS} --etcd-servers=${server_ips}" }