From 87a64d1587a052836f16210c7c3009b28f04a165 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 10 Jun 2014 20:15:33 -0700 Subject: [PATCH] Make sure we have a hostname when we grep for it We attempt to set hostname in /etc/hosts if the hostname does not exist there. However when the $HOSTNAME variable is empty we grep for /etc/hosts from stdin which has no data. Check that $HOSTNAME is not empty before we grep for it. Change-Id: Ie35fd997f2f569ebea6614f91609281a991f8d6a --- .../openstack_project/files/nodepool/scripts/prepare_node.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openstack_project/files/nodepool/scripts/prepare_node.sh b/modules/openstack_project/files/nodepool/scripts/prepare_node.sh index 3bbf56b98b..5d32b1a411 100755 --- a/modules/openstack_project/files/nodepool/scripts/prepare_node.sh +++ b/modules/openstack_project/files/nodepool/scripts/prepare_node.sh @@ -32,7 +32,7 @@ forward-zone: EOF sudo hostname $HOSTNAME -if ! grep -q $HOSTNAME /etc/hosts +if [ -n "$HOSTNAME" ] && ! grep -q $HOSTNAME /etc/hosts then echo "127.0.1.1 $HOSTNAME" | sudo tee -a /etc/hosts fi