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

Last change on this file was 32432, checked in by ak19, 3 years ago
  1. Since there's a chance that 127.0.0.1 isn't always the loopback address or may not always work, we allow this to be specified by the new property localhost.server.http in build.properties. Updating recently commited code that is affected by this and where I had been hardcoding 127.0.0.1. 2. Fixing up the port and now the server host name used by the solr extension: these should be the correct property names, which are localhost.port.http and the new localhost.server.http instead of tomcat.server and the default port for the default protocol, since all GS3 internal communications with solr are done through the local HTTP url, whatever the public URL (with default protocol, matching port and server name) might be. I also updated the get-solr-servlet-url target in build.xml to use the local http base URL (see point 3), so that solr building will work correctly. 3. build.xml now has 2 new targets, one to get the local http base URL and one to get the local http default servlet URL. Both also use the new localhost.server.http property, besides the recently introduced localhost.port.http property. 4. Now the default behaviour of util.pm::get_full_greenstone_url_prefix() is to call the new get-local-http-servlet-url ant target, since only activate.pl's servercontrol.pm helper module uses it. If you want util.pm::get_full_greenstone_url_prefix() to return the non-local (public) servlet URL, pass in 1 (true) for the new 3rd parameter. The important decision here is that activate will use the internal (i.e. local http) greenstone servlet URL to issue pinging and (de)activating commands, since localhost (specifically 127.0.0.1) over http is now always available and because a domain named server over https will create complications to do with certification checks by wget, when wget gets run by activate.pl. Alternatively, activate.pl/servercontrol.pm could run wget with the no-cert-checking flag or we could make wget check the GS3 https certificate if one exists. But all that is convoluted and unnecessary: we've so far always worked with http, and usually with localhost over the httpport, and activate.pl so far has worked well with this, so have some confidence that using the local http URL internally should still work, even if the default GS3 URL has been set up to be a public (https) URL.
File size: 3.9 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=8383
15set SOLR_HOST=127.0.0.1
16
17setlocal enabledelayedexpansion
18set FOUNDPROPS=
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
23:: Loosely based on
24:: http://stackoverflow.com/questions/7708681/how-to-read-from-a-properties-file-using-batch-script
25:: for with usebackq option allows spaces in filepath to be protected with double quotes
26:: (backquotes will be used for executing the commands)
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
29FOR /F "usebackq tokens=1,2 delims==" %%G IN ("%GSDL3SRCHOME%\build.properties") DO (
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
32 :: break out of the loop as soon as both properties are found
33 if "!FOUNDPROPS!" == "foundfound" goto foundall
34)
35
36:foundall
37endlocal& set SOLR_HOST=%SOLR_HOST%& set SOLR_PORT=%SOLR_PORT%
38echo Tomcat host: %SOLR_HOST%
39echo Tomcat port: %SOLR_PORT%
40
41
42rem IF USING JETTY SERVER FOR SOLR
43:: The port Jetty runs on:
44set SOLR_JETTY_PORT=8983
45
46:: The port Jetty listens on for a "stop" command
47set JETTY_STOP_PORT=8079
48
49if "%OS%" == "Windows_NT" goto WinNT
50if "%OS%" == "" goto Win95
51if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
52if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
53if "%GSDLLANG%" == "fr" echo Ech‚c de l'installation - votre variable PATH n'a pas ‚t‚ ajust‚e
54if "%GSDLLANG%" == "ru" echo “áâ ­®¢ª  ­¥ ã€ « áì - “’œ ­¥ ¡ë« ãáâ ­®¢«¥­
55goto End
56
57:WinNT
58set GEXT_SOLR=%CD%
59set PATH=%GEXT_SOLR%\bin\script;%PATH%
60set PATH=%GEXT_SOLR%\lib;%PATH%
61set GS_CP_SET=yes
62goto Success
63
64:Win95
65if "%1" == "SetEnv" goto Win95Env
66REM We'll invoke a second copy of the command processor to make
67REM sure there's enough environment space
68COMMAND /E:2048 /K %0 SetEnv
69goto End
70
71:Win95Env
72set GEXT_SOLR=%CD%
73set PATH="%GEXT_SOLR%\bin\script";"%PATH%"
74set PATH="%GEXT_SOLR%\lib";"%PATH%"
75set GS_CP_SET=yes
76goto Success
77
78:Success
79
80set fulldir=%~dp0
81
82:: strip off everything up to (and including) ext dir
83set extdir=%fulldir:*ext\=%
84
85:: remove trailing slash
86set extdir=%extdir:\=%
87
88setlocal enabledelayedexpansion
89if "x%GSDL3EXTS%" == "x" (
90 set GSDL3EXTS=!extdir!
91) else (
92 set GSDL3EXTS=!GSDL3EXTS!:!extdir!
93)
94endlocal & set GSDL3EXTS=%GSDL3EXTS%
95
96echo +Your environment is now setup for %extdesc%
97
98:: Back to delayed expansion to avoid problems with environment
99:: variables with brackets in them, such as "Program Files (x86)"
100
101::echo ++Solr/Jetty server will run on port %SOLR_JETTY_PORT% (+ port %JETTY_STOP_PORT% for shutdown command)
102echo ++Solr will run off the tomcat server on port %SOLR_PORT%
103echo --This port value can be changed by editing tomcat.port in build.properties
104::echo -- %0
105
106
107
108:End
109
110popd
Note: See TracBrowser for help on using the repository browser.