SOLR-7961: Add version command to bin/solr start script. Also adds -h for help

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1697904 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jan Høydahl 2015-08-26 12:33:10 +00:00
parent 63e6779b14
commit c7d7b00e03
4 changed files with 30 additions and 3 deletions

View File

@ -127,6 +127,7 @@ New Features
to refer to a single-sharded collection that has a replica on all nodes where there is a
replica 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 release

View File

@ -188,7 +188,7 @@ function print_usage() {
if [ -z "$CMD" ]; then
echo ""
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 ]; then
case $1 in
-help|-usage)
-help|-usage|-h|--help)
print_usage ""
exit
;;
@ -508,6 +508,10 @@ if [ $# -eq 1 ]; then
get_info
exit
;;
-version|-v|version)
run_tool version
exit
;;
esac
fi

View File

@ -94,10 +94,15 @@ IF [%1]==[] goto usage
IF "%1"=="-help" goto usage
IF "%1"=="-usage" goto usage
IF "%1"=="-h" goto usage
IF "%1"=="--help" goto usage
IF "%1"=="/?" goto usage
IF "%1"=="-i" goto get_info
IF "%1"=="-info" goto get_info
IF "%1"=="status" goto get_info
IF "%1"=="version" goto get_version
IF "%1"=="-v" goto get_version
IF "%1"=="-version" goto get_version
REM Only allow the command to be the first argument, assume start if not supplied
IF "%1"=="start" goto set_script_cmd
@ -136,6 +141,8 @@ IF NOT "%SCRIPT_ERROR%"=="" ECHO %SCRIPT_ERROR%
IF [%FIRST_ARG%]==[] goto script_usage
IF "%FIRST_ARG%"=="-help" goto script_usage
IF "%FIRST_ARG%"=="-usage" goto script_usage
IF "%FIRST_ARG%"=="-h" goto script_usage
IF "%FIRST_ARG%"=="--help" goto script_usage
IF "%FIRST_ARG%"=="/?" goto script_usage
IF "%SCRIPT_CMD%"=="start" goto start_usage
IF "%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_args
IF [%1]==[] goto run_create
IF "%1"=="-c" goto set_create_name

View File

@ -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 {