From 3ee52c81a12f1b823c1bc22e39d9f09a8d8b2ca8 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Thu, 12 Dec 2013 19:26:12 +0000 Subject: [PATCH] Ensure hostname resolves correctly rabbitmq hangs on startup if the unqualified hostname for the system doesn't resolve properly. This change ensures that the hostname is added to /etc/hosts so that will never happen with devstack. Change-Id: I2c250f38f9feb18d1a59f3a457c6d01c1d98499c --- stack.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stack.sh b/stack.sh index ce5fbd47e5..3ee6b1cde2 100755 --- a/stack.sh +++ b/stack.sh @@ -234,6 +234,13 @@ safe_chmod 0755 $DEST # a basic test for $DEST path permissions (fatal on error unless skipped) check_path_perm_sanity ${DEST} +# Certain services such as rabbitmq require that the local hostname resolves +# correctly. Make sure it exists in /etc/hosts so that is always true. +LOCAL_HOSTNAME=`hostname -s` +if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then + sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts +fi + # Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without # Internet access. ``stack.sh`` must have been previously run with Internet # access to install prerequisites and fetch repositories.