forked from ISTI-ansible-roles/ansible-roles
library/roles/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2: More complete fix for the hostname handling.
This commit is contained in:
parent
9573124e3c
commit
af43d0db1e
|
@ -18,6 +18,7 @@ FQDN_HOST=
|
||||||
PUB_FQDN_HOST=
|
PUB_FQDN_HOST=
|
||||||
PUBLIC_IP=
|
PUBLIC_IP=
|
||||||
MAIN_IP=
|
MAIN_IP=
|
||||||
|
WORKING_REVERSE_RESOLUTION=0
|
||||||
RETVAL=0
|
RETVAL=0
|
||||||
CLOUD_INSTANCE_DIR=/var/lib/cloud/instance
|
CLOUD_INSTANCE_DIR=/var/lib/cloud/instance
|
||||||
MEM=$( free -m | egrep ^Mem | awk '{ print $2 }' )
|
MEM=$( free -m | egrep ^Mem | awk '{ print $2 }' )
|
||||||
|
@ -69,24 +70,29 @@ function find_public_ip() {
|
||||||
RET_FQDN=$?
|
RET_FQDN=$?
|
||||||
if [ $RET_FQDN -eq 0 ] ; then
|
if [ $RET_FQDN -eq 0 ] ; then
|
||||||
PUB_FQDN_HOST=$( host $PUBLIC_IP | awk '{print $5}' | sed -e 's/\.$//g' )
|
PUB_FQDN_HOST=$( host $PUBLIC_IP | awk '{print $5}' | sed -e 's/\.$//g' )
|
||||||
|
else
|
||||||
|
echo "No reverse resolution available. WPS will not work." >> $LOG_FILE
|
||||||
|
WORKING_REVERSE_RESOLUTION=1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function modify_hosts_file() {
|
function modify_hosts_file() {
|
||||||
echo "-- modify_hosts_file" >> $LOG_FILE
|
echo "-- modify_hosts_file" >> $LOG_FILE
|
||||||
# Set the hosts file with the new data. Set /etc/hostname too
|
# Set the hosts file with the new data. Set /etc/hostname too
|
||||||
|
if [ $WORKING_REVERSE_RESOLUTION -eq 0 ] ; then
|
||||||
grep -v $HOST $HOSTS_FILE > $HOSTS_FILE.tmp
|
grep -v $HOST $HOSTS_FILE > $HOSTS_FILE.tmp
|
||||||
if [ "${FQDN_HOST}" == "${HOST}" ] ; then
|
if [ "${FQDN_HOST}" == "${HOST}" ] ; then
|
||||||
FQDN_HOST=${HOST}.localhost
|
LOCAL_HOSTNAME=${HOST}
|
||||||
fi
|
fi
|
||||||
SHORT_HOSTNAME=$( echo ${PUB_FQDN_HOST} | cut -d . -f 1 - )
|
SHORT_HOSTNAME=$( echo ${PUB_FQDN_HOST} | cut -d . -f 1 - )
|
||||||
echo "${PUBLIC_IP} ${FQDN_HOST} ${PUB_FQDN_HOST} ${SHORT_HOSTNAME} ${HOST}" >> $HOSTS_FILE.tmp
|
echo "${PUBLIC_IP} ${PUB_FQDN_HOST} ${SHORT_HOSTNAME} ${LOCAL_HOSTNAME}" >> $HOSTS_FILE.tmp
|
||||||
mv $HOSTS_FILE.tmp $HOSTS_FILE
|
mv $HOSTS_FILE.tmp $HOSTS_FILE
|
||||||
chmod 644 $HOSTS_FILE
|
chmod 644 $HOSTS_FILE
|
||||||
chown root:root $HOSTS_FILE
|
chown root:root $HOSTS_FILE
|
||||||
if [ ! -z ${SHORT_HOSTNAME} ] ; then
|
if [ ! -z ${SHORT_HOSTNAME} ] ; then
|
||||||
echo "${SHORT_HOSTNAME}" > /etc/hostname
|
echo "${SHORT_HOSTNAME}" > /etc/hostname
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function smartgears_config_parameters_check() {
|
function smartgears_config_parameters_check() {
|
||||||
|
|
Loading…
Reference in New Issue