diff --git a/distribution/src/bin/elasticsearch b/distribution/src/bin/elasticsearch index 84e14eea3f6f8..9bfaded3385a1 100755 --- a/distribution/src/bin/elasticsearch +++ b/distribution/src/bin/elasticsearch @@ -20,7 +20,6 @@ ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options JVM_OPTIONS=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_JVM_OPTIONS"` ES_JAVA_OPTS="${JVM_OPTIONS//\$\{ES_TMPDIR\}/$ES_TMPDIR} $ES_JAVA_OPTS" -cd "$ES_HOME" # manual parsing to find out, if process should be detached if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; then exec \ diff --git a/distribution/src/bin/elasticsearch-env b/distribution/src/bin/elasticsearch-env index 0b5bd6b6d5898..0e7f591adace3 100644 --- a/distribution/src/bin/elasticsearch-env +++ b/distribution/src/bin/elasticsearch-env @@ -86,3 +86,5 @@ ES_DISTRIBUTION_TYPE=${es.distribution.type} if [ -z "$ES_TMPDIR" ]; then ES_TMPDIR=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.TempDirectory` fi + +cd "$ES_HOME" diff --git a/distribution/src/bin/elasticsearch-env.bat b/distribution/src/bin/elasticsearch-env.bat index 4101d18639828..bfaf56d74661a 100644 --- a/distribution/src/bin/elasticsearch-env.bat +++ b/distribution/src/bin/elasticsearch-env.bat @@ -60,3 +60,5 @@ set ES_DISTRIBUTION_TYPE=${es.distribution.type} if not defined ES_TMPDIR ( for /f "tokens=* usebackq" %%a in (`"%JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory""`) do set ES_TMPDIR=%%a ) + +cd /d "%ES_HOME%" diff --git a/distribution/src/bin/elasticsearch.bat b/distribution/src/bin/elasticsearch.bat index 9b67fa2e0ffa6..975af52e39523 100644 --- a/distribution/src/bin/elasticsearch.bat +++ b/distribution/src/bin/elasticsearch.bat @@ -50,7 +50,6 @@ if "%MAYBE_JVM_OPTIONS_PARSER_FAILED%" == "jvm_options_parser_failed" ( exit /b 1 ) -cd /d "%ES_HOME%" %JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -Des.distribution.flavor="%ES_DISTRIBUTION_FLAVOR%" -Des.distribution.type="%ES_DISTRIBUTION_TYPE%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! endlocal diff --git a/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/ArchiveTestCase.java b/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/ArchiveTestCase.java index 133237ecf7ea6..75775039a370a 100644 --- a/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/ArchiveTestCase.java +++ b/qa/vagrant/src/main/java/org/elasticsearch/packaging/test/ArchiveTestCase.java @@ -317,14 +317,14 @@ public void test90SecurityCliPackaging() { } } - public void test100ElasticsearchShardCliPackaging() { + public void test91ElasticsearchShardCliPackaging() { assumeThat(installation, is(notNullValue())); final Installation.Executables bin = installation.executables(); final Shell sh = new Shell(); Platforms.PlatformAction action = () -> { - final Result result = sh.run(bin.elasticsearchShard + " help"); + final Result result = sh.run(bin.elasticsearchShard + " -h"); assertThat(result.stdout, containsString("A CLI tool to remove corrupted parts of unrecoverable shards")); }; @@ -334,7 +334,7 @@ public void test100ElasticsearchShardCliPackaging() { } } - public void test110ElasticsearchNodeCliPackaging() { + public void test92ElasticsearchNodeCliPackaging() { assumeThat(installation, is(notNullValue())); final Installation.Executables bin = installation.executables(); @@ -352,4 +352,19 @@ public void test110ElasticsearchNodeCliPackaging() { } } + public void test93ElasticsearchNodeCustomDataPathAndNotEsHomeWorkDir() throws IOException { + assumeThat(installation, is(notNullValue())); + + Path relativeDataPath = installation.data.relativize(installation.home); + append(installation.config("elasticsearch.yml"), "path.data: " + relativeDataPath); + + Archives.runElasticsearch(installation); + Archives.stopElasticsearch(installation); + + final Shell sh = new Shell(getTempDir()); + + Result result = sh.run("echo y | " + installation.executables().elasticsearchNode + " unsafe-bootstrap"); + assertThat(result.stdout, containsString("Master node was successfully bootstrapped")); + } + }