kms-config.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/bin/bash
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. #
  15. # resolve links - $0 may be a softlink
  16. PRG="${0}"
  17. while [ -h "${PRG}" ]; do
  18. ls=`ls -ld "${PRG}"`
  19. link=`expr "$ls" : '.*-> \(.*\)$'`
  20. if expr "$link" : '/.*' > /dev/null; then
  21. PRG="$link"
  22. else
  23. PRG=`dirname "${PRG}"`/"$link"
  24. fi
  25. done
  26. BASEDIR=`dirname ${PRG}`
  27. BASEDIR=`cd ${BASEDIR}/..;pwd`
  28. function print() {
  29. if [ "${KMS_SILENT}" != "true" ]; then
  30. echo "$@"
  31. fi
  32. }
  33. # if KMS_HOME is already set warn it will be ignored
  34. #
  35. if [ "${KMS_HOME}" != "" ]; then
  36. echo "WARNING: current setting of KMS_HOME ignored"
  37. fi
  38. print
  39. # setting KMS_HOME to the installation dir, it cannot be changed
  40. #
  41. export KMS_HOME=${BASEDIR}
  42. kms_home=${KMS_HOME}
  43. print "Setting KMS_HOME: ${KMS_HOME}"
  44. # if the installation has a env file, source it
  45. # this is for native packages installations
  46. #
  47. if [ -e "${KMS_HOME}/bin/kms-env.sh" ]; then
  48. print "Sourcing: ${KMS_HOME}/bin/kms-env.sh"
  49. source ${KMS_HOME}/bin/kms-env.sh
  50. grep "^ *export " ${KMS_HOME}/bin/kms-env.sh | sed 's/ *export/ setting/'
  51. fi
  52. # verify that the sourced env file didn't change KMS_HOME
  53. # if so, warn and revert
  54. #
  55. if [ "${KMS_HOME}" != "${kms_home}" ]; then
  56. print "WARN: KMS_HOME resetting to ''${KMS_HOME}'' ignored"
  57. export KMS_HOME=${kms_home}
  58. print " using KMS_HOME: ${KMS_HOME}"
  59. fi
  60. if [ "${KMS_CONFIG}" = "" ]; then
  61. export KMS_CONFIG=${KMS_HOME}/etc/hadoop
  62. print "Setting KMS_CONFIG: ${KMS_CONFIG}"
  63. else
  64. print "Using KMS_CONFIG: ${KMS_CONFIG}"
  65. fi
  66. kms_config=${KMS_CONFIG}
  67. # if the configuration dir has a env file, source it
  68. #
  69. if [ -e "${KMS_CONFIG}/kms-env.sh" ]; then
  70. print "Sourcing: ${KMS_CONFIG}/kms-env.sh"
  71. source ${KMS_CONFIG}/kms-env.sh
  72. grep "^ *export " ${KMS_CONFIG}/kms-env.sh | sed 's/ *export/ setting/'
  73. fi
  74. # verify that the sourced env file didn't change KMS_HOME
  75. # if so, warn and revert
  76. #
  77. if [ "${KMS_HOME}" != "${kms_home}" ]; then
  78. echo "WARN: KMS_HOME resetting to ''${KMS_HOME}'' ignored"
  79. export KMS_HOME=${kms_home}
  80. fi
  81. # verify that the sourced env file didn't change KMS_CONFIG
  82. # if so, warn and revert
  83. #
  84. if [ "${KMS_CONFIG}" != "${kms_config}" ]; then
  85. echo "WARN: KMS_CONFIG resetting to ''${KMS_CONFIG}'' ignored"
  86. export KMS_CONFIG=${kms_config}
  87. fi
  88. if [ "${KMS_LOG}" = "" ]; then
  89. export KMS_LOG=${KMS_HOME}/logs
  90. print "Setting KMS_LOG: ${KMS_LOG}"
  91. else
  92. print "Using KMS_LOG: ${KMS_LOG}"
  93. fi
  94. if [ ! -f ${KMS_LOG} ]; then
  95. mkdir -p ${KMS_LOG}
  96. fi
  97. if [ "${KMS_TEMP}" = "" ]; then
  98. export KMS_TEMP=${KMS_HOME}/temp
  99. print "Setting KMS_TEMP: ${KMS_TEMP}"
  100. else
  101. print "Using KMS_TEMP: ${KMS_TEMP}"
  102. fi
  103. if [ ! -f ${KMS_TEMP} ]; then
  104. mkdir -p ${KMS_TEMP}
  105. fi
  106. if [ "${KMS_HTTP_PORT}" = "" ]; then
  107. export KMS_HTTP_PORT=16000
  108. print "Setting KMS_HTTP_PORT: ${KMS_HTTP_PORT}"
  109. else
  110. print "Using KMS_HTTP_PORT: ${KMS_HTTP_PORT}"
  111. fi
  112. if [ "${KMS_ADMIN_PORT}" = "" ]; then
  113. export KMS_ADMIN_PORT=`expr $KMS_HTTP_PORT + 1`
  114. print "Setting KMS_ADMIN_PORT: ${KMS_ADMIN_PORT}"
  115. else
  116. print "Using KMS_ADMIN_PORT: ${KMS_ADMIN_PORT}"
  117. fi
  118. if [ "${KMS_MAX_THREADS}" = "" ]; then
  119. export KMS_MAX_THREADS=1000
  120. print "Setting KMS_MAX_THREADS: ${KMS_MAX_THREADS}"
  121. else
  122. print "Using KMS_MAX_THREADS: ${KMS_MAX_THREADS}"
  123. fi
  124. if [ "${KMS_SSL_KEYSTORE_FILE}" = "" ]; then
  125. export KMS_SSL_KEYSTORE_FILE=${HOME}/.keystore
  126. print "Setting KMS_SSL_KEYSTORE_FILE: ${KMS_SSL_KEYSTORE_FILE}"
  127. else
  128. print "Using KMS_SSL_KEYSTORE_FILE: ${KMS_SSL_KEYSTORE_FILE}"
  129. fi
  130. if [ "${KMS_SSL_KEYSTORE_PASS}" = "" ]; then
  131. export KMS_SSL_KEYSTORE_PASS=password
  132. print "Setting KMS_SSL_KEYSTORE_PASS: ********"
  133. else
  134. KMS_SSL_KEYSTORE_PASS_DISP=`echo ${KMS_SSL_KEYSTORE_PASS} | sed 's/./*/g'`
  135. print "Using KMS_SSL_KEYSTORE_PASS: ${KMS_SSL_KEYSTORE_PASS_DISP}"
  136. fi
  137. if [ "${CATALINA_BASE}" = "" ]; then
  138. export CATALINA_BASE=${KMS_HOME}/share/hadoop/kms/tomcat
  139. print "Setting CATALINA_BASE: ${CATALINA_BASE}"
  140. else
  141. print "Using CATALINA_BASE: ${CATALINA_BASE}"
  142. fi
  143. if [ "${KMS_CATALINA_HOME}" = "" ]; then
  144. export KMS_CATALINA_HOME=${CATALINA_BASE}
  145. print "Setting KMS_CATALINA_HOME: ${KMS_CATALINA_HOME}"
  146. else
  147. print "Using KMS_CATALINA_HOME: ${KMS_CATALINA_HOME}"
  148. fi
  149. if [ "${CATALINA_OUT}" = "" ]; then
  150. export CATALINA_OUT=${KMS_LOG}/kms-catalina.out
  151. print "Setting CATALINA_OUT: ${CATALINA_OUT}"
  152. else
  153. print "Using CATALINA_OUT: ${CATALINA_OUT}"
  154. fi
  155. if [ "${CATALINA_PID}" = "" ]; then
  156. export CATALINA_PID=/tmp/kms.pid
  157. print "Setting CATALINA_PID: ${CATALINA_PID}"
  158. else
  159. print "Using CATALINA_PID: ${CATALINA_PID}"
  160. fi
  161. print