Apache Lucene open-source search software
SOLR-7545: Honour SOLR_HOST parameter with bin/solr{,.cmd}
Ramkumar Aiyengard767d556dab4
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 762eea71c56..fa56919f2b3 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -279,6 +279,9 @@ Bug Fixes* SOLR-7472: SortingResponseWriter does not log fl parameters that don't exist. (Joel Bernstein)+* SOLR-7545: Honour SOLR_HOST parameter with bin/solr{,.cmd}+ (Ishan Chattopadhyaya via Ramkumar Aiyengar)+Optimizations----------------------diff --git a/solr/bin/solr b/solr/bin/solrindex a3dde95c1f7..eab30e7f8e7 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -164,6 +164,13 @@ elseSOLR_JETTY_CONFIG+=("--module=http")fi+# Set the SOLR_TOOL_HOST variable for use when connecting to a running Solr instance+if [ "$SOLR_HOST" != "" ]; then+ SOLR_TOOL_HOST="$SOLR_HOST"+else+ SOLR_TOOL_HOST="localhost"+fi+function print_usage() {CMD="$1"ERROR_MSG="$2"@@ -427,7 +434,7 @@ function get_info() {port=`jetty_port "$ID"`if [ "$port" != "" ]; thenecho -e "\nSolr process $ID running on port $port"- run_tool status -solr "$SOLR_URL_SCHEME://localhost:$port/solr"+ run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"echo ""elseecho -e "\nSolr process $ID from $PIDF not found."@@ -444,7 +451,7 @@ function get_info() {if [ "$port" != "" ]; thenecho ""echo "Solr process $ID running on port $port"- run_tool status -solr "$SOLR_URL_SCHEME://localhost:$port/solr"+ run_tool status -solr "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$port/solr"echo ""fidone@@ -699,11 +706,11 @@ if [[ "$SCRIPT_CMD" == "create" || "$SCRIPT_CMD" == "create_core" || "$SCRIPT_CMfiif [ "$SCRIPT_CMD" == "create_core" ]; then- run_tool create_core -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://localhost:$CREATE_PORT/solr" \+ run_tool create_core -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \-confdir "$CREATE_CONFDIR" -configsetsDir "$SOLR_TIP/server/solr/configsets"exit $?else- run_tool "$SCRIPT_CMD" -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://localhost:$CREATE_PORT/solr" \+ run_tool "$SCRIPT_CMD" -name "$CREATE_NAME" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$CREATE_PORT/solr" \-shards "$CREATE_NUM_SHARDS" -replicationFactor "$CREATE_REPFACT" \-confname "$CREATE_CONFNAME" -confdir "$CREATE_CONFDIR" \-configsetsDir "$SOLR_TIP/server/solr/configsets"@@ -789,7 +796,7 @@ if [[ "$SCRIPT_CMD" == "delete" ]]; thenfirun_tool delete -name "$DELETE_NAME" -deleteConfig "$DELETE_CONFIG" \- -solrUrl "$SOLR_URL_SCHEME://localhost:$DELETE_PORT/solr"+ -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$DELETE_PORT/solr"exit $?fi@@ -1429,18 +1436,18 @@ if [ "$EXAMPLE" != "cloud" ]; thenrun_tool create -name "$EXAMPLE_NAME" -shards 1 -replicationFactor 1 \-confname "$EXAMPLE_NAME" -confdir "$EXAMPLE_CONFIGSET" \- -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl $SOLR_URL_SCHEME://localhost:$SOLR_PORT/solr+ -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solrif [ $? -ne 0 ]; thenexit 1fiif [ "$EXAMPLE" == "techproducts" ]; thenecho "Indexing tech product example docs from $SOLR_TIP/example/exampledocs"- "$JAVA" $SOLR_SSL_OPTS -Durl="$SOLR_URL_SCHEME://localhost:$SOLR_PORT/solr/$EXAMPLE/update" \+ "$JAVA" $SOLR_SSL_OPTS -Durl="$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr/$EXAMPLE/update" \-jar "$SOLR_TIP/example/exampledocs/post.jar" "$SOLR_TIP/example/exampledocs"/*.xmlfi- echo -e "\nSolr $EXAMPLE example launched successfully. Direct your Web browser to $SOLR_URL_SCHEME://localhost:$SOLR_PORT/solr to visit the Solr Admin UI\n"+ echo -e "\nSolr $EXAMPLE example launched successfully. Direct your Web browser to $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr to visit the Solr Admin UI\n"fielse#@@ -1553,9 +1560,9 @@ elserun_tool create_collection -name "$CLOUD_COLLECTION" -shards $CLOUD_NUM_SHARDS -replicationFactor $CLOUD_REPFACT \-confname "$CLOUD_COLLECTION" -confdir "$CLOUD_CONFIG" \- -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl "$SOLR_URL_SCHEME://localhost:$SOLR_PORT/solr"+ -configsetsDir "$SOLR_TIP/server/solr/configsets" -solrUrl "$SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr"- echo -e "\n\nSolrCloud example running, please visit $SOLR_URL_SCHEME://localhost:$SOLR_PORT/solr \n\n"+ echo -e "\n\nSolrCloud example running, please visit $SOLR_URL_SCHEME://$SOLR_TOOL_HOST:$SOLR_PORT/solr \n\n"fiexit $?diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex a3c9cfc3df6..fb1e34b67bd 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -54,6 +54,13 @@ IF DEFINED SOLR_SSL_KEY_STORE (set SOLR_SSL_OPTS=)+REM Set the SOLR_TOOL_HOST variable for use when connecting to a running Solr instance+IF NOT "%SOLR_HOST%"=="" (+ set "SOLR_TOOL_HOST=%SOLR_HOST%"+) ELSE (+ set "SOLR_TOOL_HOST=localhost"+)+REM Verify Java is availableIF DEFINED SOLR_JAVA_HOME set "JAVA_HOME=%SOLR_JAVA_HOME%"REM Try to detect JAVA_HOME from the registry@@ -919,11 +926,11 @@ IF NOT "!CREATE_EXAMPLE_CONFIG!"=="" ("%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 create_collection -name !EXAMPLE_NAME! -shards 1 -replicationFactor 1 ^- -confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -solrUrl !SOLR_URL_SCHEME!://localhost:%SOLR_PORT%/solr+ -confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr) ELSE ("%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 create_core -name !EXAMPLE_NAME! -solrUrl !SOLR_URL_SCHEME!://localhost:%SOLR_PORT%/solr ^+ org.apache.solr.util.SolrCLI create_core -name !EXAMPLE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr ^-confdir !CREATE_EXAMPLE_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets"))@@ -931,14 +938,14 @@ IF NOT "!CREATE_EXAMPLE_CONFIG!"=="" (IF "%EXAMPLE%"=="techproducts" (@echo.@echo Indexing tech product example docs from "%SOLR_TIP%\example\exampledocs"- "%JAVA%" %SOLR_SSL_OPTS% -Durl=!SOLR_URL_SCHEME!://localhost:%SOLR_PORT%/solr/%EXAMPLE%/update -jar "%SOLR_TIP%/example/exampledocs/post.jar" "%SOLR_TIP%/example/exampledocs/*.xml"+ "%JAVA%" %SOLR_SSL_OPTS% -Durl=!SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr/%EXAMPLE%/update -jar "%SOLR_TIP%/example/exampledocs/post.jar" "%SOLR_TIP%/example/exampledocs/*.xml")@echo.IF NOT "%EXAMPLE%"=="" (@echo Solr %EXAMPLE% example launched successfully.)-@echo Direct your Web browser to !SOLR_URL_SCHEME!://localhost:%SOLR_PORT%/solr to visit the Solr Admin UI+@echo Direct your Web browser to !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr to visit the Solr Admin UI@echo.goto done@@ -1093,7 +1100,7 @@ goto create_collection-confdir !CLOUD_CONFIG! -configsetsDir "%SOLR_SERVER_DIR%\solr\configsets" -zkHost %zk_host%echo.-echo SolrCloud example is running, please visit !SOLR_URL_SCHEME!://localhost:%NODE1_PORT%/solr"+echo SolrCloud example is running, please visit !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%NODE1_PORT%/solr"echo.REM End of interactive cloud example@@ -1116,7 +1123,7 @@ for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.portecho Found Solr process %%k running on port !SOME_SOLR_PORT!"%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 status -solr !SOLR_URL_SCHEME!://localhost:!SOME_SOLR_PORT!/solr+ org.apache.solr.util.SolrCLI status -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!SOME_SOLR_PORT!/solr@echo.))@@ -1245,13 +1252,13 @@ if "!CREATE_PORT!"=="" (if "%SCRIPT_CMD%"=="create_core" ("%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 create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://localhost:!CREATE_PORT!/solr ^+ org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr ^-confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets") else ("%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 create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^- -confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" -solrUrl !SOLR_URL_SCHEME!://localhost:!CREATE_PORT!/solr+ -confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr)goto done@@ -1317,7 +1324,7 @@ if "!DELETE_CONFIG!"=="" ("%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 delete -name !DELETE_NAME! -deleteConfig !DELETE_CONFIG! ^--solrUrl !SOLR_URL_SCHEME!://localhost:!DELETE_PORT!/solr+-solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!DELETE_PORT!/solrgoto done