Shells Out Getting hostname

- Shells out getting the hostname to avoid returning the wrong value.

Change-Id: Ie0862433ae9b78c401359fe967f194c2f18ddcd6
This commit is contained in:
Aaron Sheffield 2018-05-18 15:39:56 -05:00 committed by Bryan Strassner
parent 635776f36e
commit b76f6a4d9c
3 changed files with 14 additions and 9 deletions

View File

@ -52,9 +52,14 @@ if [ "$YN_IP" != "y" ]; then
read -p "What is your LOCAL IP? " LOCAL_IP
fi
# Shells out to get the hostname to avoid some config conflicts
set -x
SHORT_HOSTNAME=$(hostname -s)
set +x
# Updates the /etc/hosts file
HOSTS="${LOCAL_IP} ${HOSTNAME}"
HOSTS_REGEX="${LOCAL_IP}.*${HOSTNAME}"
HOSTS="${LOCAL_IP} ${SHORT_HOSTNAME}"
HOSTS_REGEX="${LOCAL_IP}.*${SHORT_HOSTNAME}"
if grep -q "$HOSTS_REGEX" "/etc/hosts"; then
echo "Not updating /etc/hosts, entry ${HOSTS} already exists."
else

View File

@ -37,7 +37,7 @@ TARGET_SITE=${TARGET_SITE:-"dev"}
# The hostname for the genesis node
# The host name for the single-node deployment. e.g.: 'genesis'
HOSTNAME=${HOSTNAME:-""}
SHORT_HOSTNAME=${SHORT_HOSTNAME:-""}
# The host ip for this single-node deployment. e.g.: '10.0.0.9'
HOSTIP=${HOSTIP:-""}
# The cidr for the network for the host. e.g.: '10.0.0.0/24'
@ -72,8 +72,8 @@ function check_preconditions() {
echo "The HOSTIP variable must be set. E.g. 10.0.0.9"
fail=true
fi
if [ -z ${HOSTNAME} ] ; then
echo "The HOSTNAME variable must be set. E.g. testvm1"
if [ -z ${SHORT_HOSTNAME} ] ; then
echo "The SHORT_HOSTNAME variable must be set. E.g. testvm1"
fail=true
fi
if [ -z ${HOSTCIDR} ] ; then
@ -84,9 +84,9 @@ function check_preconditions() {
echo "The NODE_NET_IFACE variable must be set. E.g. ens3"
fail=true
fi
if [[ -z $(grep $HOSTNAME /etc/hosts | grep $HOSTIP) ]]
if [[ -z $(grep $SHORT_HOSTNAME /etc/hosts | grep $HOSTIP) ]]
then
echo "No /etc/hosts entry found for $HOSTNAME. Please add one."
echo "No /etc/hosts entry found for $SHORT_HOSTNAME. Please add one."
fail=true
fi
if [ $fail = true ] ; then
@ -134,7 +134,7 @@ function setup_repos() {
function configure_dev_configurables() {
cat << EOF >> ${WORKSPACE}/airship-in-a-bottle/deployment_files/site/${TARGET_SITE}/deployment/dev-configurables.yaml
data:
hostname: ${HOSTNAME}
hostname: ${SHORT_HOSTNAME}
hostip: ${HOSTIP}
hostcidr: ${HOSTCIDR}
interface: ${NODE_NET_IFACE}

View File

@ -24,7 +24,7 @@
# frequently changed
# The hostname for the genesis node
export HOSTNAME=testvm1
export SHORT_HOSTNAME=testvm1
# The IP address of the genesis node
export HOSTIP=10.0.0.9
# The CIDR of the network for the genesis node