diff --git a/compute/src/test/resources/initscript_with_java.sh b/compute/src/test/resources/initscript_with_java.sh index b52d6f9363..99d05645c6 100644 --- a/compute/src/test/resources/initscript_with_java.sh +++ b/compute/src/test/resources/initscript_with_java.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 52609f33cd..d5a5e3d1b8 100644 --- a/compute/src/test/resources/initscript_with_jetty.sh +++ b/compute/src/test/resources/initscript_with_jetty.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 aaa38777f3..b7d261e6bf 100644 --- a/compute/src/test/resources/runscript.sh +++ b/compute/src/test/resources/runscript.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 58a9a7c959..ac192e6351 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,10 +112,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 a59dd627d4..f5e1caba3f 100644 --- a/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh +++ b/scriptbuilder/src/main/resources/functions/setupPublicCurl.sh @@ -30,10 +30,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 3d99dea2b0..e4fd15f77b 100644 --- a/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_chef_gems_scriptbuilder.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 08533043b7..eb1b71d23d 100644 --- a/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_git_scriptbuilder.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 ab8210beff..5157490c10 100644 --- a/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_jdk_scriptbuilder.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `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 6ce3c90633..3eb8fc45aa 100644 --- a/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh +++ b/scriptbuilder/src/test/resources/test_install_ruby_scriptbuilder.sh @@ -115,10 +115,13 @@ 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() { - # 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 + [ -n "$SSH_CONNECTION" ] && { + local ipaddr=`echo $SSH_CONNECTION | awk '{print $3}'` + } || { + local ipaddr=`hostname -i` + } + # NOTE: we blindly trust existing hostname settings in /etc/hosts + egrep -q `hostname` /etc/hosts || echo "$ipaddr `hostname`" >> /etc/hosts } # download locations for many services are at public dns