Issue #1240: Updated ensure_hostname_in_hosts to use SSH_CONNECTION with failover to hostname -i

This commit is contained in:
Carl Pulley 2013-01-25 11:00:14 +00:00
parent 74c0b42b87
commit eedd8a26db
9 changed files with 63 additions and 36 deletions

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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

View File

@ -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 | cut -d ' ' -f 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