diff --git a/distribution/src/main/resources/bin/elasticsearch-env b/distribution/src/main/resources/bin/elasticsearch-env index 83737ae12534b..7e74195e60784 100644 --- a/distribution/src/main/resources/bin/elasticsearch-env +++ b/distribution/src/main/resources/bin/elasticsearch-env @@ -65,6 +65,8 @@ fi # check the Java version "$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.JavaVersionChecker +export HOSTNAME=$HOSTNAME + ${source.path.env} if [ -z "$ES_PATH_CONF" ]; then diff --git a/distribution/src/main/resources/bin/elasticsearch-env.bat b/distribution/src/main/resources/bin/elasticsearch-env.bat index 5ff573ae08409..626ea3b8c6ff4 100644 --- a/distribution/src/main/resources/bin/elasticsearch-env.bat +++ b/distribution/src/main/resources/bin/elasticsearch-env.bat @@ -44,6 +44,8 @@ if not "%JAVA_OPTS%" == "" ( rem check the Java version %JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.JavaVersionChecker" || exit /b 1 +set HOSTNAME=%COMPUTERNAME% + if "%ES_PATH_CONF%" == "" ( set ES_PATH_CONF=!ES_HOME!\config ) diff --git a/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash b/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash index db94bf983d548..91c06974266fa 100644 --- a/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash +++ b/qa/vagrant/src/test/resources/packaging/tests/module_and_plugin_test_cases.bash @@ -450,3 +450,15 @@ fi @test "[$GROUP] test umask" { install_jvm_example $(readlink -m jvm-example-*.zip) 0077 } + +@test "[$GROUP] hostname" { + local temp=`mktemp -d` + cp "$ESCONFIG"/elasticsearch.yml "$temp" + echo 'node.name: ${HOSTNAME}' >> "$ESCONFIG"/elasticsearch.yml + start_elasticsearch_service + wait_for_elasticsearch_status + [ "$(curl -XGET localhost:9200/_cat/nodes?h=name)" == "$HOSTNAME" ] + stop_elasticsearch_service + cp "$temp"/elasticsearch.yml "$ESCONFIG"/elasticsearch.yml + rm -rf "$temp" +}