Browse code

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

Peter Penchev authored on 2017/12/15 06:45:52
Showing 1 changed files
... ...
@@ -353,7 +353,7 @@ safe_chmod 0755 $DATA_DIR
353 353
 # Certain services such as rabbitmq require that the local hostname resolves
354 354
 # correctly.  Make sure it exists in /etc/hosts so that is always true.
355 355
 LOCAL_HOSTNAME=`hostname -s`
356
-if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then
356
+if ! fgrep -qwe "$LOCAL_HOSTNAME" /etc/hosts; then
357 357
     sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
358 358
 fi
359 359