[24446] | 1 | @echo off
|
---|
| 2 | pushd "%CD%"
|
---|
| 3 | CD /D "%~dp0"
|
---|
[26510] | 4 |
|
---|
[24446] | 5 | set extdesc=the Solr Extension
|
---|
[29749] | 6 | if "%GSDL3SRCHOME%" == "" echo Run the toplevel gs3-setup.bat before calling this script& goto End
|
---|
[24446] | 7 |
|
---|
[29749] | 8 | rem IF USING TOMCAT SERVER FOR SOLR
|
---|
| 9 | :: If using tomcat, read the tomcat host and port from the toplevel GS3 build.properties
|
---|
| 10 | :: http://en.kioskea.net/faq/1757-how-to-read-a-file-line-by-line
|
---|
| 11 | :: The following reads build.properties line by line, tokenizing it around the = sign, then
|
---|
| 12 | :: sets the SOLR_PORT and SOLR_HOST to the values of tomcat.port and tomcat.host properties
|
---|
| 13 |
|
---|
[32432] | 14 | set SOLR_PORT=8383
|
---|
| 15 | set SOLR_HOST=127.0.0.1
|
---|
[30574] | 16 |
|
---|
| 17 | setlocal enabledelayedexpansion
|
---|
| 18 | set FOUNDPROPS=
|
---|
[32432] | 19 | :: The Solr servlet should only be locally accessible, thus restricting the protocol to http as
|
---|
| 20 | :: https certificates can't be issued for localhost/127.0.0.1 (https://letsencrypt.org/docs/certificates-for-localhost/)
|
---|
| 21 | :: This means we use the properties localhost.server.http (defaults to 127.0.0.1) and localhost.port.http
|
---|
| 22 | :: to construct the solr servlet url, rather than properties tomcat.server and tomcat.port.https
|
---|
[29749] | 23 | :: Loosely based on
|
---|
| 24 | :: http://stackoverflow.com/questions/7708681/how-to-read-from-a-properties-file-using-batch-script
|
---|
[30591] | 25 | :: for with usebackq option allows spaces in filepath to be protected with double quotes
|
---|
| 26 | :: (backquotes will be used for executing the commands)
|
---|
[31755] | 27 | :: See also https://stackoverflow.com/questions/5553040/batch-file-for-loop-with-spaces-in-dir-name
|
---|
| 28 | :: for alternative suggestions useful in other instances
|
---|
[30591] | 29 | FOR /F "usebackq tokens=1,2 delims==" %%G IN ("%GSDL3SRCHOME%\build.properties") DO (
|
---|
[32432] | 30 | if "%%G"=="localhost.server.http" set SOLR_HOST=%%H& set FOUNDPROPS=!FOUNDPROPS!found
|
---|
| 31 | if "%%G"=="localhost.port.http" set SOLR_PORT=%%H& set FOUNDPROPS=!FOUNDPROPS!found
|
---|
[30574] | 32 | :: break out of the loop as soon as both properties are found
|
---|
| 33 | if "!FOUNDPROPS!" == "foundfound" goto foundall
|
---|
[29749] | 34 | )
|
---|
[30574] | 35 |
|
---|
| 36 | :foundall
|
---|
[30783] | 37 | endlocal& set SOLR_HOST=%SOLR_HOST%& set SOLR_PORT=%SOLR_PORT%
|
---|
[35314] | 38 | echo - Solr API accessed internally via: http://%SOLR_HOST%:%SOLR_PORT%/solr/
|
---|
[29749] | 39 |
|
---|
[24446] | 40 | if "%OS%" == "Windows_NT" goto WinNT
|
---|
| 41 | if "%OS%" == "" goto Win95
|
---|
| 42 | if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
|
---|
| 43 | if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
|
---|
| 44 | if "%GSDLLANG%" == "fr" echo Echc de l'installation - votre variable PATH n'a pas t ajuste
|
---|
| 45 | if "%GSDLLANG%" == "ru" echo áâ ®¢ª ¥ 〠« áì - ¥ ¡ë« ãáâ ®¢«¥
|
---|
| 46 | goto End
|
---|
| 47 |
|
---|
| 48 | :WinNT
|
---|
| 49 | set GEXT_SOLR=%CD%
|
---|
| 50 | set PATH=%GEXT_SOLR%\bin\script;%PATH%
|
---|
| 51 | set PATH=%GEXT_SOLR%\lib;%PATH%
|
---|
| 52 | set GS_CP_SET=yes
|
---|
| 53 | goto Success
|
---|
| 54 |
|
---|
| 55 | :Win95
|
---|
| 56 | if "%1" == "SetEnv" goto Win95Env
|
---|
| 57 | REM We'll invoke a second copy of the command processor to make
|
---|
| 58 | REM sure there's enough environment space
|
---|
| 59 | COMMAND /E:2048 /K %0 SetEnv
|
---|
| 60 | goto End
|
---|
| 61 |
|
---|
| 62 | :Win95Env
|
---|
| 63 | set GEXT_SOLR=%CD%
|
---|
| 64 | set PATH="%GEXT_SOLR%\bin\script";"%PATH%"
|
---|
| 65 | set PATH="%GEXT_SOLR%\lib";"%PATH%"
|
---|
| 66 | set GS_CP_SET=yes
|
---|
| 67 | goto Success
|
---|
| 68 |
|
---|
| 69 | :Success
|
---|
| 70 |
|
---|
| 71 | set fulldir=%~dp0
|
---|
| 72 |
|
---|
| 73 | :: strip off everything up to (and including) ext dir
|
---|
| 74 | set extdir=%fulldir:*ext\=%
|
---|
| 75 |
|
---|
| 76 | :: remove trailing slash
|
---|
| 77 | set extdir=%extdir:\=%
|
---|
| 78 |
|
---|
| 79 | setlocal enabledelayedexpansion
|
---|
[24485] | 80 | if "x%GSDL3EXTS%" == "x" (
|
---|
| 81 | set GSDL3EXTS=!extdir!
|
---|
[24446] | 82 | ) else (
|
---|
[24485] | 83 | set GSDL3EXTS=!GSDL3EXTS!:!extdir!
|
---|
[24446] | 84 | )
|
---|
[24485] | 85 | endlocal & set GSDL3EXTS=%GSDL3EXTS%
|
---|
[24446] | 86 |
|
---|
| 87 | :: Back to delayed expansion to avoid problems with environment
|
---|
| 88 | :: variables with brackets in them, such as "Program Files (x86)"
|
---|
| 89 |
|
---|
[35650] | 90 | echo +Your environment is now setup for %extdesc%
|
---|
[24446] | 91 |
|
---|
| 92 | :End
|
---|
| 93 |
|
---|
[35314] | 94 | popd
|
---|