httpfs.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. HTTPFS_SILENT=${HTTPFS_SILENT:-true}
  29. source ${HADOOP_LIBEXEC_DIR:-${BASEDIR}/libexec}/httpfs-config.sh
  30. # The Java System property 'httpfs.http.port' it is not used by HttpFS,
  31. # it is used in Tomcat's server.xml configuration file
  32. #
  33. print "Using CATALINA_OPTS: ${CATALINA_OPTS}"
  34. catalina_opts="-Dproc_httpfs";
  35. catalina_opts="${catalina_opts} -Dhttpfs.log.dir=${HTTPFS_LOG}"
  36. print "Adding to CATALINA_OPTS: ${catalina_opts}"
  37. export CATALINA_OPTS="${CATALINA_OPTS} ${catalina_opts}"
  38. catalina_init_properties() {
  39. cp "${CATALINA_BASE}/conf/catalina-default.properties" \
  40. "${CATALINA_BASE}/conf/catalina.properties"
  41. }
  42. catalina_set_property() {
  43. local key=$1
  44. local value=$2
  45. [[ -z "${value}" ]] && return
  46. local disp_value="${3:-${value}}"
  47. print "Setting catalina property ${key} to ${disp_value}"
  48. echo "${key}=${value}" >> "${CATALINA_BASE}/conf/catalina.properties"
  49. }
  50. if [[ "${1}" = "start" || "${1}" = "run" ]]; then
  51. catalina_init_properties
  52. catalina_set_property "httpfs.home.dir" "${HTTPFS_HOME}"
  53. catalina_set_property "httpfs.config.dir" "${HTTPFS_CONFIG}"
  54. catalina_set_property "httpfs.temp.dir" "${HTTPFS_TEMP}"
  55. catalina_set_property "httpfs.admin.port" "${HTTPFS_ADMIN_PORT}"
  56. catalina_set_property "httpfs.http.port" "${HTTPFS_HTTP_PORT}"
  57. catalina_set_property "httpfs.http.hostname" "${HTTPFS_HTTP_HOSTNAME}"
  58. catalina_set_property "httpfs.max.http.header.size" \
  59. "${HTTPFS_MAX_HTTP_HEADER_SIZE}"
  60. catalina_set_property "httpfs.ssl.enabled" "${HTTPFS_SSL_ENABLED}"
  61. catalina_set_property "httpfs.ssl.client.auth" "${HTTPFS_SSL_CLIENT_AUTH}"
  62. catalina_set_property "httpfs.ssl.enabled.protocols" \
  63. "${HTTPFS_SSL_ENABLED_PROTOCOLS}"
  64. catalina_set_property "httpfs.ssl.ciphers" "${HTTPFS_SSL_CIPHERS}"
  65. catalina_set_property "httpfs.ssl.keystore.file" \
  66. "${HTTPFS_SSL_KEYSTORE_FILE}"
  67. catalina_set_property "httpfs.ssl.keystore.pass" \
  68. "${HTTPFS_SSL_KEYSTORE_PASS}" "<redacted>"
  69. fi
  70. # A bug in catalina.sh script does not use CATALINA_OPTS for stopping the server
  71. #
  72. if [ "${1}" = "stop" ]; then
  73. export JAVA_OPTS=${CATALINA_OPTS}
  74. fi
  75. if [ "${HTTPFS_SILENT}" != "true" ]; then
  76. exec "${HTTPFS_CATALINA_HOME}/bin/catalina.sh" "$@"
  77. else
  78. exec "${HTTPFS_CATALINA_HOME}/bin/catalina.sh" "$@" > /dev/null
  79. fi