Skip to content

Commit

Permalink
Reduce CLI scripts to one-liners on Windows (#30772)
Browse files Browse the repository at this point in the history
This commit reduces the Windows CLI scripts to one-liners by moving all
of the redundant logic to an elasticsearch-cli script. This commit is
only the Windows side, a previous commit covered the Linux side.
  • Loading branch information
jasontedor committed May 22, 2018
1 parent 4d3e285 commit bb8f1e8
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 131 deletions.
22 changes: 22 additions & 0 deletions distribution/src/bin/elasticsearch-cli.bat
Original file line number Diff line number Diff line change
@@ -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%
15 changes: 4 additions & 11 deletions distribution/src/bin/elasticsearch-keystore.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 3 additions & 10 deletions distribution/src/bin/elasticsearch-plugin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 3 additions & 10 deletions distribution/src/bin/elasticsearch-translog.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 4 additions & 12 deletions x-pack/plugin/security/src/main/bin/elasticsearch-certgen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 4 additions & 12 deletions x-pack/plugin/security/src/main/bin/elasticsearch-certutil.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 4 additions & 12 deletions x-pack/plugin/security/src/main/bin/elasticsearch-migrate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 4 additions & 12 deletions x-pack/plugin/security/src/main/bin/elasticsearch-syskeygen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 4 additions & 12 deletions x-pack/plugin/security/src/main/bin/elasticsearch-users.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions x-pack/plugin/security/src/main/bin/x-pack-security-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
16 changes: 4 additions & 12 deletions x-pack/plugin/watcher/src/main/bin/elasticsearch-croneval.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions x-pack/plugin/watcher/src/main/bin/x-pack-watcher-env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

0 comments on commit bb8f1e8

Please sign in to comment.