jw项目windows环境软件安装
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
4.7 KiB

1 year ago
  1. #!/bin/bash
  2. set -e -o pipefail
  3. CDPATH=""
  4. SCRIPT="$0"
  5. # SCRIPT might be an arbitrarily deep series of symbolic links; loop until we
  6. # have the concrete path
  7. while [ -h "$SCRIPT" ] ; do
  8. ls=`ls -ld "$SCRIPT"`
  9. # Drop everything prior to ->
  10. link=`expr "$ls" : '.*-> \(.*\)$'`
  11. if expr "$link" : '/.*' > /dev/null; then
  12. SCRIPT="$link"
  13. else
  14. SCRIPT=`dirname "$SCRIPT"`/"$link"
  15. fi
  16. done
  17. # determine Elasticsearch home; to do this, we strip from the path until we find
  18. # bin, and then strip bin (there is an assumption here that there is no nested
  19. # directory under bin also named bin)
  20. ES_HOME=`dirname "$SCRIPT"`
  21. # now make ES_HOME absolute
  22. ES_HOME=`cd "$ES_HOME"; pwd`
  23. while [ "`basename "$ES_HOME"`" != "bin" ]; do
  24. ES_HOME=`dirname "$ES_HOME"`
  25. done
  26. ES_HOME=`dirname "$ES_HOME"`
  27. # now set the classpath
  28. ES_CLASSPATH="$ES_HOME/lib/*"
  29. # now set the path to java
  30. if [ ! -z "$ES_JAVA_HOME" ]; then
  31. JAVA="$ES_JAVA_HOME/bin/java"
  32. JAVA_TYPE="ES_JAVA_HOME"
  33. elif [ ! -z "$JAVA_HOME" ]; then
  34. # fallback to JAVA_HOME
  35. echo "warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME" >&2
  36. JAVA="$JAVA_HOME/bin/java"
  37. JAVA_TYPE="JAVA_HOME"
  38. else
  39. # use the bundled JDK (default)
  40. if [ "$(uname -s)" = "Darwin" ]; then
  41. # macOS has a different structure
  42. JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
  43. else
  44. JAVA="$ES_HOME/jdk/bin/java"
  45. fi
  46. JAVA_TYPE="bundled JDK"
  47. fi
  48. if [ ! -x "$JAVA" ]; then
  49. echo "could not find java in $JAVA_TYPE at $JAVA" >&2
  50. exit 1
  51. fi
  52. # do not let JAVA_TOOL_OPTIONS slip in (as the JVM does by default)
  53. if [ ! -z "$JAVA_TOOL_OPTIONS" ]; then
  54. echo "warning: ignoring JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS"
  55. unset JAVA_TOOL_OPTIONS
  56. fi
  57. # JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we
  58. # warn them that we are not observing the value of $JAVA_OPTS
  59. if [ ! -z "$JAVA_OPTS" ]; then
  60. echo -n "warning: ignoring JAVA_OPTS=$JAVA_OPTS; "
  61. echo "pass JVM parameters via ES_JAVA_OPTS"
  62. fi
  63. if [[ "$("$JAVA" -version 2>/dev/null)" =~ "Unable to map CDS archive" ]]; then
  64. XSHARE="-Xshare:off"
  65. else
  66. XSHARE="-Xshare:auto"
  67. fi
  68. # check the Java version
  69. "$JAVA" "$XSHARE" -cp "$ES_CLASSPATH" org.elasticsearch.tools.java_version_checker.JavaVersionChecker
  70. export HOSTNAME=$HOSTNAME
  71. if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi
  72. if [ -z "$ES_PATH_CONF" ]; then
  73. echo "ES_PATH_CONF must be set to the configuration path"
  74. exit 1
  75. fi
  76. # now make ES_PATH_CONF absolute
  77. ES_PATH_CONF=`cd "$ES_PATH_CONF"; pwd`
  78. ES_DISTRIBUTION_FLAVOR=default
  79. ES_DISTRIBUTION_TYPE=zip
  80. ES_BUNDLED_JDK=true
  81. if [[ "$ES_BUNDLED_JDK" == "false" ]]; then
  82. echo "warning: no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release" >&2
  83. fi
  84. if [[ "$ES_DISTRIBUTION_TYPE" == "docker" ]]; then
  85. # Allow environment variables to be set by creating a file with the
  86. # contents, and setting an environment variable with the suffix _FILE to
  87. # point to it. This can be used to provide secrets to a container, without
  88. # the values being specified explicitly when running the container.
  89. source "$ES_HOME/bin/elasticsearch-env-from-file"
  90. # Parse Docker env vars to customize Elasticsearch
  91. #
  92. # e.g. Setting the env var cluster.name=testcluster
  93. #
  94. # will cause Elasticsearch to be invoked with -Ecluster.name=testcluster
  95. #
  96. # see https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#_setting_default_settings
  97. declare -a es_arg_array
  98. while IFS='=' read -r envvar_key envvar_value
  99. do
  100. # Elasticsearch settings need to have at least two dot separated lowercase
  101. # words, e.g. `cluster.name`
  102. if [[ "$envvar_key" =~ ^[a-z0-9_]+\.[a-z0-9_]+ ]]; then
  103. if [[ ! -z $envvar_value ]]; then
  104. es_opt="-E${envvar_key}=${envvar_value}"
  105. es_arg_array+=("${es_opt}")
  106. fi
  107. fi
  108. done <<< "$(env)"
  109. # Reset the positional parameters to the es_arg_array values and any existing positional params
  110. set -- "$@" "${es_arg_array[@]}"
  111. # The virtual file /proc/self/cgroup should list the current cgroup
  112. # membership. For each hierarchy, you can follow the cgroup path from
  113. # this file to the cgroup filesystem (usually /sys/fs/cgroup/) and
  114. # introspect the statistics for the cgroup for the given
  115. # hierarchy. Alas, Docker breaks this by mounting the container
  116. # statistics at the root while leaving the cgroup paths as the actual
  117. # paths. Therefore, Elasticsearch provides a mechanism to override
  118. # reading the cgroup path from /proc/self/cgroup and instead uses the
  119. # cgroup path defined the JVM system property
  120. # es.cgroups.hierarchy.override. Therefore, we set this value here so
  121. # that cgroup statistics are available for the container this process
  122. # will run in.
  123. export ES_JAVA_OPTS="-Des.cgroups.hierarchy.override=/ $ES_JAVA_OPTS"
  124. fi
  125. cd "$ES_HOME"