httpfs-config.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 [ "${HTTPFS_SILENT}" != "true" ]; then
  30. echo "$@"
  31. fi
  32. }
  33. # if HTTPFS_HOME is already set warn it will be ignored
  34. #
  35. if [ "${HTTPFS_HOME}" != "" ]; then
  36. echo "WARNING: current setting of HTTPFS_HOME ignored"
  37. fi
  38. print
  39. # setting HTTPFS_HOME to the installation dir, it cannot be changed
  40. #
  41. export HTTPFS_HOME=${BASEDIR}
  42. httpfs_home=${HTTPFS_HOME}
  43. print "Setting HTTPFS_HOME: ${HTTPFS_HOME}"
  44. # if the installation has a env file, source it
  45. # this is for native packages installations
  46. #
  47. if [ -e "${HTTPFS_HOME}/bin/httpfs-env.sh" ]; then
  48. print "Sourcing: ${HTTPFS_HOME}/bin/httpfs-env.sh"
  49. source ${HTTPFS_HOME}/bin/httpfs-env.sh
  50. grep "^ *export " ${HTTPFS_HOME}/bin/httpfs-env.sh | sed 's/ *export/ setting/'
  51. fi
  52. # verify that the sourced env file didn't change HTTPFS_HOME
  53. # if so, warn and revert
  54. #
  55. if [ "${HTTPFS_HOME}" != "${httpfs_home}" ]; then
  56. print "WARN: HTTPFS_HOME resetting to ''${HTTPFS_HOME}'' ignored"
  57. export HTTPFS_HOME=${httpfs_home}
  58. print " using HTTPFS_HOME: ${HTTPFS_HOME}"
  59. fi
  60. if [ "${HTTPFS_CONFIG}" = "" ]; then
  61. export HTTPFS_CONFIG=${HTTPFS_HOME}/etc/hadoop
  62. print "Setting HTTPFS_CONFIG: ${HTTPFS_CONFIG}"
  63. else
  64. print "Using HTTPFS_CONFIG: ${HTTPFS_CONFIG}"
  65. fi
  66. httpfs_config=${HTTPFS_CONFIG}
  67. # if the configuration dir has a env file, source it
  68. #
  69. if [ -e "${HTTPFS_CONFIG}/httpfs-env.sh" ]; then
  70. print "Sourcing: ${HTTPFS_CONFIG}/httpfs-env.sh"
  71. source ${HTTPFS_CONFIG}/httpfs-env.sh
  72. grep "^ *export " ${HTTPFS_CONFIG}/httpfs-env.sh | sed 's/ *export/ setting/'
  73. fi
  74. # verify that the sourced env file didn't change HTTPFS_HOME
  75. # if so, warn and revert
  76. #
  77. if [ "${HTTPFS_HOME}" != "${httpfs_home}" ]; then
  78. echo "WARN: HTTPFS_HOME resetting to ''${HTTPFS_HOME}'' ignored"
  79. export HTTPFS_HOME=${httpfs_home}
  80. fi
  81. # verify that the sourced env file didn't change HTTPFS_CONFIG
  82. # if so, warn and revert
  83. #
  84. if [ "${HTTPFS_CONFIG}" != "${httpfs_config}" ]; then
  85. echo "WARN: HTTPFS_CONFIG resetting to ''${HTTPFS_CONFIG}'' ignored"
  86. export HTTPFS_CONFIG=${httpfs_config}
  87. fi
  88. if [ "${HTTPFS_LOG}" = "" ]; then
  89. export HTTPFS_LOG=${HTTPFS_HOME}/logs
  90. print "Setting HTTPFS_LOG: ${HTTPFS_LOG}"
  91. else
  92. print "Using HTTPFS_LOG: ${HTTPFS_LOG}"
  93. fi
  94. if [ ! -f ${HTTPFS_LOG} ]; then
  95. mkdir -p ${HTTPFS_LOG}
  96. fi
  97. if [ "${HTTPFS_TEMP}" = "" ]; then
  98. export HTTPFS_TEMP=${HTTPFS_HOME}/temp
  99. print "Setting HTTPFS_TEMP: ${HTTPFS_TEMP}"
  100. else
  101. print "Using HTTPFS_TEMP: ${HTTPFS_TEMP}"
  102. fi
  103. if [ ! -f ${HTTPFS_TEMP} ]; then
  104. mkdir -p ${HTTPFS_TEMP}
  105. fi
  106. if [ "${HTTPFS_HTTP_PORT}" = "" ]; then
  107. export HTTPFS_HTTP_PORT=14000
  108. print "Setting HTTPFS_HTTP_PORT: ${HTTPFS_HTTP_PORT}"
  109. else
  110. print "Using HTTPFS_HTTP_PORT: ${HTTPFS_HTTP_PORT}"
  111. fi
  112. if [ "${HTTPFS_ADMIN_PORT}" = "" ]; then
  113. export HTTPFS_ADMIN_PORT=`expr $HTTPFS_HTTP_PORT + 1`
  114. print "Setting HTTPFS_ADMIN_PORT: ${HTTPFS_ADMIN_PORT}"
  115. else
  116. print "Using HTTPFS_ADMIN_PORT: ${HTTPFS_ADMIN_PORT}"
  117. fi
  118. if [ "${HTTPFS_HTTP_HOSTNAME}" = "" ]; then
  119. export HTTPFS_HTTP_HOSTNAME=`hostname -f`
  120. print "Setting HTTPFS_HTTP_HOSTNAME: ${HTTPFS_HTTP_HOSTNAME}"
  121. else
  122. print "Using HTTPFS_HTTP_HOSTNAME: ${HTTPFS_HTTP_HOSTNAME}"
  123. fi
  124. if [ "${HTTPFS_SSL_ENABLED}" = "" ]; then
  125. export HTTPFS_SSL_ENABLED="false"
  126. print "Setting HTTPFS_SSL_ENABLED: ${HTTPFS_SSL_ENABLED}"
  127. else
  128. print "Using HTTPFS_SSL_ENABLED: ${HTTPFS_SSL_ENABLED}"
  129. fi
  130. if [ "${HTTPFS_SSL_KEYSTORE_FILE}" = "" ]; then
  131. export HTTPFS_SSL_KEYSTORE_FILE=${HOME}/.keystore
  132. print "Setting HTTPFS_SSL_KEYSTORE_FILE: ${HTTPFS_SSL_KEYSTORE_FILE}"
  133. else
  134. print "Using HTTPFS_SSL_KEYSTORE_FILE: ${HTTPFS_SSL_KEYSTORE_FILE}"
  135. fi
  136. if [ "${HTTPFS_SSL_KEYSTORE_PASS}" = "" ]; then
  137. export HTTPFS_SSL_KEYSTORE_PASS=password
  138. print "Setting HTTPFS_SSL_KEYSTORE_PASS: ${HTTPFS_SSL_KEYSTORE_PASS}"
  139. else
  140. print "Using HTTPFS_SSL_KEYSTORE_PASS: ${HTTPFS_SSL_KEYSTORE_PASS}"
  141. fi
  142. if [ "${CATALINA_BASE}" = "" ]; then
  143. export CATALINA_BASE=${HTTPFS_HOME}/share/hadoop/httpfs/tomcat
  144. print "Setting CATALINA_BASE: ${CATALINA_BASE}"
  145. else
  146. print "Using CATALINA_BASE: ${CATALINA_BASE}"
  147. fi
  148. if [ "${HTTPFS_CATALINA_HOME}" = "" ]; then
  149. export HTTPFS_CATALINA_HOME=${CATALINA_BASE}
  150. print "Setting HTTPFS_CATALINA_HOME: ${HTTPFS_CATALINA_HOME}"
  151. else
  152. print "Using HTTPFS_CATALINA_HOME: ${HTTPFS_CATALINA_HOME}"
  153. fi
  154. if [ "${CATALINA_OUT}" = "" ]; then
  155. export CATALINA_OUT=${HTTPFS_LOG}/httpfs-catalina.out
  156. print "Setting CATALINA_OUT: ${CATALINA_OUT}"
  157. else
  158. print "Using CATALINA_OUT: ${CATALINA_OUT}"
  159. fi
  160. if [ "${CATALINA_PID}" = "" ]; then
  161. export CATALINA_PID=/tmp/httpfs.pid
  162. print "Setting CATALINA_PID: ${CATALINA_PID}"
  163. else
  164. print "Using CATALINA_PID: ${CATALINA_PID}"
  165. fi
  166. print