Apache Lucene open-source search software
SOLR-7961: Add version command to bin/solr start script. Also adds -h for help
Jan Høydahlc7d7b00e03fb
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 8a39f46d5f3..555c759ba76 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -127,6 +127,7 @@ New Featuresto refer to a single-sharded collection that has a replica on all nodes where there is areplica in the to index (Andrei Beliakov via Mikhail Khludnev)+* SOLR-7961: Print Solr's version with command bin/solr version (janhoy)Bug Fixes----------------------@@ -200,6 +201,8 @@ Other Changes* SOLR-7007: DistributedUpdateProcessor now logs replay flag as boolean instead of int(Mike Drob via Christine Poerschke)+* SOLR-7960: Start scripts now gives generic help for bin/solr -h and bin/solr --help (janhoy)+================== 5.3.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this releasediff --git a/solr/bin/solr b/solr/bin/solrindex 7a632b23a02..e1e2adaa3ce 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -188,7 +188,7 @@ function print_usage() {if [ -z "$CMD" ]; thenecho ""echo "Usage: solr COMMAND OPTIONS"- echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete"+ echo " where COMMAND is one of: start, stop, restart, status, healthcheck, create, create_core, create_collection, delete, version"echo ""echo " Standalone server example (start Solr running in the background on port 8984):"echo ""@@ -500,7 +500,7 @@ function stop_solr() {if [ $# -eq 1 ]; thencase $1 in- -help|-usage)+ -help|-usage|-h|--help)print_usage ""exit;;@@ -508,6 +508,10 @@ if [ $# -eq 1 ]; thenget_infoexit;;+ -version|-v|version)+ run_tool version+ exit+ ;;esacfidiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 0cef348dbda..5f5f6c24b73 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -94,10 +94,15 @@ IF [%1]==[] goto usageIF "%1"=="-help" goto usageIF "%1"=="-usage" goto usage+IF "%1"=="-h" goto usage+IF "%1"=="--help" goto usageIF "%1"=="/?" goto usageIF "%1"=="-i" goto get_infoIF "%1"=="-info" goto get_infoIF "%1"=="status" goto get_info+IF "%1"=="version" goto get_version+IF "%1"=="-v" goto get_version+IF "%1"=="-version" goto get_versionREM Only allow the command to be the first argument, assume start if not suppliedIF "%1"=="start" goto set_script_cmd@@ -136,6 +141,8 @@ IF NOT "%SCRIPT_ERROR%"=="" ECHO %SCRIPT_ERROR%IF [%FIRST_ARG%]==[] goto script_usageIF "%FIRST_ARG%"=="-help" goto script_usageIF "%FIRST_ARG%"=="-usage" goto script_usage+IF "%FIRST_ARG%"=="-h" goto script_usage+IF "%FIRST_ARG%"=="--help" goto script_usageIF "%FIRST_ARG%"=="/?" goto script_usageIF "%SCRIPT_CMD%"=="start" goto start_usageIF "%SCRIPT_CMD%"=="restart" goto start_usage@@ -150,7 +157,7 @@ goto done:script_usage@echo.@echo Usage: solr COMMAND OPTIONS-@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete+@echo where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version@echo.@echo Standalone server example (start Solr running in the background on port 8984):@echo.@@ -968,6 +975,12 @@ IF NOT DEFINED HEALTHCHECK_ZK_HOST set "HEALTHCHECK_ZK_HOST=localhost:9983"org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !HEALTHCHECK_ZK_HOST!goto done+:get_version+"%JAVA%" %SOLR_SSL_OPTS% -Dsolr.install.dir="%SOLR_TIP%" -Dlog4j.configuration="file:%DEFAULT_SERVER_DIR%\scripts\cloud-scripts\log4j.properties" ^+ -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^+ org.apache.solr.util.SolrCLI version+goto done+:parse_create_argsIF [%1]==[] goto run_createIF "%1"=="-c" goto set_create_namediff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.javaindex edf2a8195bd..ec49dba1a05 100644--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java@@ -70,6 +70,7 @@ import org.apache.http.client.utils.URIBuilder;import org.apache.http.conn.ConnectTimeoutException;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.util.EntityUtils;+import org.apache.lucene.util.Version;import org.apache.solr.client.solrj.SolrClient;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.SolrServerException;@@ -225,6 +226,12 @@ public class SolrCLI {exit(1);}+ if (args.length == 1 && Arrays.asList("-v","-version","version").contains(args[0])) {+ // Simple version tool, no need for its own class+ System.out.println(Version.LATEST);+ exit(0);+ }+String configurerClassName = System.getProperty("solr.authentication.httpclient.configurer");if (configurerClassName!=null) {try {