#!/bin/bash
set -xe
# =========================================================== #
# Created By: Lokesh Nanda
# Date: 21/12/2016
# Sample call: /home/hadoop/HueScripts/hueurl.sh
# Getting the DNS name of EMR on cluster startup and dumping it to /home/hadoop/HueScripts/hueurl.properties
# BDP UI to read /home/hadoop/HueScripts/hueurl.properties file to get the latest link
# =========================================================== #
InstanceIDDev=$(aws emr list-clusters | grep -m 1 \"Id\" | awk '{print $2}')
InstanceIDEMR=$(echo "$InstanceIDDev" | sed 's/\"//g'| sed 's/\,//g')
DescribeEMR=$(aws emr describe-cluster --cluster-id "${InstanceIDEMR}" | python -c "import sys, json; print json.load(sys.stdin)['Cluster']['MasterPublicDnsName']")
echo "${DescribeEMR}"> /home/hadoop/HueScripts/hueurl.properties
sudo sed -i s/ec2/huelink=ec2/ /home/hadoop/HueScripts/hueurl.properties
sudo sed -i s/compute.amazonaws.com/compute.amazonaws.com:8888/ /home/hadoop/HueScripts/hueurl.properties
set -xe
# =========================================================== #
# Created By: Lokesh Nanda
# Date: 21/12/2016
# Sample call: /home/hadoop/HueScripts/hueurl.sh
# Getting the DNS name of EMR on cluster startup and dumping it to /home/hadoop/HueScripts/hueurl.properties
# BDP UI to read /home/hadoop/HueScripts/hueurl.properties file to get the latest link
# =========================================================== #
InstanceIDDev=$(aws emr list-clusters | grep -m 1 \"Id\" | awk '{print $2}')
InstanceIDEMR=$(echo "$InstanceIDDev" | sed 's/\"//g'| sed 's/\,//g')
DescribeEMR=$(aws emr describe-cluster --cluster-id "${InstanceIDEMR}" | python -c "import sys, json; print json.load(sys.stdin)['Cluster']['MasterPublicDnsName']")
echo "${DescribeEMR}"> /home/hadoop/HueScripts/hueurl.properties
sudo sed -i s/ec2/huelink=ec2/ /home/hadoop/HueScripts/hueurl.properties
sudo sed -i s/compute.amazonaws.com/compute.amazonaws.com:8888/ /home/hadoop/HueScripts/hueurl.properties