Updated Branches: refs/heads/master 7930d804e -> fe1b88f95
Adding check for public ip in puppet agent startup Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/fe1b88f9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/fe1b88f9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/fe1b88f9 Branch: refs/heads/master Commit: fe1b88f952f6c00c15374697fbf3b4dab5be2a7a Parents: 7930d80 Author: Sajith Kariyawasam <[email protected]> Authored: Mon Dec 23 17:51:32 2013 +0530 Committer: Sajith Kariyawasam <[email protected]> Committed: Mon Dec 23 17:51:32 2013 +0530 ---------------------------------------------------------------------- tools/puppet/agent/root/bin/ec2_init.sh | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/fe1b88f9/tools/puppet/agent/root/bin/ec2_init.sh ---------------------------------------------------------------------- diff --git a/tools/puppet/agent/root/bin/ec2_init.sh b/tools/puppet/agent/root/bin/ec2_init.sh index 1896629..1ad8a21 100644 --- a/tools/puppet/agent/root/bin/ec2_init.sh +++ b/tools/puppet/agent/root/bin/ec2_init.sh @@ -40,6 +40,7 @@ PUPPETD=`which puppetd` COMMAND="${PUPPETD} -vt" IP=`${IFCONFIG} eth0 | ${GREP} -e "inet addr" | ${AWK} '{print $2}' | ${CUT} -d ':' -f 2` +LOG=/tmp/puppet-init.log HOSTSFILE=/etc/hosts HOSTNAMEFILE=/etc/hostname @@ -49,11 +50,48 @@ read_master() { } +is_public_ip_assigned() { + +while true +do + wget http://169.254.169.254/latest/meta-data/public-ipv4 + if [ ! -f public-ipv4 ] + then + echo "Public ipv4 file not found. Sleep and retry" >> $LOG + sleep 2; + continue; + else + echo "public-ipv4 file is available. Read value" >> $LOG + # Here means file is available. Read the file + read -r ip<public-ipv4; + echo "value is **[$ip]** " >> $LOG + + if [ -z "$ip" ] + then + echo "File is empty. Retry...." >> $LOG + sleep 2 + rm public-ipv4 + continue + else + echo "public ip is assigned. value is [$ip]. Remove file" >> $LOG + rm public-ipv4 + break + fi + fi +done +} + + DATE=`date +%d%m%y%S` RANDOMNUMBER="`${TR} -c -d 0-9 < /dev/urandom | ${HEAD} -c 4`${DATE}" if [ ! -d /tmp/payload ]; then + ## Check whether the public ip is assigned + is_public_ip_assigned + + echo "Public ip have assigned. Continue.." >> $LOG + ## Clean old poop ${ECHO} "Removing all existing certificates .." #${FIND} /var/lib/puppet -type f -print0 | ${XARGS} -0r ${RM}
