diff --git a/distribution/src/bin/elasticsearch-cli.bat b/distribution/src/bin/elasticsearch-cli.bat new file mode 100644 index 0000000000000..efda5f653ef31 --- /dev/null +++ b/distribution/src/bin/elasticsearch-cli.bat @@ -0,0 +1,22 @@ +call "%~dp0elasticsearch-env.bat" || exit /b 1 + +if defined ES_ADDITIONAL_SOURCES ( + for %%a in ("%ES_ADDITIONAL_SOURCES:;=","%") do ( + call %~dp0%%a + ) +) + +for /f "tokens=1*" %%a in ("%*") do ( + set main_class=%%a + set arguments=%%b +) + +%JAVA% ^ + %ES_JAVA_OPTS% ^ + -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%" ^ + %main_class% ^ + %arguments% diff --git a/distribution/src/bin/elasticsearch-keystore.bat b/distribution/src/bin/elasticsearch-keystore.bat index 1d6616983d8cc..9bd72a65745a9 100644 --- a/distribution/src/bin/elasticsearch-keystore.bat +++ b/distribution/src/bin/elasticsearch-keystore.bat @@ -3,17 +3,10 @@ setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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.common.settings.KeyStoreCli ^ - %* +call "%~dp0elasticsearch-cli.bat" ^ + org.elasticsearch.common.settings.KeyStoreCli ^ + %* ^ + || exit /b 1 endlocal endlocal diff --git a/distribution/src/bin/elasticsearch-plugin.bat b/distribution/src/bin/elasticsearch-plugin.bat index b3b94a31863f1..d46ef295d085b 100644 --- a/distribution/src/bin/elasticsearch-plugin.bat +++ b/distribution/src/bin/elasticsearch-plugin.bat @@ -3,17 +3,10 @@ setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.plugins.PluginCli ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/distribution/src/bin/elasticsearch-translog.bat b/distribution/src/bin/elasticsearch-translog.bat index 492c1f0831263..37d96bbed6c4e 100644 --- a/distribution/src/bin/elasticsearch-translog.bat +++ b/distribution/src/bin/elasticsearch-translog.bat @@ -3,17 +3,10 @@ setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.index.translog.TranslogToolCli ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat index d44ca227c07fd..8c8a0c69f5626 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.core.ssl.CertificateGenerateTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat index 4426fb87d3ba6..f898f885ce0a3 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.core.ssl.CertificateTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat index 79090b6490790..f9486979e6bc3 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmMigrateTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat index 9e5625d0b912e..4ddb8da3ff143 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-saml-metadata.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.security.authc.saml.SamlMetadataCommand ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat index b449ca09a6c30..f380e5f55271f 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-setup-passwords.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.security.authc.esnative.tool.SetupPasswordTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat index 3ee9dcb3ba9cb..1eff4aad8251e 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat b/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat index b32b9398f9971..7f7347d706ff5 100644 --- a/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat +++ b/x-pack/plugin/security/src/main/bin/elasticsearch-users.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-security-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.security.authc.file.tool.UsersTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/security/src/main/bin/x-pack-security-env.bat b/x-pack/plugin/security/src/main/bin/x-pack-security-env.bat index 035f1c965ffb6..d003412fc08d9 100644 --- a/x-pack/plugin/security/src/main/bin/x-pack-security-env.bat +++ b/x-pack/plugin/security/src/main/bin/x-pack-security-env.bat @@ -2,6 +2,4 @@ rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one rem or more contributor license agreements. Licensed under the Elastic License; rem you may not use this file except in compliance with the Elastic License. -call "%~dp0x-pack-env.bat" || exit /b 1 - set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/modules/x-pack-security/* diff --git a/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat b/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat index 7fd983c9ba5fe..37ca14dd094cc 100644 --- a/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat +++ b/x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat @@ -7,19 +7,11 @@ rem you may not use this file except in compliance with the Elastic License. setlocal enabledelayedexpansion setlocal enableextensions -call "%~dp0elasticsearch-env.bat" || exit /b 1 - -call "%~dp0x-pack-watcher-env.bat" || exit /b 1 - -%JAVA% ^ - %ES_JAVA_OPTS% ^ - -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%" ^ +set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-watcher-env +call "%~dp0elasticsearch-cli.bat" ^ org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEvalTool ^ - %* + %* ^ + || exit /b 1 endlocal endlocal diff --git a/x-pack/plugin/watcher/src/main/bin/x-pack-watcher-env.bat b/x-pack/plugin/watcher/src/main/bin/x-pack-watcher-env.bat index 010c154eb5a39..4c7f762dca26c 100644 --- a/x-pack/plugin/watcher/src/main/bin/x-pack-watcher-env.bat +++ b/x-pack/plugin/watcher/src/main/bin/x-pack-watcher-env.bat @@ -2,6 +2,4 @@ rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one rem or more contributor license agreements. Licensed under the Elastic License; rem you may not use this file except in compliance with the Elastic License. -call "%~dp0x-pack-env.bat" || exit /b 1 - set ES_CLASSPATH=!ES_CLASSPATH!;!ES_HOME!/modules/x-pack-watcher/*