httpfs.sh 3.9 KB

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