From 74c0b42b870fcaa3117a193facc2cb6e07e12584 Mon Sep 17 00:00:00 2001 From: Carl Pulley Date: Thu, 24 Jan 2013 22:49:17 +0000 Subject: [PATCH] Issue #1240: Improved handling of /etc/hosts updates by ensure_hostname_in_hosts --- compute/src/test/resources/initscript_with_java.sh | 5 ++++- compute/src/test/resources/initscript_with_jetty.sh | 5 ++++- compute/src/test/resources/runscript.sh | 5 ++++- .../test/resources/test_guest_additions_installer_init.sh | 5 ++++- .../src/main/resources/functions/setupPublicCurl.sh | 5 ++++- .../test/resources/test_install_chef_gems_scriptbuilder.sh | 5 ++++- .../src/test/resources/test_install_git_scriptbuilder.sh | 5 ++++- .../src/test/resources/test_install_jdk_scriptbuilder.sh | 5 ++++- .../src/test/resources/test_install_ruby_scriptbuilder.sh | 5 ++++- 9 files changed, 36 insertions(+), 9 deletions(-) diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index 17982edb18..b52d6f9363 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/compute/src/test/resources/initscript_with_jetty.sh b/compute/src/test/resources/initscript_with_jetty.sh index 741ec9458e..45eaad57c3 100644 --- a/compute/src/test/resources/initscript_with_jetty.sh +++ b/compute/src/test/resources/initscript_with_jetty.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/compute/src/test/resources/runscript.sh b/compute/src/test/resources/runscript.sh index 652feded31..aaa38777f3 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/labs/virtualbox/src/test/resources/test_guest_additions_installer_init.sh b/labs/virtualbox/src/test/resources/test_guest_additions_installer_init.sh index 2d6320ed4c..58a9a7c959 100644 --- a/labs/virtualbox/src/test/resources/test_guest_additions_installer_init.sh +++ b/labs/virtualbox/src/test/resources/test_guest_additions_installer_init.sh @@ -112,7 +112,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh b/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh index eb7cdd9861..a59dd627d4 100644 --- a/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh +++ b/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh @@ -30,7 +30,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh index 06e8f70bf7..67cdfe5c9b 100644 --- a/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh index b876867c6c..08533043b7 100644 --- a/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh index 905aef3de4..ab8210beff 100644 --- a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns diff --git a/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh b/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh index 44a34769aa..6476f276a2 100644 --- a/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh @@ -115,7 +115,10 @@ function ensure_netutils_yum() { # most network services require that the hostname is in # the /etc/hosts file, or they won't operate function ensure_hostname_in_hosts() { - egrep -q `hostname` /etc/hosts || awk -v hostname=`hostname` 'END { print $1" "hostname }' /proc/net/arp >> /etc/hosts + # NOTE: + # 1. We blindly trust existing hostname settings in /etc/hosts + # 2. We assume hostname supports the -i option to return the default NICs IP address + egrep -q `hostname` /etc/hosts || echo "`hostname -i` `hostname`" >> /etc/hosts } # download locations for many services are at public dns