Guest User

Untitled

a guest
Jun 18th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. #!/bin/bash
  2. #this script determines what flavor of the sandbox is running and downloads the complementary one required for CDA
  3.  
  4. registry="hortonworks"
  5. hdpVersion="2.6.5"
  6. hdfVersion="3.1.1"
  7. hdfSandbox="sandbox-hdf"
  8. hdpSandbox="sandbox-hdp"
  9.  
  10. # housekeeping
  11. docker=$(which docker)
  12. mv=$(which mv)
  13. sed=$(which sed)
  14. chmod=$(which chmod)
  15.  
  16. #load the docker image
  17. if docker images | grep sandbox-hdp ; then
  18. echo "hdp" > sandbox-flavor
  19. elif docker images | grep sandbox-hdf; then
  20. echo "hdf" > sandbox-flavor
  21. fi
  22. $sed 's/sandbox-hdf-standalone-cda-ready/sandbox-hdf/g' assets/generate-proxy-deploy-script.sh > assets/generate-proxy-deploy-script.sh.new
  23. $sed 's/sandbox-hdp-security/sandbox-hdp/g' assets/generate-proxy-deploy-script.sh > assets/generate-proxy-deploy-script.sh.new
  24. $mv -f assets/generate-proxy-deploy-script.sh.new assets/generate-proxy-deploy-script.sh
  25.  
  26. flavor=$(cat sandbox-flavor)
  27. if [ "$flavor" = "hdf" ]; then
  28. # we have an hdf sandbox running so we need to download and start the hdp coutnerpart
  29. version="$hdpVersion"
  30. name="$hdpSandbox"
  31. $sed 's/hdpEnabled=false/hdpEnabled=true/g' assets/generate-proxy-deploy-script.sh > assets/generate-proxy-deploy-script.sh.new
  32. $mv -f assets/generate-proxy-deploy-script.sh.new assets/generate-proxy-deploy-script.sh
  33. hostname="sandbox-hdp.hortonworks.com"
  34. elif [ "$flavor" = "hdp" ]; then
  35. # we have an hdp sandbox running so we need to download and start the hdp coutnerpart
  36. version="$hdfVersion"
  37. name="$hdfSandbox"
  38. $sed 's/hdfEnabled=false/hdfEnabled=true/g' assets/generate-proxy-deploy-script.sh > assets/generate-proxy-deploy-script.sh.new
  39. $mv -f assets/generate-proxy-deploy-script.sh.new assets/generate-proxy-deploy-script.sh
  40. hostname="sandbox-hdf.hortonworks.com"
  41. fi
  42.  
  43. $docker pull "$registry/$name:$version"
  44.  
  45. containerExists=$(docker ps -a | grep -o $name | head -1)
  46. if [ ! -z $containerExists ]; then
  47. if [ "$name" = $containerExists ]; then
  48. $docker start $name
  49. fi
  50. else
  51. $docker run --privileged --name $name -h $hostname --network=cda --network-alias=$hostname -d $registry/$name:$version
  52. fi
  53.  
  54. #Deploy the proxy container.
  55. $chmod +x assets/generate-proxy-deploy-script.sh
  56. assets/generate-proxy-deploy-script.sh 2>/dev/null
  57. $chmod +x sandbox/proxy/proxy-deploy.sh 2>/dev/null
  58. sandbox/proxy/proxy-deploy.sh 2>/dev/null
  59.  
  60. #add the hostname to localhost
  61. echo "You need to add 'sandbox-hdp.hortonworks.com' and 'sandbox-hdf.hortonworks.com' into your hosts file"
Add Comment
Please, Sign In to add comment