Repository: stratos Updated Branches: refs/heads/master 2d848cb5c -> 85f00e26c
Fixed STRATOS-1003 - Cartidge init.sh script does not update CentOS hostname Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/85f00e26 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/85f00e26 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/85f00e26 Branch: refs/heads/master Commit: 85f00e26c1d34a45afe864c84758ee925b6147f2 Parents: 2d848cb Author: Manula Thantriwatte <[email protected]> Authored: Wed Nov 26 05:18:06 2014 +0000 Committer: Manula Thantriwatte <[email protected]> Committed: Wed Nov 26 05:18:06 2014 +0000 ---------------------------------------------------------------------- tools/puppet3-agent/init.sh | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/85f00e26/tools/puppet3-agent/init.sh ---------------------------------------------------------------------- diff --git a/tools/puppet3-agent/init.sh b/tools/puppet3-agent/init.sh index a8f0ceb..6841808 100755 --- a/tools/puppet3-agent/init.sh +++ b/tools/puppet3-agent/init.sh @@ -1,6 +1,7 @@ #!/bin/bash # -------------------------------------------------------------- # +# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file @@ -35,7 +36,13 @@ SLEEP=`which sleep` TR=`which tr` HEAD=`which head` WGET=`which wget` +PUPPETD=`which puppet` +AGENT="agent" +PUPPETAGENT="${PUPPETD} ${AGENT}" +OS=$(lsb_release -si) +PUPPET_DNS_AVAILABLE=false +COMMAND="${PUPPETAGENT} -vt" IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2` LOG=/tmp/puppet-init.log @@ -43,6 +50,11 @@ HOSTSFILE=/etc/hosts HOSTNAMEFILE=/etc/hostname PUPPETCONF=/etc/puppet/puppet.conf +read_master() { + ${COMMAND} +} + + is_public_ip_assigned() { while true @@ -98,8 +110,13 @@ if [ ! -d /tmp/payload ]; then INSTANCE_HOSTNAME=`sed 's/,/\n/g' launch-params | grep HOSTNAME | cut -d "=" -f 2` PUPPET_IP=`sed 's/,/\n/g' launch-params | grep PUPPET_IP | cut -d "=" -f 2` PUPPET_HOSTNAME=`sed 's/,/\n/g' launch-params | grep PUPPET_HOSTNAME | cut -d "=" -f 2` - PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2` PUPPET_ENV=`sed 's/,/\n/g' launch-params | grep PUPPET_ENV | cut -d "=" -f 2` + PUPPET_DNS_AVAILABLE=`sed 's/,/\n/g' launch-params | grep PUPPET_DNS_AVAILABLE | cut -d "=" -f 2` + + #If this property is not set, then set it as false + if [ -z $PUPPET_DNS_AVAILABLE ];then + PUPPET_DNS_AVAILABLE=false + fi NODEID="${RANDOMNUMBER}.${DEPLOYMENT}.${SERVICE_NAME}" #essential to have PUPPET_HOSTNAME at the end in order to auto-sign the certs DOMAIN="${PUPPET_HOSTNAME}" @@ -115,7 +132,20 @@ if [ ! -d /tmp/payload ]; then ${ECHO} "${PUPPET_IP} ${PUPPET_HOSTNAME}" >> ${HOSTSFILE} fi ${ECHO} "127.0.0.1 ${HOST}" >> ${HOSTSFILE} - /etc/init.d/hostname start + + if [ "$OS" = "CentOS" ]; then + #CentOS hostname change + ${ECHO} "CentOS : Changing host name in /etc/sysconfig/network" + CENTOSHOSTNAME="/etc/sysconfig/network" + ${ECHO} "NETWORKING=yes" > ${CENTOSHOSTNAME} + ${ECHO} "HOSTNAME=${HOST}" >> ${CENTOSHOSTNAME} + ${ECHO} "Network restarting..." + /etc/init.d/network restart + ${SLEEP} 4 + else + #Ubuntu hostname change + /etc/init.d/hostname start + fi PUPPET=`which puppet` PUPPETAGENT="${PUPPET} agent" @@ -133,4 +163,3 @@ if [ ! -d /tmp/payload ]; then fi # END -
