Skip to content

Instantly share code, notes, and snippets.

@YolandaMDavis
Last active June 13, 2017 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YolandaMDavis/284d248e2df007f426730cfd242f7160 to your computer and use it in GitHub Desktop.
Save YolandaMDavis/284d248e2df007f426730cfd242f7160 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Deploying HDF Sandbox Container:"
until docker ps 2>&1| grep STATUS>/dev/null; do sleep 1; done; >/dev/null
docker ps -a | grep sandbox
if [ $? -eq 0 ]; then
docker start sandbox
else
docker run --name sandbox --hostname "sandbox-hdf.hortonworks.com" --privileged -d \
-p 12181:2181 \
-p 17010:16010 \
-p 51070:50070 \
-p 13000:3000 \
-p 14200:4200 \
-p 14557:4557 \
-p 16080:6080 \
-p 18000:8000 \
-p 9080:8080 \
-p 18744:8744 \
-p 18886:8886 \
-p 18888:8888 \
-p 18993:8993 \
-p 19000:9000 \
-p 19090:9090 \
-p 19091:9091 \
-p 42111:42111 \
-p 62888:61888 \
-p 15100:15100 \
-p 15101:15101 \
-p 15102:15102 \
-p 15103:15103 \
-p 15104:15104 \
-p 15105:15105 \
-p 17000:17000 \
-p 17001:17001 \
-p 17002:17002 \
-p 17003:17003 \
-p 17004:17004 \
-p 17005:17005 \
-p 18081:8081 \
-p 18090:8090 \
-p 19060:9060 \
-p 19089:9089 \
-p 16667:6667 \
-p 17777:7777 \
-p 17788:7788 \
-p 17789:7789 \
-p 12222:22 \
sandbox /usr/sbin/sshd -D
fi
echo "Starting services required for Ambari"
docker exec -d sandbox service mysqld start
docker exec -t sandbox service postgresql start
docker exec -t sandbox service ntpd start
docker exec -t sandbox service ambari-server start
docker exec -t sandbox service ambari-agent start
sleep 20
echo "Starting required HDF Components"
until curl -v --user admin:admin -X PUT -H "X-Requested-By: ambari" -d "{\"RequestInfo\":{\"context\":\"_PARSE_.STOP.ALL_SERVICES\",\"operation_level\":{\"level\":\"CLUSTER\",\"cluster_name\":\"Sandbox\"}},\"Body\":{\"ServiceInfo\":{\"state\":\"INSTALLED\"}}}" http://sandbox-hdf.hortonworks.com:9080/api/v1/clusters/Sandbox/services; do sleep 10; done;
sleep 20
until curl --user admin:admin -X PUT -H "X-Requested-By: ambari" -d "{\"RequestInfo\":{\"context\":\"Start ZOOKEEPER via REST\",\"operation_level\":{\"level\":\"CLUSTER\",\"cluster_name\":\"Sandbox\"}},\"Body\":{\"ServiceInfo\":{\"state\":\"STARTED\"}}}" http://sandbox-hdf.hortonworks.com:9080/api/v1/clusters/Sandbox/services/ZOOKEEPER | grep -i accept; do sleep 5; done;
sleep 20
until curl --user admin:admin -X PUT -H "X-Requested-By: ambari" -d "{\"RequestInfo\":{\"context\":\"Start NIFI via REST\",\"operation_level\":{\"level\":\"CLUSTER\",\"cluster_name\":\"Sandbox\"}},\"Body\":{\"ServiceInfo\":{\"state\":\"STARTED\"}}}" http://sandbox-hdf.hortonworks.com:9080/api/v1/clusters/Sandbox/services/NIFI | grep -i accept; do sleep 5; done;
sleep 20
until curl --user admin:admin -X PUT -H "X-Requested-By: ambari" -d "{\"RequestInfo\":{\"context\":\"Start KAFKA via REST\",\"operation_level\":{\"level\":\"CLUSTER\",\"cluster_name\":\"Sandbox\"}},\"Body\":{\"ServiceInfo\":{\"state\":\"lsSTARTED\"}}}" http://sandbox-hdf.hortonworks.com:9080/api/v1/clusters/Sandbox/services/KAFKA | grep -i accept; do sleep 5; done;
sleep 20
echo "Waiting for HDF Components to complete startup"
until curl -s --user admin:admin -H "X-Requested-By: ambari" "http://sandbox-hdf.hortonworks.com:9080/api/v1/clusters/Sandbox/requests?to=end&page_size=10&fields=Requests" | tail -n 27 | grep COMPLETED | grep COMPLETED; do sleep 1; done;
echo "Loading Crash Course Tutorial Data"
echo "Creating Input Source Directory /tmp/nifi/input..."
docker exec -d sandbox mkdir -p /tmp/nifi/input
docker exec -d sandbox chmod -R 777 /tmp/nifi
echo "Downloading the Vehicle Location Data to Input Source..."
docker exec -d sandbox wget -O /tmp/nifi/input/trafficLocs_data_for_simulator.zip 'https://github.com/hortonworks/data-tutorials/raw/master/tutorials/hdf/analyze-traffic-pattern-with-apache-nifi/assets/trafficLocs_data_for_simulator.zip'
echo "Successfully Started Sandbox Container"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment