source: gs3-extensions/solr/trunk/src/gs3-setup.bat@ 30591

Last change on this file since 30591 was 30591, checked in by ak19, 8 years ago

Correct way of allowing spaces in filepath when using a batch for loop. Fix to revision 30400 that had to be undone in revision 30532.

File size: 3.2 KB
RevLine 
[24446]1@echo off
2pushd "%CD%"
3CD /D "%~dp0"
[26510]4
[24446]5set extdesc=the Solr Extension
[29749]6if "%GSDL3SRCHOME%" == "" echo Run the toplevel gs3-setup.bat before calling this script& goto End
[24446]7
[29749]8rem 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
14set SOLR_PORT=8983
15set SOLR_HOST=localhost
[30574]16
17setlocal enabledelayedexpansion
18set FOUNDPROPS=
[29749]19:: Loosely based on
20:: http://stackoverflow.com/questions/7708681/how-to-read-from-a-properties-file-using-batch-script
[30591]21:: for with usebackq option allows spaces in filepath to be protected with double quotes
22:: (backquotes will be used for executing the commands)
23FOR /F "usebackq tokens=1,2 delims==" %%G IN ("%GSDL3SRCHOME%\build.properties") DO (
[30574]24 if "%%G"=="tomcat.server" set SOLR_HOST=%%H& set FOUNDPROPS=!FOUNDPROPS!found
25 if "%%G"=="tomcat.port" set SOLR_PORT=%%H& set FOUNDPROPS=!FOUNDPROPS!found
26 :: break out of the loop as soon as both properties are found
27 if "!FOUNDPROPS!" == "foundfound" goto foundall
[29749]28)
[30574]29endlocal
30
31:foundall
[29749]32echo Tomcat host: %SOLR_HOST%
33echo Tomcat port: %SOLR_PORT%
34
35
36rem IF USING JETTY SERVER FOR SOLR
[24485]37:: The port Jetty runs on:
38set SOLR_JETTY_PORT=8983
39
40:: The port Jetty listens on for a "stop" command
41set JETTY_STOP_PORT=8079
42
[24446]43if "%OS%" == "Windows_NT" goto WinNT
44if "%OS%" == "" goto Win95
45if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
46if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
47if "%GSDLLANG%" == "fr" echo Ech‚c de l'installation - votre variable PATH n'a pas ‚t‚ ajust‚e
48if "%GSDLLANG%" == "ru" echo “áâ ­®¢ª  ­¥ ã€ « áì - “’œ ­¥ ¡ë« ãáâ ­®¢«¥­
49goto End
50
51:WinNT
52set GEXT_SOLR=%CD%
53set PATH=%GEXT_SOLR%\bin\script;%PATH%
54set PATH=%GEXT_SOLR%\lib;%PATH%
55set GS_CP_SET=yes
56goto Success
57
58:Win95
59if "%1" == "SetEnv" goto Win95Env
60REM We'll invoke a second copy of the command processor to make
61REM sure there's enough environment space
62COMMAND /E:2048 /K %0 SetEnv
63goto End
64
65:Win95Env
66set GEXT_SOLR=%CD%
67set PATH="%GEXT_SOLR%\bin\script";"%PATH%"
68set PATH="%GEXT_SOLR%\lib";"%PATH%"
69set GS_CP_SET=yes
70goto Success
71
72:Success
73
74set fulldir=%~dp0
75
76:: strip off everything up to (and including) ext dir
77set extdir=%fulldir:*ext\=%
78
79:: remove trailing slash
80set extdir=%extdir:\=%
81
82setlocal enabledelayedexpansion
[24485]83if "x%GSDL3EXTS%" == "x" (
84 set GSDL3EXTS=!extdir!
[24446]85) else (
[24485]86 set GSDL3EXTS=!GSDL3EXTS!:!extdir!
[24446]87)
[24485]88endlocal & set GSDL3EXTS=%GSDL3EXTS%
[24446]89
90echo +Your environment is now setup for %extdesc%
91
92:: Back to delayed expansion to avoid problems with environment
93:: variables with brackets in them, such as "Program Files (x86)"
94
[29749]95::echo ++Solr/Jetty server will run on port %SOLR_JETTY_PORT% (+ port %JETTY_STOP_PORT% for shutdown command)
96echo ++Solr will run off the tomcat server on port %SOLR_PORT%
[24485]97echo --These port values can be changed by editing:
98echo -- %0
[24446]99
[24485]100
101
[24446]102:End
103
104popd
Note: See TracBrowser for help on using the repository browser.