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

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

Fix for GSDL3EXTS and SOLR_PORT no remaining set AFTER script finishes executing.

File size: 3.3 KB
Line 
1@echo off
2pushd "%CD%"
3CD /D "%~dp0"
4
5set extdesc=the Solr Extension
6if "%GSDL3SRCHOME%" == "" echo Run the toplevel gs3-setup.bat before calling this script& goto End
7
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
16
17setlocal enabledelayedexpansion
18set FOUNDPROPS=
19:: Loosely based on
20:: http://stackoverflow.com/questions/7708681/how-to-read-from-a-properties-file-using-batch-script
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 (
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
28)
29
30:foundall
31endlocal& set SOLR_HOST=%SOLR_HOST%& set SOLR_PORT=%SOLR_PORT%
32echo Tomcat host: %SOLR_HOST%
33echo Tomcat port: %SOLR_PORT%
34
35
36rem IF USING JETTY SERVER FOR SOLR
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
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
83if "x%GSDL3EXTS%" == "x" (
84 set GSDL3EXTS=!extdir!
85) else (
86 set GSDL3EXTS=!GSDL3EXTS!:!extdir!
87)
88endlocal & set GSDL3EXTS=%GSDL3EXTS%
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
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%
97echo --These port values can be changed by editing:
98echo -- %0
99
100
101
102:End
103
104popd
Note: See TracBrowser for help on using the repository browser.