easyInstallerLib.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/sh
  2. #/*
  3. # * Licensed to the Apache Software Foundation (ASF) under one
  4. # * or more contributor license agreements. See the NOTICE file
  5. # * distributed with this work for additional information
  6. # * regarding copyright ownership. The ASF licenses this file
  7. # * to you under the Apache License, Version 2.0 (the
  8. # * "License"); you may not use this file except in compliance
  9. # * with the License. You may obtain a copy of the License at
  10. # *
  11. # * http://www.apache.org/licenses/LICENSE-2.0
  12. # *
  13. # * Unless required by applicable law or agreed to in writing, software
  14. # * distributed under the License is distributed on an "AS IS" BASIS,
  15. # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # * See the License for the specific language governing permissions and
  17. # * limitations under the License.
  18. # */
  19. #################
  20. ### CONSTANTS ###
  21. #################
  22. # Meant to be used in the future to deal with upgrades and downgrades.
  23. # XXX Remember to update this with every release of EasyInstaller.
  24. HDP_VERSION_STRING="HDP-1.0.4-Preview-6";
  25. # We assume these are created by the RPM.
  26. EASYINSTALLER_DB_DIR="/var/db/hdp/easyInstaller";
  27. EASYINSTALLER_CONF_TEMPLATES_DIR="/etc/hdp/easyInstaller/templates";
  28. EASYINSTALLER_SCRIPTS_DIR="/usr/libexec/hdp/easyInstaller";
  29. GSINSTALLER_SCRIPTS_DIR="/usr/libexec/hdp/gsInstaller";
  30. GSINSTALLER_PROPERTIES_CONF_NAME="gsInstaller.properties";
  31. GSCLUSTER_PROPERTIES_CONF_NAME="gsCluster.properties";
  32. INSTALLED_HDP_VERSION_COOKIE_NAME="installedHDPVersion";
  33. CHECKPOINTED_STAGE_NUMBER_COOKIE_NAME="checkpointedStageNumber";
  34. CLUSTER_DEPLOY_USER_IDENTITY_FILE_NAME="clusterDeployUserIdentity";
  35. CLUSTER_HOSTS_FILE_NAME="clusterHosts";
  36. NAMENODE_MOUNT_POINTS_FILE_NAME="NameNodeMountPointsSuggest.out";
  37. # XXX TODO Remove this temporary hack once we figure out why Jenkins is not
  38. # pushing the advertised keys into the environment.
  39. JENKINS_URL="http://localhost:9040/"
  40. #################
  41. ### FUNCTIONS ###
  42. #################
  43. function true2yes
  44. {
  45. # Anything other than exactly "true" results in "no".
  46. local answer="no";
  47. if [ "xtrue" == "x${1}" ]
  48. then
  49. answer="yes";
  50. fi
  51. echo "${answer}";
  52. }
  53. function fetchJobConfigTemplate
  54. {
  55. local jobName="${1}";
  56. local jobConfigTemplateDestinationFile="${2}";
  57. if [ "x" != "x${jobName}" ] && [ "x" != "x${jobConfigTemplateDestinationFile}" ]
  58. then
  59. cp -pf "${EASYINSTALLER_CONF_TEMPLATES_DIR}/jobs/${jobName}/config.xml" "${jobConfigTemplateDestinationFile}";
  60. else
  61. return 1;
  62. fi
  63. }
  64. function getFirstWordFromFile
  65. {
  66. local firstWord="";
  67. local absFilePath="${1}";
  68. if [ "x" != "x${absFilePath}" ] && [ -e "${absFilePath}" ]
  69. then
  70. firstWord=`head -1 ${absFilePath} | awk '{print $1;}'`;
  71. fi
  72. echo "${firstWord}";
  73. }
  74. function wrapWithXMLTag
  75. {
  76. local wrappedOutput="";
  77. local xmlTag="${1}";
  78. local wrappedEntity="${2}";
  79. if [ "x" != "x${xmlTag}" ] && [ "x" != "x${wrappedEntity}" ]
  80. then
  81. wrappedOutput="<${xmlTag}>${wrappedEntity}</${xmlTag}>";
  82. fi
  83. echo "${wrappedOutput}";
  84. }