From 854cb67636c478143ed0071d44a84447a72e87a7 Mon Sep 17 00:00:00 2001 From: Peter Penchev Date: Thu, 14 Dec 2017 21:45:52 +0000 Subject: [PATCH] Allow a non-127.0.0.1 definition for the hostname. In some environments it might be useful to resolve the hostname to an IP address that is reachable by other hosts in the local network. If some of the configuration scripts have taken care of putting a proper line in /etc/hosts, do not try to override it by appending a 127.0.0.1 one. Change-Id: I7ae20a66c473b0c683803cc44654cd95fcce3639 Closes-Bug: 1746751 --- stack.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stack.sh b/stack.sh index 32eb43f292..266ae7c11a 100755 --- a/stack.sh +++ b/stack.sh @@ -353,7 +353,7 @@ safe_chmod 0755 $DATA_DIR # 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 +if ! fgrep -qwe "$LOCAL_HOSTNAME" /etc/hosts; then sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts fi