"Fossies" - the Fresh Open Source Software Archive

Member "solr-8.4.1/solr/bin/solr.cmd" (10 Jan 2020, 72863 Bytes) of package /linux/www/solr-8.4.1-src.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) MS DOS Batch source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "solr.cmd": 8.4.0_vs_8.4.1.

    1 @REM
    2 @REM  Licensed to the Apache Software Foundation (ASF) under one or more
    3 @REM  contributor license agreements.  See the NOTICE file distributed with
    4 @REM  this work for additional information regarding copyright ownership.
    5 @REM  The ASF licenses this file to You under the Apache License, Version 2.0
    6 @REM  (the "License"); you may not use this file except in compliance with
    7 @REM  the License.  You may obtain a copy of the License at
    8 @REM
    9 @REM      http://www.apache.org/licenses/LICENSE-2.0
   10 @REM
   11 @REM  Unless required by applicable law or agreed to in writing, software
   12 @REM  distributed under the License is distributed on an "AS IS" BASIS,
   13 @REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14 @REM  See the License for the specific language governing permissions and
   15 @REM  limitations under the License.
   16 
   17 @echo off
   18 
   19 @REM Make sure to keep line endings as CRLF for .cmd files
   20 
   21 IF "%OS%"=="Windows_NT" setlocal enabledelayedexpansion enableextensions
   22 
   23 set "PASS_TO_RUN_EXAMPLE="
   24 
   25 REM Determine top-level Solr directory
   26 set SDIR=%~dp0
   27 IF "%SDIR:~-1%"=="\" set SDIR=%SDIR:~0,-1%
   28 set SOLR_TIP=%SDIR%\..
   29 pushd %SOLR_TIP%
   30 set SOLR_TIP=%CD%
   31 popd
   32 
   33 REM Used to report errors before exiting the script
   34 set SCRIPT_ERROR=
   35 set NO_USER_PROMPT=0
   36 
   37 REM Allow user to import vars from an include file
   38 REM vars set in the include file can be overridden with
   39 REM command line args
   40 IF "%SOLR_INCLUDE%"=="" set "SOLR_INCLUDE=%SOLR_TIP%\bin\solr.in.cmd"
   41 IF EXIST "%SOLR_INCLUDE%" CALL "%SOLR_INCLUDE%"
   42 
   43 set "DEFAULT_SERVER_DIR=%SOLR_TIP%\server"
   44 
   45 REM Select HTTP OR HTTPS related configurations
   46 set SOLR_URL_SCHEME=http
   47 set "SOLR_JETTY_CONFIG=--module=http"
   48 set "SOLR_SSL_OPTS= "
   49 
   50 IF DEFINED SOLR_HADOOP_CREDENTIAL_PROVIDER_PATH (
   51   set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dhadoop.security.credential.provider.path=%SOLR_HADOOP_CREDENTIAL_PROVIDER_PATH%"
   52 )
   53 
   54 IF NOT DEFINED SOLR_SSL_ENABLED (
   55   IF DEFINED SOLR_SSL_KEY_STORE (
   56     set "SOLR_SSL_ENABLED=true"
   57   ) ELSE (
   58     set "SOLR_SSL_ENABLED=false"
   59   )
   60 )
   61 
   62 IF "%SOLR_SSL_ENABLED%"=="true" (
   63   set "SOLR_JETTY_CONFIG=--lib="%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*""
   64   if !JAVA_MAJOR_VERSION! GEQ 9  (
   65     set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=https"
   66   ) else (
   67     set "SOLR_JETTY_CONFIG=!SOLR_JETTY_CONFIG! --module=https8"
   68   )
   69   set SOLR_URL_SCHEME=https
   70   IF DEFINED SOLR_SSL_KEY_STORE (
   71     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.keystore=%SOLR_SSL_KEY_STORE%"
   72   )
   73 
   74   IF DEFINED SOLR_SSL_KEY_STORE_TYPE (
   75     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.keystore.type=%SOLR_SSL_KEY_STORE_TYPE%"
   76   )
   77 
   78   IF DEFINED SOLR_SSL_TRUST_STORE (
   79     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.truststore=%SOLR_SSL_TRUST_STORE%"
   80   )
   81   IF DEFINED SOLR_SSL_TRUST_STORE_TYPE (
   82     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.truststore.type=%SOLR_SSL_TRUST_STORE_TYPE%"
   83   )
   84 
   85   IF NOT DEFINED SOLR_SSL_CLIENT_HOSTNAME_VERIFICATION (
   86     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.ssl.verifyClientHostName=HTTPS"
   87   )
   88 
   89   IF DEFINED SOLR_SSL_NEED_CLIENT_AUTH (
   90     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.ssl.needClientAuth=%SOLR_SSL_NEED_CLIENT_AUTH%"
   91   )
   92   IF DEFINED SOLR_SSL_WANT_CLIENT_AUTH (
   93     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.jetty.ssl.wantClientAuth=%SOLR_SSL_WANT_CLIENT_AUTH%"
   94   )
   95 
   96   IF DEFINED SOLR_SSL_CLIENT_KEY_STORE (
   97     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.keyStore=%SOLR_SSL_CLIENT_KEY_STORE%"
   98 
   99     IF DEFINED SOLR_SSL_CLIENT_KEY_STORE_TYPE (
  100       set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.keyStoreType=%SOLR_SSL_CLIENT_KEY_STORE_TYPE%"
  101     )
  102   ) ELSE (
  103     IF DEFINED SOLR_SSL_KEY_STORE (
  104       set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.keyStore=%SOLR_SSL_KEY_STORE%"
  105     )
  106     IF DEFINED SOLR_SSL_KEY_STORE_TYPE (
  107       set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.keyStoreType=%SOLR_SSL_KEY_STORE_TYPE%"
  108     )
  109   )
  110 
  111   IF DEFINED SOLR_SSL_CLIENT_TRUST_STORE (
  112     set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.trustStore=%SOLR_SSL_CLIENT_TRUST_STORE%"
  113 
  114     IF DEFINED SOLR_SSL_CLIENT_TRUST_STORE_TYPE (
  115       set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.trustStoreType=%SOLR_SSL_CLIENT_TRUST_STORE_TYPE%"
  116     )
  117   ) ELSE (
  118     IF DEFINED SOLR_SSL_TRUST_STORE (
  119      set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.trustStore=%SOLR_SSL_TRUST_STORE%"
  120     )
  121     IF DEFINED SOLR_SSL_TRUST_STORE_TYPE (
  122      set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Djavax.net.ssl.trustStoreType=%SOLR_SSL_TRUST_STORE_TYPE%"
  123     )
  124   )
  125   IF DEFINED SOLR_SSL_CHECK_PEER_NAME (
  126    set "SOLR_SSL_OPTS=!SOLR_SSL_OPTS! -Dsolr.ssl.checkPeerName=%SOLR_SSL_CHECK_PEER_NAME%"
  127   )
  128 ) ELSE (
  129   set SOLR_SSL_OPTS=
  130 )
  131 
  132 REM Authentication options
  133 
  134 IF NOT DEFINED SOLR_AUTH_TYPE (
  135   IF DEFINED SOLR_AUTHENTICATION_OPTS (
  136     echo WARNING: SOLR_AUTHENTICATION_OPTS variable configured without associated SOLR_AUTH_TYPE variable
  137     echo          Please configure SOLR_AUTH_TYPE variable with the authentication type to be used.
  138     echo          Currently supported authentication types are [kerberos, basic]
  139   )
  140 )
  141 
  142 IF DEFINED SOLR_AUTH_TYPE (
  143   IF DEFINED SOLR_AUTHENTICATION_CLIENT_BUILDER (
  144     echo WARNING: SOLR_AUTHENTICATION_CLIENT_BUILDER and SOLR_AUTH_TYPE variables are configured together
  145     echo          Use SOLR_AUTH_TYPE variable to configure authentication type to be used
  146     echo          Currently supported authentication types are [kerberos, basic]
  147     echo          The value of SOLR_AUTHENTICATION_CLIENT_BUILDER configuration variable will be ignored
  148   )
  149 )
  150 
  151 IF DEFINED SOLR_AUTH_TYPE (
  152   IF /I "%SOLR_AUTH_TYPE%" == "basic" (
  153     set SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory"
  154   ) ELSE (
  155     IF /I "%SOLR_AUTH_TYPE%" == "kerberos" (
  156       set SOLR_AUTHENTICATION_CLIENT_BUILDER="org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory"
  157     ) ELSE (
  158       echo ERROR: Value specified for SOLR_AUTH_TYPE configuration variable is invalid.
  159       goto err
  160     )
  161   )
  162 )
  163 
  164 IF DEFINED SOLR_AUTHENTICATION_CLIENT_CONFIGURER (
  165   echo WARNING: Found unsupported configuration variable SOLR_AUTHENTICATION_CLIENT_CONFIGURER
  166   echo          Please start using SOLR_AUTH_TYPE instead
  167 )
  168 IF DEFINED SOLR_AUTHENTICATION_CLIENT_BUILDER (
  169   set AUTHC_CLIENT_BUILDER_ARG="-Dsolr.httpclient.builder.factory=%SOLR_AUTHENTICATION_CLIENT_BUILDER%"
  170 )
  171 set "AUTHC_OPTS=%AUTHC_CLIENT_BUILDER_ARG% %SOLR_AUTHENTICATION_OPTS%"
  172 
  173 REM Set the SOLR_TOOL_HOST variable for use when connecting to a running Solr instance
  174 IF NOT "%SOLR_HOST%"=="" (
  175   set "SOLR_TOOL_HOST=%SOLR_HOST%"
  176 ) ELSE (
  177   set "SOLR_TOOL_HOST=localhost"
  178 )
  179 IF "%SOLR_JETTY_HOST%"=="" (
  180   set SOLR_JETTY_HOST=0.0.0.0
  181 )
  182 
  183 REM Verify Java is available
  184 IF DEFINED SOLR_JAVA_HOME set "JAVA_HOME=%SOLR_JAVA_HOME%"
  185 REM Try to detect JAVA_HOME from the registry
  186 IF NOT DEFINED JAVA_HOME (
  187   FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment" /v CurrentVersion') DO set CurVer=%%B
  188   FOR /F "skip=2 tokens=2*" %%A IN ('REG QUERY "HKLM\Software\JavaSoft\Java Runtime Environment\!CurVer!" /v JavaHome') DO (
  189     set "JAVA_HOME=%%B"
  190   )
  191 )
  192 IF NOT DEFINED JAVA_HOME goto need_java_home
  193 set JAVA_HOME=%JAVA_HOME:"=%
  194 IF %JAVA_HOME:~-1%==\ SET JAVA_HOME=%JAVA_HOME:~0,-1%
  195 IF NOT EXIST "%JAVA_HOME%\bin\java.exe" (
  196   set "SCRIPT_ERROR=java.exe not found in %JAVA_HOME%\bin. Please set JAVA_HOME to a valid JRE / JDK directory."
  197   goto err
  198 )
  199 set "JAVA=%JAVA_HOME%\bin\java"
  200 CALL :resolve_java_info
  201 IF !JAVA_MAJOR_VERSION! LSS 8 (
  202   set "SCRIPT_ERROR=Java 1.8 or later is required to run Solr. Current Java version is: !JAVA_VERSION_INFO! (detected major: !JAVA_MAJOR_VERSION!)"
  203   goto err
  204 )
  205 
  206 set FIRST_ARG=%1
  207 
  208 IF [%1]==[] goto usage
  209 
  210 IF "%1"=="-help" goto usage
  211 IF "%1"=="-usage" goto usage
  212 IF "%1"=="-h" goto usage
  213 IF "%1"=="--help" goto usage
  214 IF "%1"=="/?" goto usage
  215 IF "%1"=="-i" goto get_info
  216 IF "%1"=="-info" goto get_info
  217 IF "%1"=="status" goto get_info
  218 IF "%1"=="version" goto get_version
  219 IF "%1"=="-v" goto get_version
  220 IF "%1"=="-version" goto get_version
  221 IF "%1"=="assert" goto run_assert
  222 IF "%1"=="autoscaling" goto run_autoscaling
  223 IF "%1"=="export" goto run_export
  224 IF "%1"=="package" goto run_package
  225 
  226 REM Only allow the command to be the first argument, assume start if not supplied
  227 IF "%1"=="start" goto set_script_cmd
  228 IF "%1"=="stop" goto set_script_cmd
  229 IF "%1"=="restart" goto set_script_cmd
  230 IF "%1"=="healthcheck" (
  231   REM healthcheck uses different arg parsing strategy
  232   set SCRIPT_CMD=healthcheck
  233   SHIFT
  234   goto parse_healthcheck_args
  235 )
  236 IF "%1"=="create" (
  237   set SCRIPT_CMD=create
  238   SHIFT
  239   goto parse_create_args
  240 )
  241 IF "%1"=="create_core" (
  242   set SCRIPT_CMD=create_core
  243   SHIFT
  244   goto parse_create_args
  245 )
  246 IF "%1"=="create_collection" (
  247   set SCRIPT_CMD=create_collection
  248   SHIFT
  249   goto parse_create_args
  250 )
  251 IF "%1"=="delete" (
  252   set SCRIPT_CMD=delete
  253   SHIFT
  254   goto parse_delete_args
  255 )
  256 IF "%1"=="zk" (
  257   set SCRIPT_CMD=zk
  258   SHIFT
  259   set ZK_RECURSE=false
  260   goto parse_zk_args
  261 )
  262 IF "%1"=="auth" (
  263   set SCRIPT_CMD=auth
  264   SHIFT
  265   goto run_auth
  266 )
  267 IF "%1"=="config" (
  268   REM config uses different arg parsing strategy
  269   set SCRIPT_CMD=config
  270   SHIFT
  271   set CONFIG_ARGS=
  272   goto parse_config_args
  273 )
  274 
  275 goto parse_args
  276 
  277 :usage
  278 IF NOT "%SCRIPT_ERROR%"=="" ECHO %SCRIPT_ERROR%
  279 IF [%FIRST_ARG%]==[] goto script_usage
  280 IF "%FIRST_ARG%"=="-help" goto script_usage
  281 IF "%FIRST_ARG%"=="-usage" goto script_usage
  282 IF "%FIRST_ARG%"=="-h" goto script_usage
  283 IF "%FIRST_ARG%"=="--help" goto script_usage
  284 IF "%FIRST_ARG%"=="/?" goto script_usage
  285 IF "%SCRIPT_CMD%"=="start" goto start_usage
  286 IF "%SCRIPT_CMD%"=="restart" goto start_usage
  287 IF "%SCRIPT_CMD%"=="stop" goto stop_usage
  288 IF "%SCRIPT_CMD%"=="healthcheck" goto healthcheck_usage
  289 IF "%SCRIPT_CMD%"=="create" goto create_usage
  290 IF "%SCRIPT_CMD%"=="create_core" goto create_core_usage
  291 IF "%SCRIPT_CMD%"=="create_collection" goto create_collection_usage
  292 IF "%SCRIPT_CMD%"=="delete" goto delete_usage
  293 IF  "%SCRIPT_CMD%"=="zk" goto zk_usage
  294 IF "%SCRIPT_CMD%"=="auth" goto auth_usage
  295 IF "%SCRIPT_CMD%"=="status" goto status_usage
  296 goto done
  297 
  298 :script_usage
  299 @echo.
  300 @echo Usage: solr COMMAND OPTIONS
  301 @echo        where COMMAND is one of: start, stop, restart, healthcheck, create, create_core, create_collection, delete, version, zk, auth, assert, config, autoscaling, export
  302 @echo.
  303 @echo   Standalone server example (start Solr running in the background on port 8984):
  304 @echo.
  305 @echo     solr start -p 8984
  306 @echo.
  307 @echo   SolrCloud example (start Solr running in SolrCloud mode using localhost:2181 to connect to Zookeeper, with 1g max heap size and remote Java debug options enabled):
  308 @echo.
  309 @echo     solr start -c -m 1g -z localhost:2181 -a "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044"
  310 @echo.
  311 @echo   Omit '-z localhost:2181' from the above command if you have defined ZK_HOST in solr.in.cmd.
  312 @echo.
  313 @echo Pass -help after any COMMAND to see command-specific usage information,
  314 @echo   such as:    solr start -help or solr stop -help
  315 @echo.
  316 goto done
  317 
  318 :start_usage
  319 @echo.
  320 @echo Usage: solr %SCRIPT_CMD% [-f] [-c] [-h hostname] [-p port] [-d directory] [-z zkHost] [-m memory] [-e example] [-s solr.solr.home] [-t solr.data.home] [-a "additional-options"] [-V]
  321 @echo.
  322 @echo   -f            Start Solr in foreground; default starts Solr in the background
  323 @echo                   and sends stdout / stderr to solr-PORT-console.log
  324 @echo.
  325 @echo   -c or -cloud  Start Solr in SolrCloud mode; if -z not supplied and ZK_HOST not defined in
  326 @echo                   solr.in.cmd, an embedded ZooKeeper instance is started on Solr port+1000,
  327 @echo                   such as 9983 if Solr is bound to 8983
  328 @echo.
  329 @echo   -h host       Specify the hostname for this Solr instance
  330 @echo.
  331 @echo   -p port       Specify the port to start the Solr HTTP listener on; default is 8983
  332 @echo "                  The specified port (SOLR_PORT) will also be used to determine the stop port"
  333 @echo "                  STOP_PORT=(\$SOLR_PORT-1000) and JMX RMI listen port RMI_PORT=(\$SOLR_PORT+10000). "
  334 @echo "                  For instance, if you set -p 8985, then the STOP_PORT=7985 and RMI_PORT=18985"
  335 @echo.
  336 @echo   -d dir        Specify the Solr server directory; defaults to server
  337 @echo.
  338 @echo   -z zkHost     Zookeeper connection string; only used when running in SolrCloud mode using -c
  339 @echo                   If neither ZK_HOST is defined in solr.in.cmd nor the -z parameter is specified,
  340 @echo                   an embedded ZooKeeper instance will be launched.
  341 @echo.
  342 @echo   -m memory     Sets the min (-Xms) and max (-Xmx) heap size for the JVM, such as: -m 4g
  343 @echo                   results in: -Xms4g -Xmx4g; by default, this script sets the heap size to 512m
  344 @echo.
  345 @echo   -s dir        Sets the solr.solr.home system property; Solr will create core directories under
  346 @echo                   this directory. This allows you to run multiple Solr instances on the same host
  347 @echo                   while reusing the same server directory set using the -d parameter. If set, the
  348 @echo                   specified directory should contain a solr.xml file, unless solr.xml exists in Zookeeper.
  349 @echo                   This parameter is ignored when running examples (-e), as the solr.solr.home depends
  350 @echo                   on which example is run. The default value is server/solr. If passed a relative dir
  351 @echo                   validation with the current dir will be done before trying the default server/^<dir^>
  352 @echo.
  353 @echo   -t dir        Sets the solr.data.home system property, where Solr will store index data in ^<instance_dir^>/data subdirectories.
  354 @echo                   If not set, Solr uses solr.solr.home for both config and data.
  355 @echo.
  356 @echo   -e example    Name of the example to run; available examples:
  357 @echo       cloud:          SolrCloud example
  358 @echo       techproducts:   Comprehensive example illustrating many of Solr's core capabilities
  359 @echo       dih:            Data Import Handler
  360 @echo       schemaless:     Schema-less example
  361 @echo.
  362 @echo   -a opts       Additional parameters to pass to the JVM when starting Solr, such as to setup
  363 @echo                 Java debug options. For example, to enable a Java debugger to attach to the Solr JVM
  364 @echo                 you could pass: -a "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18983"
  365 @echo                 In most cases, you should wrap the additional parameters in double quotes.
  366 @echo.
  367 @echo   -j opts       Additional parameters to pass to Jetty when starting Solr.
  368 @echo                 For example, to add configuration folder that jetty should read
  369 @echo                 you could pass: -j "--include-jetty-dir=/etc/jetty/custom/server/"
  370 @echo                 In most cases, you should wrap the additional parameters in double quotes.
  371 @echo.
  372 @echo   -noprompt     Don't prompt for input; accept all defaults when running examples that accept user input
  373 @echo.
  374 @echo   -v and -q     Verbose (-v) or quiet (-q) logging. Sets default log level to DEBUG or WARN instead of INFO
  375 @echo.
  376 @echo   -V/-verbose   Verbose messages from this script
  377 @echo.
  378 goto done
  379 
  380 :status_usage
  381 @echo.
  382 @echo Usage: solr status
  383 @echo.
  384 @echo   NOTE: This command will show the status of all running Solr servers
  385 @echo.
  386 goto done
  387 
  388 :stop_usage
  389 @echo.
  390 @echo Usage: solr stop [-k key] [-p port] [-V]
  391 @echo.
  392 @echo  -k key      Stop key; default is solrrocks
  393 @echo.
  394 @echo  -p port     Specify the port the Solr HTTP listener is bound to
  395 @echo.
  396 @echo  -all        Find and stop all running Solr servers on this host
  397 @echo.
  398 @echo  -V/-verbose Verbose messages from this script
  399 @echo.
  400 @echo  NOTE: To see if any Solr servers are running, do: solr status
  401 @echo.
  402 goto done
  403 
  404 :healthcheck_usage
  405 @echo.
  406 @echo Usage: solr healthcheck [-c collection] [-z zkHost] [-V] 
  407 @echo.
  408 @echo Can be run from remote (non-Solr^) hosts, as long as a proper ZooKeeper connection is provided
  409 @echo.
  410 @echo   -c collection  Collection to run healthcheck against.
  411 @echo.
  412 @echo   -z zkHost      Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.cmd; 
  413 @echo                    otherwise, default is localhost:9983
  414 @echo.
  415 @echo   -V             Enable more verbose output
  416 @echo.
  417 goto done
  418 
  419 :create_usage
  420 echo.
  421 echo Usage: solr create [-c name] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] [-V]
  422 echo.
  423 echo   Create a core or collection depending on whether Solr is running in standalone (core) or SolrCloud
  424 echo   mode (collection). In other words, this action detects which mode Solr is running in, and then takes
  425 echo   the appropriate action (either create_core or create_collection). For detailed usage instructions, do:
  426 echo.
  427 echo     bin\solr create_core -help
  428 echo.
  429 echo        or
  430 echo.
  431 echo     bin\solr create_collection -help
  432 echo.
  433 goto done
  434 
  435 :delete_usage
  436 echo.
  437 echo Usage: solr delete [-c name] [-deleteConfig true^|false] [-p port] [-V]
  438 echo.
  439 echo  Deletes a core or collection depending on whether Solr is running in standalone (core) or SolrCloud
  440 echo  mode (collection). If you're deleting a collection in SolrCloud mode, the default behavior is to also
  441 echo  delete the configuration directory from Zookeeper so long as it is not being used by another collection.
  442 echo  You can override this behavior by passing -deleteConfig false when running this command.
  443 echo.
  444 echo  Can be run on remote (non-Solr^) hosts, as long as a valid SOLR_HOST is provided in solr.in.cmd
  445 echo.
  446 echo   -c name     Name of core to delete
  447 echo.
  448 echo   -deleteConfig boolean Delete the configuration directory from Zookeeper; default is true
  449 echo.
  450 echo   -p port     Port of a local Solr instance where you want to delete the core/collection
  451 echo                 If not specified, the script will search the local system for a running
  452 echo                 Solr instance and will use the port of the first server it finds.
  453 echo.
  454 echo   -V            Enables more verbose output.
  455 echo.
  456 goto done
  457 
  458 :create_core_usage
  459 echo.
  460 echo Usage: solr create_core [-c ^<core^>] [-d confdir] [-p port] [-V]
  461 echo.
  462 echo When a configSet is used, this can be run from any host.  If pointing at a non-configSet directory, this
  463 echo must be run from the host that you wish to create the core on.
  464 echo.
  465 echo   -c ^<core^>     Name of core to create
  466 echo.
  467 echo   -d confdir  Configuration directory to copy when creating the new core, built-in options are:
  468 echo.
  469 echo       _default: Minimal configuration, which supports enabling/disabling field-guessing support
  470 echo       sample_techproducts_configs: Example configuration with many optional features enabled to
  471 echo          demonstrate the full power of Solr
  472 echo.
  473 echo       If not specified, default is: _default
  474 echo.
  475 echo       Alternatively, you can pass the path to your own configuration directory instead of using
  476 echo       one of the built-in configurations, such as: bin\solr create_core -c mycore -d c:/tmp/myconfig
  477 echo.
  478 echo   -p port     Port of a local Solr instance where you want to create the new core
  479 echo                 If not specified, the script will search the local system for a running
  480 echo                 Solr instance and will use the port of the first server it finds.
  481 echo.
  482 echo   -V            Enable more verbose output.
  483 echo.
  484 goto done
  485 
  486 :create_collection_usage
  487 echo.
  488 echo Usage: solr create_collection [-c collection] [-d confdir] [-n confname] [-shards #] [-replicationFactor #] [-p port] [-V]
  489 echo.
  490 echo Can be run from remote (non-Solr^) hosts, as long as a valid SOLR_HOST is provided in solr.in.cmd.
  491 echo.
  492 echo   -c ^<collection^>         Name of collection to create
  493 echo.
  494 echo   -d ^<confdir^>            Configuration directory to copy when creating the new collection, built-in options are:
  495 echo.
  496 echo       _default: Minimal configuration, which supports enabling/disabling field-guessing support
  497 echo       sample_techproducts_configs: Example configuration with many optional features enabled to
  498 echo          demonstrate the full power of Solr
  499 echo.
  500 echo       If not specified, default is: _default
  501 echo.
  502 echo       Alternatively, you can pass the path to your own configuration directory instead of using
  503 echo       one of the built-in configurations, such as: bin\solr create_collection -c mycoll -d c:/tmp/myconfig
  504 echo.
  505 echo       By default the script will upload the specified confdir directory into Zookeeper using the same
  506 echo         name as the collection (-c) option. Alternatively, if you want to reuse an existing directory
  507 echo         or create a confdir in Zookeeper that can be shared by multiple collections, use the -n option
  508 echo.
  509 echo   -n configName         Name the configuration directory in Zookeeper; by default, the configuration
  510 echo                             will be uploaded to Zookeeper using the collection name (-c), but if you want
  511 echo                             to use an existing directory or override the name of the configuration in
  512 echo                              Zookeeper, then use the -c option.
  513 echo.
  514 echo   -shards #             Number of shards to split the collection into; default is 1
  515 echo.
  516 echo   -replicationFactor #  Number of copies of each document in the collection, default is 1 (no replication)
  517 echo.
  518 echo   -p port               Port of a local Solr instance where you want to create the new collection
  519 echo                           If not specified, the script will search the local system for a running
  520 echo                           Solr instance and will use the port of the first server it finds.
  521 echo.
  522 echo   -V                    Enable more verbose output.
  523 echo.
  524 goto done
  525 
  526 :zk_usage
  527 set ZK_FULL=true
  528 goto zk_short_usage
  529 :zk_full_usage
  530 echo         Can be run on remote (non-Solr^) hosts, as long as valid ZK_HOST information is provided.
  531 echo         Be sure to check the Solr logs in case of errors.
  532 echo.
  533 echo             -z zkHost       Optional Zookeeper connection string for all commands. If specified it
  534 echo                             overrides the 'ZK_HOST=...'' defined in solr.in.cmd.
  535 echo.
  536 echo             -V              Enable more verbose output.
  537 echo.
  538 echo         upconfig uploads a configset from the local machine to Zookeeper. (Backcompat: -upconfig)
  539 echo.
  540 echo         downconfig downloads a configset from Zookeeper to the local machine. (Backcompat: -downconfig)
  541 echo.
  542 echo             -n configName   Name of the configset in Zookeeper that will be the destination of
  543 echo                             'upconfig' and the source for 'downconfig'.
  544 echo.
  545 echo             -d confdir      The local directory the configuration will be uploaded from for
  546 echo                             'upconfig' or downloaded to for 'downconfig'. If 'confdir' is a child of
  547 echo                             ...solr/server/solr/configsets' then the configs will be copied from/to
  548 echo                             that directory. Otherwise it is interpreted as a simple local path.
  549 echo.
  550 echo         cp copies files or folders to/from Zookeeper or Zokeeper -^> Zookeeper
  551 echo             -r              Recursively copy ^<src^> to ^<dst^>. Command will fail if ^<src^> has children and
  552 echo                             -r is not specified. Optional
  553 echo.
  554 echo.             ^<src^>, ^<dest^> : [file:][/]path/to/local/file or zk:/path/to/zk/node
  555 echo                              NOTE: ^<src^> and ^<dest^> may both be Zookeeper resources prefixed by 'zk:'
  556 echo             When ^<src^> is a zk resource, ^<dest^> may be '.'
  557 echo             If ^<dest^> ends with '/', then ^<dest^> will be a local folder or parent znode and the last
  558 echo             element of the ^<src^> path will be appended unless ^<src^> also ends in a slash. 
  559 echo             ^<dest^> may be zk:, which may be useful when using the cp -r form to backup/restore 
  560 echo             the entire zk state.
  561 echo             You must enclose local paths that end in a wildcard in quotes or just
  562 echo             end the local path in a slash. That is,
  563 echo             'bin/solr zk cp -r /some/dir/ zk:/ -z localhost:2181' is equivalent to
  564 echo             'bin/solr zk cp -r ^"/some/dir/*^" zk:/ -z localhost:2181'
  565 echo             but 'bin/solr zk cp -r /some/dir/* zk:/ -z localhost:2181' will throw an error.
  566 echo.
  567 echo             Here's an example of backup/restore for a ZK configuration:
  568 echo             to copy to local: 'bin/solr zk cp -r zk:/ /some/dir -z localhost:2181'
  569 echo             to restore to ZK: 'bin/solr zk cp -r /some/dir/ zk:/ -z localhost:2181'
  570 echo.
  571 echo             The 'file:' prefix is stripped, thus 'file:/wherever' specifies an absolute local path and
  572 echo             'file:somewhere' specifies a relative local path. All paths on Zookeeper are absolute.
  573 echo.
  574 echo             Zookeeper nodes CAN have data, so moving a single file to a parent znode
  575 echo             will overlay the data on the parent Znode so specifying the trailing slash
  576 echo             can be important.
  577 echo.
  578 echo             Wildcards are supported when copying from local, trailing only and must be quoted.
  579 echo.
  580 echo         rm deletes files or folders on Zookeeper
  581 echo             -r     Recursively delete if ^<path^> is a directory. Command will fail if ^<path^>
  582 echo                    has children and -r is not specified. Optional
  583 echo             ^<path^> : [zk:]/path/to/zk/node. ^<path^> may not be the root ('/')
  584 echo.
  585 echo         mv moves (renames) znodes on Zookeeper
  586 echo             ^<src^>, ^<dest^> : Zookeeper nodes, the 'zk:' prefix is optional.
  587 echo             If ^<dest^> ends with '/', then ^<dest^> will be a parent znode
  588 echo             and the last element of the ^<src^> path will be appended.
  589 echo             Zookeeper nodes CAN have data, so moving a single file to a parent znode
  590 echo             will overlay the data on the parent Znode so specifying the trailing slash
  591 echo             is important.
  592 echo.
  593 echo         ls lists the znodes on Zookeeper
  594 echo             -r recursively descends the path listing all znodes. Optional
  595 echo             ^<path^>: The Zookeeper path to use as the root.
  596 echo.
  597 echo             Only the node names are listed, not data
  598 echo.
  599 echo         mkroot makes a znode in Zookeeper with no data. Can be used to make a path of arbitrary
  600 echo                depth but primarily intended to create a 'chroot'.
  601 echo.
  602 echo             ^<path^>: The Zookeeper path to create. Leading slash is assumed if not present.
  603 echo                       Intermediate nodes are created as needed if not present.
  604 echo.
  605 
  606 goto done
  607 
  608 :zk_short_usage
  609 IF NOT "!ERROR_MSG!"=="" (
  610   echo  ERROR: !ERROR_MSG!
  611   echo.
  612 )
  613 echo  Usage: solr zk upconfig^|downconfig -d ^<confdir^> -n ^<configName^> [-z zkHost]
  614 echo         solr zk cp [-r] ^<src^> ^<dest^> [-z zkHost]
  615 echo         solr zk rm [-r] ^<path^> [-z zkHost]
  616 echo         solr zk mv ^<src^> ^<dest^> [-z zkHost]
  617 echo         solr zk ls [-r] ^<path^> [-z zkHost]
  618 echo         solr zk mkroot ^<path^> [-z zkHost]
  619 echo.
  620 IF "%ZK_FULL%"=="true" (
  621   goto zk_full_usage
  622 ) ELSE (
  623   echo Type bin/solr zk -help for full usage help
  624 )
  625 goto done
  626 
  627 :auth_usage
  628 echo Usage: solr auth enable [-type basicAuth] -credentials user:pass [-blockUnknown ^<true^|false^>] [-updateIncludeFileOnly ^<true^|false^>] [-V]
  629 echo        solr auth enable [-type basicAuth] -prompt ^<true^|false^> [-blockUnknown ^<true^|false^>] [-updateIncludeFileOnly ^<true^|false^>] [-V]
  630 echo        solr auth disable [-updateIncludeFileOnly ^<true^|false^>] [-V]
  631 echo.
  632 echo  Updates or enables/disables authentication.  Must be run on the machine hosting Solr.
  633 echo.
  634 echo   -type ^<type^>                 The authentication mechanism to enable. Defaults to 'basicAuth'.
  635 echo.
  636 echo   -credentials ^<user:pass^>     The username and password of the initial user
  637 echo                                Note: only one of -prompt or -credentials must be provided
  638 echo.
  639 echo   -prompt ^<true^|false^>         Prompts the user to provide the credentials
  640 echo                                Note: only one of -prompt or -credentials must be provided
  641 echo.
  642 echo   -blockUnknown ^<true^|false^>   When true, this blocks out access to unauthenticated users. When not provided,
  643 echo                                this defaults to false (i.e. unauthenticated users can access all endpoints, except the
  644 echo                                operations like collection-edit, security-edit, core-admin-edit etc.^). Check the reference
  645 echo                                guide for Basic Authentication for more details.
  646 echo.
  647 echo   -updateIncludeFileOnly ^<true^|false^>    Only update the solr.in.sh or solr.in.cmd file, and skip actual enabling/disabling"
  648 echo                                          authentication (i.e. don't update security.json^)"
  649 echo.
  650 echo   -z zkHost                    Zookeeper connection string. Unnecessary if ZK_HOST is defined in solr.in.cmd.
  651 echo.
  652 echo   -d ^<dir^>                     Specify the Solr server directory"
  653 echo.
  654 echo   -s ^<dir^>                     Specify the Solr home directory. This is where any credentials or authentication"
  655 echo                                configuration files (e.g. basicAuth.conf^) would be placed."
  656 echo.
  657 echo   -V                           Enable more verbose output
  658 echo.
  659 goto done
  660 
  661 REM Really basic command-line arg parsing
  662 :parse_args
  663 
  664 set "arg=%~1"
  665 set "firstTwo=%arg:~0,2%"
  666 IF "%SCRIPT_CMD%"=="" set SCRIPT_CMD=start
  667 IF [%1]==[] goto process_script_cmd
  668 IF "%1"=="-help" goto usage
  669 IF "%1"=="-usage" goto usage
  670 IF "%1"=="/?" goto usage
  671 IF "%1"=="-f" goto set_foreground_mode
  672 IF "%1"=="-foreground" goto set_foreground_mode
  673 IF "%1"=="-V" goto set_verbose
  674 IF "%1"=="-verbose" goto set_verbose
  675 IF "%1"=="-v" goto set_debug
  676 IF "%1"=="-q" goto set_warn
  677 IF "%1"=="-c" goto set_cloud_mode
  678 IF "%1"=="-cloud" goto set_cloud_mode
  679 IF "%1"=="-d" goto set_server_dir
  680 IF "%1"=="-dir" goto set_server_dir
  681 IF "%1"=="-s" goto set_solr_home_dir
  682 IF "%1"=="-t" goto set_solr_data_dir
  683 IF "%1"=="-solr.home" goto set_solr_home_dir
  684 IF "%1"=="-e" goto set_example
  685 IF "%1"=="-example" goto set_example
  686 IF "%1"=="-h" goto set_host
  687 IF "%1"=="-host" goto set_host
  688 IF "%1"=="-m" goto set_memory
  689 IF "%1"=="-memory" goto set_memory
  690 IF "%1"=="-p" goto set_port
  691 IF "%1"=="-port" goto set_port
  692 IF "%1"=="-z" goto set_zookeeper
  693 IF "%1"=="-zkhost" goto set_zookeeper
  694 IF "%1"=="-zkHost" goto set_zookeeper
  695 IF "%1"=="-a" goto set_addl_opts
  696 IF "%1"=="-addlopts" goto set_addl_opts
  697 IF "%1"=="-j" goto set_addl_jetty_config
  698 IF "%1"=="-jettyconfig" goto set_addl_jetty_config
  699 IF "%1"=="-noprompt" goto set_noprompt
  700 IF "%1"=="-k" goto set_stop_key
  701 IF "%1"=="-key" goto set_stop_key
  702 IF "%1"=="-all" goto set_stop_all
  703 IF "%firstTwo%"=="-D" goto set_passthru
  704 IF NOT "%1"=="" goto invalid_cmd_line
  705 goto invalid_cmd_line
  706 
  707 :set_script_cmd
  708 set SCRIPT_CMD=%1
  709 SHIFT
  710 goto parse_args
  711 
  712 :set_foreground_mode
  713 set FG=1
  714 SHIFT
  715 goto parse_args
  716 
  717 :set_verbose
  718 set verbose=1
  719 set "PASS_TO_RUN_EXAMPLE=--verbose !PASS_TO_RUN_EXAMPLE!"
  720 SHIFT
  721 goto parse_args
  722 
  723 :set_debug
  724 set SOLR_LOG_LEVEL=DEBUG
  725 SHIFT
  726 goto parse_args
  727 
  728 :set_warn
  729 set SOLR_LOG_LEVEL=WARN
  730 SHIFT
  731 goto parse_args
  732 
  733 :set_cloud_mode
  734 set SOLR_MODE=solrcloud
  735 SHIFT
  736 goto parse_args
  737 
  738 :set_server_dir
  739 
  740 set "arg=%~2"
  741 IF "%arg%"=="" (
  742   set SCRIPT_ERROR=Directory name is required!
  743   goto invalid_cmd_line
  744 )
  745 set firstChar=%arg:~0,1%
  746 IF "%firstChar%"=="-" (
  747   set SCRIPT_ERROR=Expected directory but found %2 instead!
  748   goto invalid_cmd_line
  749 )
  750 
  751 REM See if they are using a short-hand name relative from the Solr tip directory
  752 IF EXIST "%SOLR_TIP%\%~2" (
  753   set "SOLR_SERVER_DIR=%SOLR_TIP%\%~2"
  754 ) ELSE (
  755   set "SOLR_SERVER_DIR=%~2"
  756 )
  757 SHIFT
  758 SHIFT
  759 goto parse_args
  760 
  761 :set_solr_home_dir
  762 
  763 set "arg=%~2"
  764 IF "%arg%"=="" (
  765   set SCRIPT_ERROR=Directory name is required!
  766   goto invalid_cmd_line
  767 )
  768 
  769 set firstChar=%arg:~0,1%
  770 IF "%firstChar%"=="-" (
  771   set SCRIPT_ERROR=Expected directory but found %2 instead!
  772   goto invalid_cmd_line
  773 )
  774 set "SOLR_HOME=%~2"
  775 SHIFT
  776 SHIFT
  777 goto parse_args
  778 
  779 :set_solr_data_dir
  780 
  781 set "arg=%~2"
  782 IF "%arg%"=="" (
  783   set SCRIPT_ERROR=Directory name is required!
  784   goto invalid_cmd_line
  785 )
  786 
  787 set firstChar=%arg:~0,1%
  788 IF "%firstChar%"=="-" (
  789   set SCRIPT_ERROR=Expected directory but found %2 instead!
  790   goto invalid_cmd_line
  791 )
  792 set "SOLR_DATA_HOME=%~2"
  793 SHIFT
  794 SHIFT
  795 goto parse_args
  796 
  797 :set_example
  798 
  799 set "arg=%~2"
  800 IF "%arg%"=="" (
  801   set SCRIPT_ERROR=Example name is required!
  802   goto invalid_cmd_line
  803 )
  804 
  805 set firstChar=%arg:~0,1%
  806 IF "%firstChar%"=="-" (
  807   set SCRIPT_ERROR=Expected example name but found %2 instead!
  808   goto invalid_cmd_line
  809 )
  810 
  811 set EXAMPLE=%~2
  812 SHIFT
  813 SHIFT
  814 goto parse_args
  815 
  816 :set_memory
  817 
  818 set "arg=%~2"
  819 IF "%arg%"=="" (
  820   set SCRIPT_ERROR=Memory setting is required!
  821   goto invalid_cmd_line
  822 )
  823 
  824 set firstChar=%arg:~0,1%
  825 IF "%firstChar%"=="-" (
  826   set SCRIPT_ERROR=Expected memory setting but found %2 instead!
  827   goto invalid_cmd_line
  828 )
  829 
  830 set SOLR_HEAP=%~2
  831 set "PASS_TO_RUN_EXAMPLE=-m %~2 !PASS_TO_RUN_EXAMPLE!"
  832 SHIFT
  833 SHIFT
  834 goto parse_args
  835 
  836 :set_host
  837 set "arg=%~2"
  838 IF "%arg%"=="" (
  839   set SCRIPT_ERROR=Hostname is required!
  840   goto invalid_cmd_line
  841 )
  842 
  843 set firstChar=%arg:~0,1%
  844 IF "%firstChar%"=="-" (
  845   set SCRIPT_ERROR=Expected hostname but found %2 instead!
  846   goto invalid_cmd_line
  847 )
  848 
  849 set SOLR_HOST=%~2
  850 set "PASS_TO_RUN_EXAMPLE=-h %~2 !PASS_TO_RUN_EXAMPLE!"
  851 SHIFT
  852 SHIFT
  853 goto parse_args
  854 
  855 :set_port
  856 set "arg=%~2"
  857 IF "%arg%"=="" (
  858   set SCRIPT_ERROR=Port is required!
  859   goto invalid_cmd_line
  860 )
  861 
  862 set firstChar=%arg:~0,1%
  863 IF "%firstChar%"=="-" (
  864   set SCRIPT_ERROR=Expected port but found %2 instead!
  865   goto invalid_cmd_line
  866 )
  867 
  868 set SOLR_PORT=%~2
  869 set "PASS_TO_RUN_EXAMPLE=-p %~2 !PASS_TO_RUN_EXAMPLE!"
  870 SHIFT
  871 SHIFT
  872 goto parse_args
  873 
  874 :set_stop_key
  875 set "arg=%~2"
  876 IF "%arg%"=="" (
  877   set SCRIPT_ERROR=Stop key is required!
  878   goto invalid_cmd_line
  879 )
  880 
  881 set firstChar=%arg:~0,1%
  882 IF "%firstChar%"=="-" (
  883   set SCRIPT_ERROR=Expected stop key but found %2 instead!
  884   goto invalid_cmd_line
  885 )
  886 set STOP_KEY=%~2
  887 SHIFT
  888 SHIFT
  889 goto parse_args
  890 
  891 :set_stop_all
  892 set STOP_ALL=1
  893 SHIFT
  894 goto parse_args
  895 
  896 :set_zookeeper
  897 
  898 set "arg=%~2"
  899 IF "%arg%"=="" (
  900   set SCRIPT_ERROR=Zookeeper connection string is required!
  901   goto invalid_cmd_line
  902 )
  903 
  904 set firstChar=%arg:~0,1%
  905 IF "%firstChar%"=="-" (
  906   set SCRIPT_ERROR=Expected Zookeeper connection string but found %2 instead!
  907   goto invalid_cmd_line
  908 )
  909 
  910 set "ZK_HOST=%~2"
  911 set "PASS_TO_RUN_EXAMPLE=-z %~2 !PASS_TO_RUN_EXAMPLE!"
  912 SHIFT
  913 SHIFT
  914 goto parse_args
  915 
  916 :set_addl_opts
  917 set "arg=%~2"
  918 set "SOLR_ADDL_ARGS=%~2"
  919 SHIFT
  920 SHIFT
  921 goto parse_args
  922 
  923 :set_addl_jetty_config
  924 set "arg=%~2"
  925 set "SOLR_JETTY_ADDL_CONFIG=%~2"
  926 SHIFT
  927 SHIFT
  928 goto parse_args
  929 
  930 :set_passthru
  931 set "PASSTHRU=%~1=%~2"
  932 IF NOT "%SOLR_OPTS%"=="" (
  933   set "SOLR_OPTS=%SOLR_OPTS% %PASSTHRU%"
  934 ) ELSE (
  935   set "SOLR_OPTS=%PASSTHRU%"
  936 )
  937 set "PASS_TO_RUN_EXAMPLE=%PASSTHRU% !PASS_TO_RUN_EXAMPLE!"
  938 SHIFT
  939 SHIFT
  940 goto parse_args
  941 
  942 :set_noprompt
  943 set NO_USER_PROMPT=1
  944 set "PASS_TO_RUN_EXAMPLE=-noprompt !PASS_TO_RUN_EXAMPLE!"
  945 
  946 SHIFT
  947 goto parse_args
  948 
  949 REM Perform the requested command after processing args
  950 :process_script_cmd
  951 
  952 IF "%verbose%"=="1" (
  953   CALL :safe_echo "Using Solr root directory: %SOLR_TIP%"
  954   CALL :safe_echo "Using Java: %JAVA%"
  955   "%JAVA%" -version
  956   @echo.
  957 )
  958 
  959 IF NOT "%SOLR_HOST%"=="" (
  960   set SOLR_HOST_ARG=-Dhost=%SOLR_HOST%
  961 ) ELSE (
  962   set SOLR_HOST_ARG=
  963 )
  964 
  965 IF "%SOLR_SERVER_DIR%"=="" set "SOLR_SERVER_DIR=%DEFAULT_SERVER_DIR%"
  966 
  967 IF NOT EXIST "%SOLR_SERVER_DIR%" (
  968   set "SCRIPT_ERROR=Solr server directory %SOLR_SERVER_DIR% not found!"
  969   goto err
  970 )
  971 
  972 IF NOT "%EXAMPLE%"=="" goto run_example
  973 
  974 :start_solr
  975 IF "%SOLR_HOME%"=="" set "SOLR_HOME=%SOLR_SERVER_DIR%\solr"
  976 IF EXIST "%cd%\%SOLR_HOME%" set "SOLR_HOME=%cd%\%SOLR_HOME%"
  977 
  978 IF NOT EXIST "%SOLR_HOME%\" (
  979   IF EXIST "%SOLR_SERVER_DIR%\%SOLR_HOME%" (
  980     set "SOLR_HOME=%SOLR_SERVER_DIR%\%SOLR_HOME%"
  981   ) ELSE (
  982     set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% not found!"
  983     goto err
  984   )
  985 )
  986 
  987 IF "%STOP_KEY%"=="" set STOP_KEY=solrrocks
  988 
  989 @REM This is quite hacky, but examples rely on a different log4j2.xml
  990 @REM so that we can write logs for examples to %SOLR_HOME%\..\logs
  991 IF [%SOLR_LOGS_DIR%] == [] (
  992   set "SOLR_LOGS_DIR=%SOLR_SERVER_DIR%\logs"
  993 ) ELSE (
  994   set SOLR_LOGS_DIR=%SOLR_LOGS_DIR:"=%
  995 )
  996 
  997 set "EXAMPLE_DIR=%SOLR_TIP%\example"
  998 set TMP_SOLR_HOME=!SOLR_HOME:%EXAMPLE_DIR%=!
  999 IF NOT "%TMP_SOLR_HOME%"=="%SOLR_HOME%" (
 1000   set "SOLR_LOGS_DIR=%SOLR_HOME%\..\logs"
 1001   set "LOG4J_CONFIG=file:///%SOLR_SERVER_DIR%\resources\log4j2.xml"
 1002 )
 1003 
 1004 set IS_RESTART=0
 1005 IF "%SCRIPT_CMD%"=="restart" (
 1006   IF "%SOLR_PORT%"=="" (
 1007     set "SCRIPT_ERROR=Must specify the port when trying to restart Solr."
 1008     goto err
 1009   )
 1010   set SCRIPT_CMD=stop
 1011   set IS_RESTART=1
 1012 )
 1013 
 1014 @REM stop logic here
 1015 IF "%SCRIPT_CMD%"=="stop" (
 1016   IF "%SOLR_PORT%"=="" (
 1017     IF "%STOP_ALL%"=="1" (
 1018       set found_it=0
 1019       for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
 1020         set SOME_SOLR_PORT=
 1021         For /F "delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
 1022         if NOT "!SOME_SOLR_PORT!"=="" (
 1023           for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1024             @REM j is the ip:port and k is the pid
 1025             IF NOT "%%k"=="0" (
 1026               IF "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
 1027                 set found_it=1
 1028                 @echo Stopping Solr process %%k running on port !SOME_SOLR_PORT!
 1029                 IF "%STOP_PORT%"=="" set /A STOP_PORT=!SOME_SOLR_PORT! - 1000
 1030                 "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
 1031                 del "%SOLR_TIP%"\bin\solr-!SOME_SOLR_PORT!.port
 1032                 timeout /T 5
 1033                 REM Kill it if it is still running after the graceful shutdown
 1034                 For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1035                   IF "%%N"=="%%k" (
 1036                     IF "%%M"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
 1037                       @echo Forcefully killing process %%N
 1038                       taskkill /f /PID %%N
 1039                     )
 1040                   )
 1041                 )
 1042               )
 1043             )
 1044           )
 1045         )
 1046       )
 1047       if "!found_it!"=="0" echo No Solr nodes found to stop.
 1048     ) ELSE (
 1049       set "SCRIPT_ERROR=Must specify the port when trying to stop Solr, or use -all to stop all running nodes on this host."
 1050       goto err
 1051     )
 1052   ) ELSE (
 1053     set found_it=0
 1054     For /f "tokens=2,5" %%M in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
 1055       IF NOT "%%N"=="0" (
 1056         IF "%%M"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
 1057           set found_it=1
 1058           @echo Stopping Solr process %%N running on port %SOLR_PORT%
 1059           IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
 1060           "%JAVA%" %SOLR_SSL_OPTS% -Djetty.home="%SOLR_SERVER_DIR%" -jar "%SOLR_SERVER_DIR%\start.jar" %SOLR_JETTY_CONFIG% STOP.PORT=!STOP_PORT! STOP.KEY=%STOP_KEY% --stop
 1061           del "%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
 1062           timeout /T 5
 1063           REM Kill it if it is still running after the graceful shutdown
 1064           For /f "tokens=2,5" %%j in ('netstat -nao ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
 1065             IF "%%N"=="%%k" (
 1066               IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
 1067                 @echo Forcefully killing process %%N
 1068                 taskkill /f /PID %%N
 1069               )
 1070             )
 1071           )
 1072         )
 1073       )
 1074     )
 1075     if "!found_it!"=="0" echo No Solr found running on port %SOLR_PORT%
 1076   )
 1077 
 1078   IF "!IS_RESTART!"=="0" goto done
 1079 )
 1080 
 1081 IF "!IS_RESTART!"=="1" set SCRIPT_CMD=start
 1082 
 1083 IF "%SOLR_PORT%"=="" set SOLR_PORT=8983
 1084 IF "%STOP_PORT%"=="" set /A STOP_PORT=%SOLR_PORT% - 1000
 1085 
 1086 IF "%SCRIPT_CMD%"=="start" (
 1087   REM see if Solr is already running using netstat
 1088   For /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":%SOLR_PORT% "') do (
 1089     IF NOT "%%k"=="0" (
 1090       IF "%%j"=="%SOLR_JETTY_HOST%:%SOLR_PORT%" (
 1091         set "SCRIPT_ERROR=Process %%k is already listening on port %SOLR_PORT%. If this is Solr, please stop it first before starting (or use restart). If this is not Solr, then please choose a different port using -p PORT"
 1092         goto err
 1093       )
 1094     )
 1095   )
 1096 )
 1097 
 1098 @REM determine if -server flag is supported by current JVM
 1099 "%JAVA%" -server -version > nul 2>&1
 1100 IF ERRORLEVEL 1 (
 1101   set IS_JDK=false
 1102   set "SERVEROPT="
 1103   @echo WARNING: You are using a JRE without support for -server option. Please upgrade to latest JDK for best performance
 1104   @echo.
 1105 ) ELSE (
 1106   set IS_JDK=true
 1107   set "SERVEROPT=-server"
 1108 )
 1109 if !JAVA_MAJOR_VERSION! LSS 9  (
 1110   "%JAVA%" -d64 -version > nul 2>&1
 1111   IF ERRORLEVEL 1 (
 1112     set "IS_64BIT=false"
 1113     @echo WARNING: 32-bit Java detected. Not recommended for production. Point your JAVA_HOME to a 64-bit JDK
 1114     @echo.
 1115   ) ELSE (
 1116     set IS_64bit=true
 1117   )
 1118 ) ELSE (
 1119   set IS_64bit=true
 1120 )
 1121 
 1122 REM Clean up and rotate logs. Default to false since 7.4 as log4j2 handles startup rotation
 1123 IF [%SOLR_LOG_PRESTART_ROTATION%] == [] (
 1124   set SOLR_LOG_PRESTART_ROTATION=false
 1125 )
 1126 IF [%SOLR_LOG_PRESTART_ROTATION%] == [true] (
 1127   REM Enable any of these if you require old remove/archive behavior
 1128   REM call :run_utils "-remove_old_solr_logs 7" || echo "Failed removing old solr logs"
 1129   REM call :run_utils "-archive_gc_logs"        || echo "Failed archiving old GC logs"
 1130   REM call :run_utils "-archive_console_logs"   || echo "Failed archiving old console logs"
 1131   call :run_utils "-rotate_solr_logs 9"     || echo "Failed rotating old solr logs"
 1132 )
 1133 
 1134 IF NOT "%ZK_HOST%"=="" set SOLR_MODE=solrcloud
 1135 
 1136 IF "%SOLR_MODE%"=="solrcloud" (
 1137   IF "%ZK_CLIENT_TIMEOUT%"=="" set "ZK_CLIENT_TIMEOUT=15000"
 1138 
 1139   set "CLOUD_MODE_OPTS=-DzkClientTimeout=!ZK_CLIENT_TIMEOUT!"
 1140 
 1141   IF NOT "%ZK_HOST%"=="" (
 1142     set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkHost=%ZK_HOST%"
 1143   ) ELSE (
 1144     IF "%verbose%"=="1" echo Configuring SolrCloud to launch an embedded Zookeeper using -DzkRun
 1145     set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -DzkRun"
 1146   )
 1147   IF EXIST "%SOLR_HOME%\collection1\core.properties" set "CLOUD_MODE_OPTS=!CLOUD_MODE_OPTS! -Dbootstrap_confdir=./solr/collection1/conf -Dcollection.configName=myconf -DnumShards=1"
 1148 ) ELSE (
 1149   set CLOUD_MODE_OPTS=
 1150   IF NOT EXIST "%SOLR_HOME%\solr.xml" (
 1151     set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% must contain solr.xml!"
 1152     goto err
 1153   )
 1154 )
 1155 
 1156 REM These are useful for attaching remove profilers like VisualVM/JConsole
 1157 IF "%ENABLE_REMOTE_JMX_OPTS%"=="true" (
 1158   IF "!RMI_PORT!"=="" set RMI_PORT=1%SOLR_PORT%
 1159   set REMOTE_JMX_OPTS=-Dcom.sun.management.jmxremote ^
 1160 -Dcom.sun.management.jmxremote.local.only=false ^
 1161 -Dcom.sun.management.jmxremote.ssl=false ^
 1162 -Dcom.sun.management.jmxremote.authenticate=false ^
 1163 -Dcom.sun.management.jmxremote.port=!RMI_PORT! ^
 1164 -Dcom.sun.management.jmxremote.rmi.port=!RMI_PORT!
 1165 
 1166   IF NOT "%SOLR_HOST%"=="" set REMOTE_JMX_OPTS=%REMOTE_JMX_OPTS% -Djava.rmi.server.hostname=%SOLR_HOST%
 1167 ) ELSE (
 1168   set REMOTE_JMX_OPTS=
 1169 )
 1170 
 1171 IF NOT "%SOLR_HEAP%"=="" set SOLR_JAVA_MEM=-Xms%SOLR_HEAP% -Xmx%SOLR_HEAP%
 1172 IF "%SOLR_JAVA_MEM%"=="" set SOLR_JAVA_MEM=-Xms512m -Xmx512m
 1173 IF "%SOLR_JAVA_STACK_SIZE%"=="" set SOLR_JAVA_STACK_SIZE=-Xss256k
 1174 set SOLR_OPTS=%SOLR_JAVA_STACK_SIZE% %SOLR_OPTS%
 1175 IF "%SOLR_TIMEZONE%"=="" set SOLR_TIMEZONE=UTC
 1176 
 1177 IF "%GC_TUNE%"=="" (
 1178   set GC_TUNE=-XX:+UseG1GC ^
 1179     -XX:+PerfDisableSharedMem ^
 1180     -XX:+ParallelRefProcEnabled ^
 1181     -XX:MaxGCPauseMillis=250 ^
 1182     -XX:+UseLargePages ^
 1183     -XX:+AlwaysPreTouch
 1184 )
 1185 
 1186 if !JAVA_MAJOR_VERSION! GEQ 9  (
 1187   IF NOT "%GC_LOG_OPTS%"=="" (
 1188     echo ERROR: On Java 9 you cannot set GC_LOG_OPTS, only default GC logging is available. Exiting
 1189     GOTO :eof
 1190   )
 1191   set GC_LOG_OPTS="-Xlog:gc*:file=\"!SOLR_LOGS_DIR!\solr_gc.log\":time,uptime:filecount=9,filesize=20M"
 1192 ) else (
 1193   IF "%GC_LOG_OPTS%"=="" (
 1194     rem Set defaults for Java 8
 1195     set GC_LOG_OPTS=-verbose:gc ^
 1196      -XX:+PrintHeapAtGC ^
 1197      -XX:+PrintGCDetails ^
 1198      -XX:+PrintGCDateStamps ^
 1199      -XX:+PrintGCTimeStamps ^
 1200      -XX:+PrintTenuringDistribution ^
 1201      -XX:+PrintGCApplicationStoppedTime
 1202   )
 1203   if "%JAVA_VENDOR%" == "IBM J9" (
 1204     set GC_LOG_OPTS=!GC_LOG_OPTS! "-Xverbosegclog:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M
 1205   ) else (
 1206     set GC_LOG_OPTS=!GC_LOG_OPTS! "-Xloggc:!SOLR_LOGS_DIR!\solr_gc.log" -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M
 1207   )
 1208 )
 1209 
 1210 IF "%verbose%"=="1" (
 1211   @echo Starting Solr using the following settings:
 1212   CALL :safe_echo "    JAVA            = %JAVA%"
 1213   CALL :safe_echo "    SOLR_SERVER_DIR = %SOLR_SERVER_DIR%"
 1214   CALL :safe_echo "    SOLR_HOME       = %SOLR_HOME%"
 1215   @echo     SOLR_HOST       = %SOLR_HOST%
 1216   @echo     SOLR_PORT       = %SOLR_PORT%
 1217   @echo     STOP_PORT       = %STOP_PORT%
 1218   @echo     SOLR_JAVA_MEM   = %SOLR_JAVA_MEM%
 1219   @echo     GC_TUNE         = !GC_TUNE!
 1220   @echo     GC_LOG_OPTS     = %GC_LOG_OPTS%
 1221   @echo     SOLR_TIMEZONE   = %SOLR_TIMEZONE%
 1222 
 1223   IF "%SOLR_MODE%"=="solrcloud" (
 1224     @echo     CLOUD_MODE_OPTS = %CLOUD_MODE_OPTS%
 1225   )
 1226 
 1227   IF NOT "%SOLR_OPTS%"=="" (
 1228     @echo     SOLR_OPTS       = %SOLR_OPTS%
 1229   )
 1230 
 1231   IF NOT "%SOLR_ADDL_ARGS%"=="" (
 1232     CALL :safe_echo "     SOLR_ADDL_ARGS  = %SOLR_ADDL_ARGS%"
 1233   )
 1234 
 1235   IF NOT "%SOLR_JETTY_ADDL_CONFIG%"=="" (
 1236     CALL :safe_echo "     SOLR_JETTY_ADDL_CONFIG  = %SOLR_JETTY_ADDL_CONFIG%"
 1237   )
 1238 
 1239   IF "%ENABLE_REMOTE_JMX_OPTS%"=="true" (
 1240     @echo     RMI_PORT        = !RMI_PORT!
 1241     @echo     REMOTE_JMX_OPTS = %REMOTE_JMX_OPTS%
 1242   )
 1243 
 1244   IF NOT "%SOLR_LOG_LEVEL%"=="" (
 1245     @echo     SOLR_LOG_LEVEL  = !SOLR_LOG_LEVEL!
 1246   )
 1247 
 1248   IF NOT "%SOLR_DATA_HOME%"=="" (
 1249     @echo     SOLR_DATA_HOME  = !SOLR_DATA_HOME!
 1250   )
 1251 
 1252   @echo.
 1253 )
 1254 
 1255 set START_OPTS=-Duser.timezone=%SOLR_TIMEZONE%
 1256 set START_OPTS=%START_OPTS% !GC_TUNE! %GC_LOG_OPTS%
 1257 IF NOT "!CLOUD_MODE_OPTS!"=="" set "START_OPTS=%START_OPTS% !CLOUD_MODE_OPTS!"
 1258 IF NOT "%REMOTE_JMX_OPTS%"=="" set "START_OPTS=%START_OPTS% %REMOTE_JMX_OPTS%"
 1259 IF NOT "%SOLR_ADDL_ARGS%"=="" set "START_OPTS=%START_OPTS% %SOLR_ADDL_ARGS%"
 1260 IF NOT "%SOLR_HOST_ARG%"=="" set "START_OPTS=%START_OPTS% %SOLR_HOST_ARG%"
 1261 IF NOT "%SOLR_OPTS%"=="" set "START_OPTS=%START_OPTS% %SOLR_OPTS%"
 1262 IF "%SOLR_SSL_ENABLED%"=="true" (
 1263   set "SSL_PORT_PROP=-Dsolr.jetty.https.port=%SOLR_PORT%"
 1264   set "START_OPTS=%START_OPTS% %SOLR_SSL_OPTS% !SSL_PORT_PROP!"
 1265 )
 1266 IF NOT "%SOLR_LOG_LEVEL%"=="" set "START_OPTS=%START_OPTS% -Dsolr.log.level=%SOLR_LOG_LEVEL%"
 1267 
 1268 set SOLR_LOGS_DIR_QUOTED="%SOLR_LOGS_DIR%"
 1269 set SOLR_DATA_HOME_QUOTED="%SOLR_DATA_HOME%"
 1270 
 1271 set "START_OPTS=%START_OPTS% -Dsolr.log.dir=%SOLR_LOGS_DIR_QUOTED%"
 1272 IF NOT "%SOLR_DATA_HOME%"=="" set "START_OPTS=%START_OPTS% -Dsolr.data.home=%SOLR_DATA_HOME_QUOTED%"
 1273 IF NOT DEFINED LOG4J_CONFIG set "LOG4J_CONFIG=file:///%SOLR_SERVER_DIR%\resources\log4j2.xml"
 1274 
 1275 cd /d "%SOLR_SERVER_DIR%"
 1276 
 1277 IF NOT EXIST "%SOLR_LOGS_DIR%" (
 1278   mkdir "%SOLR_LOGS_DIR%"
 1279 )
 1280 copy /Y NUL "%SOLR_LOGS_DIR%\.writable" > NUL 2>&1 && set WRITEOK=1
 1281 IF DEFINED WRITEOK (
 1282   del "%SOLR_LOGS_DIR%\.writable"
 1283 ) else (
 1284   echo "ERROR: Logs directory %SOLR_LOGS_DIR% is not writable or could not be created. Exiting"
 1285   GOTO :eof
 1286 )
 1287 echo " contexts etc lib modules resources scripts solr solr-webapp " > "%TEMP%\solr-pattern.txt"
 1288 findstr /i /C:" %SOLR_LOGS_DIR% " "%TEMP%\solr-pattern.txt" 1>nul
 1289 if %ERRORLEVEL% == 0 (
 1290   echo "ERROR: Logs directory %SOLR_LOGS_DIR% is invalid. Reserved for the system. Exiting"
 1291   GOTO :eof
 1292 )
 1293 
 1294 IF NOT EXIST "%SOLR_SERVER_DIR%\tmp" (
 1295   mkdir "%SOLR_SERVER_DIR%\tmp"
 1296 )
 1297 
 1298 IF "%DEFAULT_CONFDIR%"=="" set "DEFAULT_CONFDIR=%SOLR_SERVER_DIR%\solr\configsets\_default\conf"
 1299 
 1300 IF "%FG%"=="1" (
 1301   REM run solr in the foreground
 1302   title "Solr-%SOLR_PORT%"
 1303   echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
 1304   "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
 1305     -Dlog4j.configurationFile="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
 1306     -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^
 1307     -Djetty.host=%SOLR_JETTY_HOST% -Djetty.port=%SOLR_PORT% -Djetty.home="%SOLR_SERVER_DIR%" ^
 1308     -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar %SOLR_JETTY_CONFIG% "%SOLR_JETTY_ADDL_CONFIG%"
 1309 ) ELSE (
 1310   START /B "Solr-%SOLR_PORT%" /D "%SOLR_SERVER_DIR%" ^
 1311     "%JAVA%" %SERVEROPT% %SOLR_JAVA_MEM% %START_OPTS% ^
 1312     -Dlog4j.configurationFile="%LOG4J_CONFIG%" -DSTOP.PORT=!STOP_PORT! -DSTOP.KEY=%STOP_KEY% ^
 1313     -Dsolr.log.muteconsole ^
 1314     -Dsolr.solr.home="%SOLR_HOME%" -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%" ^
 1315     -Djetty.host=%SOLR_JETTY_HOST% -Djetty.port=%SOLR_PORT% -Djetty.home="%SOLR_SERVER_DIR%" ^
 1316     -Djava.io.tmpdir="%SOLR_SERVER_DIR%\tmp" -jar start.jar %SOLR_JETTY_CONFIG% "%SOLR_JETTY_ADDL_CONFIG%" > "!SOLR_LOGS_DIR!\solr-%SOLR_PORT%-console.log"
 1317   echo %SOLR_PORT%>"%SOLR_TIP%"\bin\solr-%SOLR_PORT%.port
 1318 
 1319   REM now wait to see Solr come online ...
 1320   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^
 1321     -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1322     -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1323     org.apache.solr.util.SolrCLI status -maxWaitSecs 30 -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:%SOLR_PORT%/solr
 1324 )
 1325 
 1326 goto done
 1327 
 1328 :run_example
 1329 REM Run the requested example
 1330 
 1331 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1332   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1333   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1334   org.apache.solr.util.SolrCLI run_example -script "%SDIR%\solr.cmd" -e %EXAMPLE% -d "%SOLR_SERVER_DIR%" ^
 1335   -urlScheme !SOLR_URL_SCHEME! !PASS_TO_RUN_EXAMPLE!
 1336 
 1337 REM End of run_example
 1338 goto done
 1339 
 1340 :get_info
 1341 REM Find all Java processes, correlate with those listening on a port
 1342 REM and then try to contact via that port using the status tool
 1343 for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
 1344   set SOME_SOLR_PORT=
 1345   For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
 1346   if NOT "!SOME_SOLR_PORT!"=="" (
 1347     for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1348       IF NOT "%%k"=="0" (
 1349         if "%%j"=="%SOLR_JETTY_HOST%:!SOME_SOLR_PORT!" (
 1350           @echo.
 1351           set has_info=1
 1352           echo Found Solr process %%k running on port !SOME_SOLR_PORT!
 1353           "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1354             -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1355             -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1356             org.apache.solr.util.SolrCLI status -solr !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!SOME_SOLR_PORT!/solr
 1357           @echo.
 1358         )
 1359       )
 1360     )
 1361   )
 1362 )
 1363 if NOT "!has_info!"=="1" echo No running Solr nodes found.
 1364 set has_info=
 1365 goto done
 1366 
 1367 :parse_healthcheck_args
 1368 IF [%1]==[] goto run_healthcheck
 1369 IF "%1"=="-V" goto set_healthcheck_verbose
 1370 IF "%1"=="-c" goto set_healthcheck_collection
 1371 IF "%1"=="-collection" goto set_healthcheck_collection
 1372 IF "%1"=="-z" goto set_healthcheck_zk
 1373 IF "%1"=="-zkhost" goto set_healthcheck_zk
 1374 IF "%1"=="-zkHost" goto set_healthcheck_zk
 1375 IF "%1"=="-help" goto usage
 1376 IF "%1"=="-usage" goto usage
 1377 IF "%1"=="/?" goto usage
 1378 goto run_healthcheck
 1379 
 1380 :set_healthcheck_verbose
 1381 set HEALTHCHECK_VERBOSE="-verbose"
 1382 SHIFT
 1383 goto parse_healthcheck_args
 1384 
 1385 :set_healthcheck_collection
 1386 set HEALTHCHECK_COLLECTION=%~2
 1387 SHIFT
 1388 SHIFT
 1389 goto parse_healthcheck_args
 1390 
 1391 :set_healthcheck_zk
 1392 set ZK_HOST=%~2
 1393 SHIFT
 1394 SHIFT
 1395 goto parse_healthcheck_args
 1396 
 1397 :run_healthcheck
 1398 IF NOT DEFINED HEALTHCHECK_COLLECTION goto healthcheck_usage
 1399 IF NOT DEFINED HEALTHCHECK_VERBOSE set "HEALTHCHECK_VERBOSE="
 1400 IF NOT DEFINED HEALTHCHECK_ZK_HOST set "HEALTHCHECK_ZK_HOST=localhost:9983"
 1401 echo ZK_HOST: !ZK_HOST!
 1402 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1403   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1404   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1405   org.apache.solr.util.SolrCLI healthcheck -collection !HEALTHCHECK_COLLECTION! -zkHost !ZK_HOST! %HEALTHCHECK_VERBOSE%
 1406 goto done
 1407 
 1408 :run_assert
 1409 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1410   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1411   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1412   org.apache.solr.util.SolrCLI %* 
 1413 if errorlevel 1 (
 1414    exit /b 1
 1415 )
 1416 goto done
 1417 
 1418 :run_autoscaling
 1419 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1420   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1421   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1422   org.apache.solr.util.SolrCLI %* 
 1423 goto done:
 1424 
 1425 :run_export
 1426 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1427   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1428   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1429   org.apache.solr.util.SolrCLI %*
 1430 goto done:
 1431 
 1432 :run_package
 1433 REM TODO: Compute the running Solr URL and populate it as a parameter (as has been done for the shell script)
 1434 REM Without that, users will have to supply -solrUrl parameter in every request. Life can be so hard for Windows users!
 1435 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1436   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1437   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1438   org.apache.solr.util.SolrCLI %*
 1439 goto done:
 1440 
 1441 :parse_config_args
 1442 IF [%1]==[] goto run_config
 1443 IF "%1"=="-z" goto set_config_zk
 1444 IF "%1"=="-zkhost" goto set_config_zk
 1445 IF "%1"=="-zkHost" goto set_config_zk
 1446 IF "%1"=="-s" goto set_config_url_scheme
 1447 IF "%1"=="-scheme" goto set_config_url_scheme
 1448 set "CONFIG_ARGS=!CONFIG_ARGS! %1"
 1449 SHIFT
 1450 goto parse_config_args
 1451 
 1452 :set_config_zk
 1453 set ZK_HOST=%~2
 1454 SHIFT
 1455 SHIFT
 1456 goto parse_config_args
 1457 
 1458 :set_config_url_scheme
 1459 set SOLR_URL_SCHEME=%~2
 1460 SHIFT
 1461 SHIFT
 1462 goto parse_config_args
 1463 
 1464 :run_config
 1465 IF NOT "!ZK_HOST!"=="" SET "CONFIG_ARGS=!CONFIG_ARGS! -z !ZK_HOST!"
 1466 IF NOT "!SOLR_URL_SCHEME!"=="" SET "CONFIG_ARGS=!CONFIG_ARGS! -scheme !SOLR_URL_SCHEME!"
 1467 
 1468 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1469   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1470   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1471   org.apache.solr.util.SolrCLI config !CONFIG_ARGS!
 1472 if errorlevel 1 (
 1473    exit /b 1
 1474 )
 1475 goto done
 1476 
 1477 :get_version
 1478 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1479   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1480   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1481   org.apache.solr.util.SolrCLI version
 1482 goto done
 1483 
 1484 :run_utils
 1485 set "TOOL_CMD=%~1"
 1486 set q="-q"
 1487 IF "%verbose%"=="1"  set q=""
 1488 "%JAVA%" %SOLR_SSL_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1489   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1490   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1491   org.apache.solr.util.SolrCLI utils -s "%DEFAULT_SERVER_DIR%" -l "%SOLR_LOGS_DIR%" %q:"=% %TOOL_CMD%
 1492 if errorlevel 1 (
 1493    exit /b 1
 1494 )
 1495 goto done
 1496 
 1497 :parse_create_args
 1498 IF [%1]==[] goto run_create
 1499 IF "%1"=="-V" goto set_create_verbose
 1500 IF "%1"=="-c" goto set_create_name
 1501 IF "%1"=="-core" goto set_create_name
 1502 IF "%1"=="-collection" goto set_create_name
 1503 IF "%1"=="-d" goto set_create_confdir
 1504 IF "%1"=="-confdir" goto set_create_confdir
 1505 IF "%1"=="-n" goto set_create_confname
 1506 IF "%1"=="-confname" goto set_create_confname
 1507 IF "%1"=="-s" goto set_create_shards
 1508 IF "%1"=="-shards" goto set_create_shards
 1509 IF "%1"=="-rf" goto set_create_rf
 1510 IF "%1"=="-replicationFactor" goto set_create_rf
 1511 IF "%1"=="-p" goto set_create_port
 1512 IF "%1"=="-port" goto set_create_port
 1513 IF "%1"=="-help" goto usage
 1514 IF "%1"=="-usage" goto usage
 1515 IF "%1"=="/?" goto usage
 1516 goto run_create
 1517 
 1518 
 1519 :set_create_verbose
 1520 set CREATE_VERBOSE="-verbose"
 1521 SHIFT
 1522 goto parse_create_args
 1523 
 1524 :set_create_name
 1525 set CREATE_NAME=%~2
 1526 SHIFT
 1527 SHIFT
 1528 goto parse_create_args
 1529 
 1530 :set_create_confdir
 1531 set CREATE_CONFDIR=%~2
 1532 SHIFT
 1533 SHIFT
 1534 goto parse_create_args
 1535 
 1536 :set_create_confname
 1537 set CREATE_CONFNAME=%~2
 1538 SHIFT
 1539 SHIFT
 1540 goto parse_create_args
 1541 
 1542 :set_create_port
 1543 set CREATE_PORT=%~2
 1544 SHIFT
 1545 SHIFT
 1546 goto parse_create_args
 1547 
 1548 :set_create_shards
 1549 set CREATE_NUM_SHARDS=%~2
 1550 SHIFT
 1551 SHIFT
 1552 goto parse_create_args
 1553 
 1554 :set_create_rf
 1555 set CREATE_REPFACT=%~2
 1556 SHIFT
 1557 SHIFT
 1558 goto parse_create_args
 1559 
 1560 :run_create
 1561 IF "!CREATE_NAME!"=="" (
 1562   set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%"
 1563   goto invalid_cmd_line
 1564 )
 1565 IF NOT DEFINED CREATE_VERBOSE set "CREATE_VERBOSE="
 1566 IF "!CREATE_CONFDIR!"=="" set CREATE_CONFDIR=_default
 1567 IF "!CREATE_NUM_SHARDS!"=="" set CREATE_NUM_SHARDS=1
 1568 IF "!CREATE_REPFACT!"=="" set CREATE_REPFACT=1
 1569 IF "!CREATE_CONFNAME!"=="" set CREATE_CONFNAME=!CREATE_NAME!
 1570 
 1571 REM Find a port that Solr is running on
 1572 if "!CREATE_PORT!"=="" (
 1573   for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
 1574     set SOME_SOLR_PORT=
 1575     For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
 1576     if NOT "!SOME_SOLR_PORT!"=="" (
 1577       for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1578         IF NOT "%%k"=="0" set CREATE_PORT=!SOME_SOLR_PORT!
 1579       )
 1580     )
 1581   )
 1582 )
 1583 if "!CREATE_PORT!"=="" (
 1584   set "SCRIPT_ERROR=Could not find a running Solr instance on this host! Please use the -p option to specify the port."
 1585   goto err
 1586 )
 1587 
 1588 if "!CREATE_CONFDIR!"=="_default" (
 1589   echo WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
 1590   echo          To turn off: bin\solr config -c !CREATE_NAME! -p !CREATE_PORT! -action set-user-property -property update.autoCreateFields -value false
 1591 )
 1592 
 1593 if "%SCRIPT_CMD%"=="create_core" (
 1594   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1595     -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1596     -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1597     org.apache.solr.util.SolrCLI create_core -name !CREATE_NAME! -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr ^
 1598     -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" %CREATE_VERBOSE%
 1599 ) else (
 1600   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" -Dsolr.default.confdir="%DEFAULT_CONFDIR%"^
 1601     -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1602     -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1603     org.apache.solr.util.SolrCLI create -name !CREATE_NAME! -shards !CREATE_NUM_SHARDS! -replicationFactor !CREATE_REPFACT! ^
 1604     -confname !CREATE_CONFNAME! -confdir !CREATE_CONFDIR! -configsetsDir "%SOLR_TIP%\server\solr\configsets" ^
 1605     -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!CREATE_PORT!/solr %CREATE_VERBOSE%
 1606 )
 1607 
 1608 goto done
 1609 
 1610 :parse_delete_args
 1611 IF [%1]==[] goto run_delete
 1612 IF "%1"=="-V" goto set_delete_verbose
 1613 IF "%1"=="-c" goto set_delete_name
 1614 IF "%1"=="-core" goto set_delete_name
 1615 IF "%1"=="-collection" goto set_delete_name
 1616 IF "%1"=="-p" goto set_delete_port
 1617 IF "%1"=="-port" goto set_delete_port
 1618 IF "%1"=="-deleteConfig" goto set_delete_config
 1619 IF "%1"=="-help" goto usage
 1620 IF "%1"=="-usage" goto usage
 1621 IF "%1"=="/?" goto usage
 1622 goto run_delete
 1623 
 1624 :set_delete_verbose
 1625 set DELETE_VERBOSE="-verbose"
 1626 SHIFT
 1627 goto parse_delete_args
 1628 
 1629 :set_delete_name
 1630 set DELETE_NAME=%~2
 1631 SHIFT
 1632 SHIFT
 1633 goto parse_delete_args
 1634 
 1635 :set_delete_port
 1636 set DELETE_PORT=%~2
 1637 SHIFT
 1638 SHIFT
 1639 goto parse_delete_args
 1640 
 1641 :set_delete_config
 1642 set DELETE_CONFIG=%~2
 1643 SHIFT
 1644 SHIFT
 1645 goto parse_delete_args
 1646 
 1647 :run_delete
 1648 IF NOT DEFINED DELETE_VERBOSE set "DELETE_VERBOSE="
 1649 IF "!DELETE_NAME!"=="" (
 1650   set "SCRIPT_ERROR=Name (-c) is a required parameter for %SCRIPT_CMD%"
 1651   goto invalid_cmd_line
 1652 )
 1653 
 1654 REM Find a port that Solr is running on
 1655 if "!DELETE_PORT!"=="" (
 1656   for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
 1657     set SOME_SOLR_PORT=
 1658     For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
 1659     if NOT "!SOME_SOLR_PORT!"=="" (
 1660       for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1661         IF NOT "%%k"=="0" set DELETE_PORT=!SOME_SOLR_PORT!
 1662       )
 1663     )
 1664   )
 1665 )
 1666 if "!DELETE_PORT!"=="" (
 1667   set "SCRIPT_ERROR=Could not find a running Solr instance on this host! Please use the -p option to specify the port."
 1668   goto err
 1669 )
 1670 
 1671 if "!DELETE_CONFIG!"=="" (
 1672   set DELETE_CONFIG=true
 1673 )
 1674 
 1675 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1676 -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1677 -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1678 org.apache.solr.util.SolrCLI delete -name !DELETE_NAME! -deleteConfig !DELETE_CONFIG! ^
 1679 -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!DELETE_PORT!/solr %DELETE_VERBOSE%
 1680 
 1681 goto done
 1682 
 1683 REM Clumsy to do the state machine thing for -d and -n, but that's required for back-compat
 1684 :parse_zk_args
 1685 IF "%1"=="-upconfig" (
 1686   goto set_zk_op
 1687 ) ELSE IF "%1"=="-V" (
 1688   goto set_zk_verbose
 1689 ) ELSE IF "%1"=="upconfig" (
 1690   goto set_zk_op
 1691 ) ELSE IF "%1"=="-downconfig" (
 1692   goto set_zk_op
 1693 ) ELSE IF "%1"=="downconfig" (
 1694   goto set_zk_op
 1695 ) ELSE IF "%1"=="cp" (
 1696   goto set_zk_op
 1697 ) ELSE IF "%1"=="mv" (
 1698   goto set_zk_op
 1699 ) ELSE IF "%1"=="rm" (
 1700   goto set_zk_op
 1701 ) ELSE IF "%1"=="ls" (
 1702   goto set_zk_op
 1703 ) ELSE IF "%1"=="mkroot" (
 1704   goto set_zk_op
 1705 ) ELSE IF "%1"=="-n" (
 1706   goto set_config_name
 1707 ) ELSE IF "%1"=="-r" (
 1708   goto set_zk_recurse
 1709 ) ELSE IF "%1"=="-configname" (
 1710   goto set_config_name
 1711 ) ELSE IF "%1"=="-d" (
 1712   goto set_configdir
 1713 ) ELSE IF "%1"=="-confdir" (
 1714   goto set_configdir
 1715 ) ELSE IF "%1"=="-z" (
 1716   goto set_config_zk
 1717 ) ELSE IF "%1"=="/?" (
 1718   goto zk_usage
 1719 ) ELSE IF "%1"=="-h" (
 1720   goto zk_usage
 1721 ) ELSE IF "%1"=="-help" (
 1722   goto zk_usage
 1723 ) ELSE IF "!ZK_SRC!"=="" (
 1724   if not "%~1"=="" (
 1725     goto set_zk_src
 1726   )
 1727 ) ELSE IF "!ZK_DST!"=="" (
 1728   IF "%ZK_OP%"=="cp" (
 1729     goto set_zk_dst
 1730   )
 1731   IF "%ZK_OP%"=="mv" (
 1732     goto set_zk_dst
 1733   )
 1734   set ZK_DST="_"
 1735 ) ELSE IF NOT "%1"=="" (
 1736   set ERROR_MSG="Unrecognized or misplaced zk argument %1%"
 1737   goto zk_short_usage
 1738 )
 1739 goto run_zk
 1740 
 1741 :set_zk_op
 1742 set ZK_OP=%~1
 1743 SHIFT
 1744 goto parse_zk_args
 1745 
 1746 :set_zk_verbose
 1747 set ZK_VERBOSE="-verbose"
 1748 SHIFT
 1749 goto parse_zk_args
 1750 
 1751 :set_config_name
 1752 set CONFIGSET_NAME=%~2
 1753 SHIFT
 1754 SHIFT
 1755 goto parse_zk_args
 1756 
 1757 :set_configdir
 1758 set CONFIGSET_DIR=%~2
 1759 SHIFT
 1760 SHIFT
 1761 goto parse_zk_args
 1762 
 1763 :set_config_zk
 1764 set ZK_HOST=%~2
 1765 SHIFT
 1766 SHIFT
 1767 goto parse_zk_args
 1768 
 1769 :set_zk_src
 1770 set ZK_SRC=%~1
 1771 SHIFT
 1772 goto parse_zk_args
 1773 
 1774 :set_zk_dst
 1775 set ZK_DST=%~1
 1776 SHIFT
 1777 goto parse_zk_args
 1778 
 1779 :set_zk_recurse
 1780 set ZK_RECURSE="true"
 1781 SHIFT
 1782 goto parse_zk_args
 1783 
 1784 :run_zk
 1785 IF "!ZK_OP!"=="" (
 1786   set "ERROR_MSG=Invalid command specified for zk sub-command"
 1787   goto zk_short_usage
 1788 )
 1789 
 1790 IF "!ZK_HOST!"=="" (
 1791   set "ERROR_MSG=Must specify -z zkHost"
 1792   goto zk_short_usage
 1793 )
 1794 
 1795 IF "!ZK_OP!"=="-upconfig" (
 1796   set ZK_OP="upconfig"
 1797 )
 1798 IF "!ZK_OP!"=="-downconfig" (
 1799   set ZK_OP="downconfig"
 1800 )
 1801 
 1802 IF "!ZK_OP!"=="upconfig" (
 1803   IF "!CONFIGSET_NAME!"=="" (
 1804     set ERROR_MSG="-n option must be set for upconfig"
 1805     goto zk_short_usage
 1806   )
 1807   IF "!CONFIGSET_DIR!"=="" (
 1808     set ERROR_MSG="The -d option must be set for upconfig."
 1809     goto zk_short_usage
 1810   )
 1811   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1812   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1813   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1814   org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%^
 1815   -configsetsDir "%SOLR_TIP%/server/solr/configsets"
 1816 ) ELSE IF "!ZK_OP!"=="downconfig" (
 1817   IF "!CONFIGSET_NAME!"=="" (
 1818     set ERROR_MSG="-n option must be set for downconfig"
 1819     goto zk_short_usage
 1820   )
 1821   IF "!CONFIGSET_DIR!"=="" (
 1822     set ERROR_MSG="The -d option must be set for downconfig."
 1823     goto zk_short_usage
 1824   )
 1825   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1826   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1827   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1828   org.apache.solr.util.SolrCLI !ZK_OP! -confname !CONFIGSET_NAME! -confdir !CONFIGSET_DIR! -zkHost !ZK_HOST! %ZK_VERBOSE%
 1829 ) ELSE IF "!ZK_OP!"=="cp" (
 1830   IF "%ZK_SRC%"=="" (
 1831     set ERROR_MSG="<src> must be specified for 'cp' command"
 1832     goto zk_short_usage
 1833   )
 1834   IF "%ZK_DST%"=="" (
 1835     set ERROR_MSG=<dest> must be specified for 'cp' command"
 1836     goto zk_short_usage
 1837   )
 1838   IF NOT "!ZK_SRC:~0,3!"=="zk:" (
 1839     IF NOT "!%ZK_DST:~0,3!"=="zk:" (
 1840       set ERROR_MSG="At least one of src or dst must be prefixed by 'zk:'"
 1841       goto zk_short_usage
 1842   )
 1843   )
 1844   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1845   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1846   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1847   org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! -recurse !ZK_RECURSE! %ZK_VERBOSE%
 1848 ) ELSE IF "!ZK_OP!"=="mv" (
 1849   IF "%ZK_SRC%"=="" (
 1850     set ERROR_MSG="<src> must be specified for 'mv' command"
 1851     goto zk_short_usage
 1852   )
 1853   IF "%ZK_DST%"=="" (
 1854     set ERROR_MSG="<dest> must be specified for 'mv' command"
 1855     goto zk_short_usage
 1856   )
 1857   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1858   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1859   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1860   org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -src !ZK_SRC! -dst !ZK_DST! %ZK_VERBOSE%
 1861 ) ELSE IF "!ZK_OP!"=="rm" (
 1862   IF "%ZK_SRC"=="" (
 1863     set ERROR_MSG="Zookeeper path to remove must be specified when using the 'rm' command"
 1864     goto zk_short_usage
 1865   )
 1866   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1867   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1868   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1869   org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
 1870 ) ELSE IF "!ZK_OP!"=="ls" (
 1871   IF "%ZK_SRC"=="" (
 1872     set ERROR_MSG="Zookeeper path to remove must be specified when using the 'ls' command"
 1873     goto zk_short_usage
 1874   )
 1875   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1876   -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1877   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1878   org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! -recurse !ZK_RECURSE! %ZK_VERBOSE%
 1879 ) ELSE IF "!ZK_OP!"=="mkroot" (
 1880   IF "%ZK_SRC"=="" (
 1881     set ERROR_MSG="Zookeeper path to create must be specified when using the 'mkroot' command"
 1882     goto zk_short_usage
 1883   )
 1884   "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1885   -Dlog4j.configurationFile="file:///%SOLR_SERVER_DIR%\resources\log4j2-console.xml" ^
 1886   -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1887   org.apache.solr.util.SolrCLI !ZK_OP! -zkHost !ZK_HOST! -path !ZK_SRC! %ZK_VERBOSE%
 1888 ) ELSE (
 1889   set ERROR_MSG="Unknown zk option !ZK_OP!"
 1890   goto zk_short_usage
 1891 )
 1892 goto done
 1893 
 1894  
 1895 :run_auth
 1896 IF "%1"=="-help" goto usage
 1897 IF "%1"=="-usage" goto usage
 1898 
 1899 REM Options parsing.
 1900 REM Note: With the following technique of parsing, it is not possible
 1901 REM       to have an option without a value.
 1902 set "AUTH_PARAMS=%1"
 1903 set "option="
 1904 for %%a in (%*) do (
 1905    if not defined option (
 1906       set arg=%%a
 1907       if "!arg:~0,1!" equ "-" set "option=!arg!"
 1908    ) else (
 1909       set "option!option!=%%a"
 1910       if "!option!" equ "-d" set "SOLR_SERVER_DIR=%%a"
 1911       if "!option!" equ "-s" set "SOLR_HOME=%%a"
 1912       if not "!option!" equ "-s" if not "!option!" equ "-d" (
 1913         set "AUTH_PARAMS=!AUTH_PARAMS! !option! %%a"
 1914       )
 1915       set "option="
 1916    )
 1917 )
 1918 IF "%SOLR_SERVER_DIR%"=="" set "SOLR_SERVER_DIR=%DEFAULT_SERVER_DIR%"
 1919 IF NOT EXIST "%SOLR_SERVER_DIR%" (
 1920   set "SCRIPT_ERROR=Solr server directory %SOLR_SERVER_DIR% not found!"
 1921   goto err
 1922 )
 1923 IF "%SOLR_HOME%"=="" set "SOLR_HOME=%SOLR_SERVER_DIR%\solr"
 1924 IF EXIST "%cd%\%SOLR_HOME%" set "SOLR_HOME=%cd%\%SOLR_HOME%"
 1925 IF NOT EXIST "%SOLR_HOME%\" (
 1926   IF EXIST "%SOLR_SERVER_DIR%\%SOLR_HOME%" (
 1927     set "SOLR_HOME=%SOLR_SERVER_DIR%\%SOLR_HOME%"
 1928   ) ELSE (
 1929     set "SCRIPT_ERROR=Solr home directory %SOLR_HOME% not found!"
 1930     goto err
 1931   )
 1932 )
 1933 
 1934 if "!AUTH_PORT!"=="" (
 1935   for /f "usebackq" %%i in (`dir /b "%SOLR_TIP%\bin" ^| findstr /i "^solr-.*\.port$"`) do (
 1936     set SOME_SOLR_PORT=
 1937     For /F "Delims=" %%J In ('type "%SOLR_TIP%\bin\%%i"') do set SOME_SOLR_PORT=%%~J
 1938     if NOT "!SOME_SOLR_PORT!"=="" (
 1939       for /f "tokens=2,5" %%j in ('netstat -aon ^| find "TCP " ^| find ":0 " ^| find ":!SOME_SOLR_PORT! "') do (
 1940         IF NOT "%%k"=="0" set AUTH_PORT=!SOME_SOLR_PORT!
 1941       )
 1942     )
 1943   )
 1944 )
 1945 "%JAVA%" %SOLR_SSL_OPTS% %AUTHC_OPTS% %SOLR_ZK_CREDS_AND_ACLS% -Dsolr.install.dir="%SOLR_TIP%" ^
 1946     -Dlog4j.configurationFile="file:///%DEFAULT_SERVER_DIR%\resources\log4j2-console.xml" ^
 1947     -classpath "%DEFAULT_SERVER_DIR%\solr-webapp\webapp\WEB-INF\lib\*;%DEFAULT_SERVER_DIR%\lib\ext\*" ^
 1948     org.apache.solr.util.SolrCLI auth %AUTH_PARAMS% -solrIncludeFile "%SOLR_INCLUDE%" -authConfDir "%SOLR_HOME%" ^
 1949     -solrUrl !SOLR_URL_SCHEME!://%SOLR_TOOL_HOST%:!AUTH_PORT!/solr
 1950 goto done
 1951 
 1952 
 1953 :invalid_cmd_line
 1954 @echo.
 1955 IF "!SCRIPT_ERROR!"=="" (
 1956   @echo Invalid command-line option: %1
 1957 ) ELSE (
 1958   @echo ERROR: !SCRIPT_ERROR!
 1959 )
 1960 @echo.
 1961 IF "%FIRST_ARG%"=="start" (
 1962   goto start_usage
 1963 ) ELSE IF "%FIRST_ARG:~0,1%" == "-" (
 1964   goto start_usage
 1965 ) ELSE IF "%FIRST_ARG%"=="restart" (
 1966   goto start_usage
 1967 ) ELSE IF "%FIRST_ARG%"=="stop" (
 1968   goto stop_usage
 1969 ) ELSE IF "%FIRST_ARG%"=="healthcheck" (
 1970   goto healthcheck_usage
 1971 ) ELSE IF "%FIRST_ARG%"=="create" (
 1972   goto create_usage
 1973 ) ELSE IF "%FIRST_ARG%"=="create_core" (
 1974   goto create_core_usage
 1975 ) ELSE IF "%FIRST_ARG%"=="create_collection" (
 1976   goto create_collection_usage
 1977 ) ELSE IF "%FIRST_ARG%"=="zk" (
 1978   goto zk_short_usage
 1979 ) ELSE IF "%FIRST_ARG%"=="auth" (
 1980   goto auth_usage
 1981 ) ELSE IF "%FIRST_ARG%"=="status" (
 1982   goto status_usage
 1983 ) ELSE (
 1984   goto script_usage
 1985 )
 1986 
 1987 :need_java_home
 1988 @echo Please set the JAVA_HOME environment variable to the path where you installed Java 1.8+
 1989 goto done
 1990 
 1991 :need_java_vers
 1992 @echo Java 1.8 or later is required to run Solr.
 1993 goto done
 1994 
 1995 :err
 1996 @echo.
 1997 @echo ERROR: !SCRIPT_ERROR!
 1998 @echo.
 1999 exit /b 1
 2000 
 2001 :done
 2002 ENDLOCAL
 2003 exit /b 0
 2004 
 2005 REM Tests what Java we have and sets some global variables
 2006 :resolve_java_info
 2007 
 2008 CALL :resolve_java_vendor
 2009 
 2010 set JAVA_MAJOR_VERSION=0
 2011 set JAVA_VERSION_INFO=
 2012 set JAVA_BUILD=0
 2013 
 2014 FOR /f "usebackq tokens=3" %%a IN (`^""%JAVA%" -version 2^>^&1 ^| findstr "version"^"`) do (
 2015   set JAVA_VERSION_INFO=%%a
 2016   REM Remove surrounding quotes
 2017   set JAVA_VERSION_INFO=!JAVA_VERSION_INFO:"=!
 2018 
 2019   REM Extract the major Java version, e.g. 7, 8, 9, 10 ...
 2020   for /f "tokens=1,2 delims=._-" %%a in ("!JAVA_VERSION_INFO!") do (
 2021     if %%a GEQ 9 (
 2022       set JAVA_MAJOR_VERSION=%%a
 2023     ) else (
 2024       set JAVA_MAJOR_VERSION=%%b
 2025     )
 2026   )
 2027 
 2028   REM Don't look for "_{build}" if we're on IBM J9.
 2029   if NOT "%JAVA_VENDOR%" == "IBM J9" (
 2030     for /f "delims=_ tokens=2" %%a in ("!JAVA_VERSION_INFO!") do (
 2031       set /a JAVA_BUILD=%%a
 2032     )
 2033   )
 2034 )
 2035 GOTO :eof
 2036 
 2037 REM Set which JVM vendor we have
 2038 :resolve_java_vendor
 2039 "%JAVA%" -version 2>&1 | findstr /i "IBM J9" > nul
 2040 if %ERRORLEVEL% == 1 ( set "JAVA_VENDOR=Oracle" ) else ( set "JAVA_VENDOR=IBM J9" )
 2041 
 2042 set JAVA_VENDOR_OUT=
 2043 GOTO :eof
 2044 
 2045 REM Safe echo which does not mess with () in strings
 2046 :safe_echo
 2047 set "eout=%1"
 2048 set eout=%eout:"=%
 2049 echo !eout!
 2050 GOTO :eof