Merge "Shells Out Getting hostname"

This commit is contained in:
Zuul 2018-05-19 15:34:44 +00:00 committed by Gerrit Code Review
commit ee7fc61fb3
3 changed files with 14 additions and 9 deletions

View File

@ -63,9 +63,14 @@ if [[ ! "$YN_IP" =~ ^([yY]|"")$ ]]; 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