httpfs.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/bin/env 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. function hadoop_usage()
  16. {
  17. echo "Usage: httpfs.sh [--config confdir] [--debug] --daemon start|status|stop"
  18. echo " httpfs.sh [--config confdir] [--debug] COMMAND"
  19. echo " where COMMAND is one of:"
  20. echo " run Start httpfs in the current window"
  21. echo " run -security Start in the current window with security manager"
  22. echo " start Start httpfs in a separate window"
  23. echo " start -security Start in a separate window with security manager"
  24. echo " status Return the LSB compliant status"
  25. echo " stop Stop httpfs, waiting up to 5 seconds for the process to end"
  26. echo " stop n Stop httpfs, waiting up to n seconds for the process to end"
  27. echo " stop -force Stop httpfs, wait up to 5 seconds and then use kill -KILL if still running"
  28. echo " stop n -force Stop httpfs, wait up to n seconds and then use kill -KILL if still running"
  29. }
  30. # let's locate libexec...
  31. if [[ -n "${HADOOP_PREFIX}" ]]; then
  32. DEFAULT_LIBEXEC_DIR="${HADOOP_PREFIX}/libexec"
  33. else
  34. this="${BASH_SOURCE-$0}"
  35. bin=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
  36. DEFAULT_LIBEXEC_DIR="${bin}/../libexec"
  37. fi
  38. HADOOP_LIBEXEC_DIR="${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR}"
  39. # shellcheck disable=SC2034
  40. HADOOP_NEW_CONFIG=true
  41. if [[ -f "${HADOOP_LIBEXEC_DIR}/httpfs-config.sh" ]]; then
  42. . "${HADOOP_LIBEXEC_DIR}/httpfs-config.sh"
  43. else
  44. echo "ERROR: Cannot execute ${HADOOP_LIBEXEC_DIR}/httpfs-config.sh." 2>&1
  45. exit 1
  46. fi
  47. # The Java System property 'httpfs.http.port' it is not used by Kms,
  48. # it is used in Tomcat's server.xml configuration file
  49. #
  50. # Mask the trustStorePassword
  51. # shellcheck disable=SC2086
  52. CATALINA_OPTS_DISP="$(echo ${CATALINA_OPTS} | sed -e 's/trustStorePassword=[^ ]*/trustStorePassword=***/')"
  53. hadoop_debug "Using CATALINA_OPTS: ${CATALINA_OPTS_DISP}"
  54. # We're using hadoop-common, so set up some stuff it might need:
  55. hadoop_finalize
  56. hadoop_verify_logdir
  57. if [[ $# = 0 ]]; then
  58. case "${HADOOP_DAEMON_MODE}" in
  59. status)
  60. hadoop_status_daemon "${CATALINA_PID}"
  61. exit
  62. ;;
  63. start)
  64. set -- "start"
  65. ;;
  66. stop)
  67. set -- "stop"
  68. ;;
  69. esac
  70. fi
  71. hadoop_finalize_catalina_opts
  72. export CATALINA_OPTS
  73. # A bug in catalina.sh script does not use CATALINA_OPTS for stopping the server
  74. #
  75. if [[ "${1}" = "stop" ]]; then
  76. export JAVA_OPTS=${CATALINA_OPTS}
  77. fi
  78. # If ssl, the populate the passwords into ssl-server.xml before starting tomcat
  79. #
  80. # HTTPFS_SSL_KEYSTORE_PASS is a bit odd.
  81. # if undefined, then the if test will not enable ssl on its own
  82. # if "", set it to "password".
  83. # if custom, use provided password
  84. #
  85. if [[ -f "${HADOOP_CATALINA_HOME}/conf/ssl-server.xml.conf" ]]; then
  86. if [[ -n "${HTTPFS_SSL_KEYSTORE_PASS+x}" ]] || [[ -n "${HTTPFS_SSL_TRUSTSTORE_PASS}" ]]; then
  87. export HTTPFS_SSL_KEYSTORE_PASS=${HTTPFS_SSL_KEYSTORE_PASS:-password}
  88. sed -e 's/_httpfs_ssl_keystore_pass_/'${HTTPFS_SSL_KEYSTORE_PASS}'/g' \
  89. -e 's/_httpfs_ssl_truststore_pass_/'${HTTPFS_SSL_TRUSTSTORE_PASS}'/g' \
  90. "${HADOOP_CATALINA_HOME}/conf/ssl-server.xml.conf" \
  91. > "${HADOOP_CATALINA_HOME}/conf/ssl-server.xml"
  92. chmod 700 "${HADOOP_CATALINA_HOME}/conf/ssl-server.xml" >/dev/null 2>&1
  93. fi
  94. fi
  95. hadoop_add_param CATALINA_OPTS -Dhttpfs.http.hostname "-Dhttpfs.http.hostname=${HTTPFS_HOST_NAME}"
  96. hadoop_add_param CATALINA_OPTS -Dhttpfs.ssl.enabled "-Dhttpfs.ssl.enabled=${HTTPFS_SSL_ENABLED}"
  97. exec "${HADOOP_CATALINA_HOME}/bin/catalina.sh" "$@"