source: gli/trunk/gli.bat@ 17332

Last change on this file since 17332 was 17332, checked in by oranfry, 16 years ago

using search4j to find java in gli.bat

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 13.3 KB
Line 
1@echo off
2set GLILANG=en
3
4
5:: -------- Run the Greenstone Librarian Interface --------
6
7:: This script must be run from within the directory in which it lives
8if exist gli.bat goto start
9 if "%GLILANG%" == "en" echo This script must be run from the directory in which it resides.
10 if "%GLILANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
11 if "%GLILANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ …
12 partir du r‚pertoire dans lequel il se trouve.
13 if "%GLILANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
14 goto exit
15
16:start
17if "%OS%" == "Windows_NT" goto progName
18 :: Invoke a new command processor to ensure there's enough environment space
19 if "%1" == "Second" goto progName
20 command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
21 goto done
22
23
24:progName
25if not "%PROGNAME%" == "" goto findGSDL
26 :: otherwise PROGNAME was not set, so default to the Greenstone Librarian Interface (GLI) program
27 if "%GLILANG%" == "es" set PROGNAME=Biblioteca Digital Greenstone
28 if "%GLILANG%" == "fr" set PROGNAME=Bibliothécaire Greenstone
29 if "%GLILANG%" == "ru" set PROGNAME=ÉÎÔÅÒÆÅÊÓ Greenstone
30 :: if the PROGNAME is still not set, then set the language to English
31 if "%PROGNAME%" == "" set PROGNAME=Greenstone Librarian Interface
32
33
34if "%PROGABBR%" == "" set PROGABBR=GLI
35if "%PROGNAME_EN%" == "" set PROGNAME_EN=Greenstone Librarian Interface
36
37:findGSDL
38echo.
39if "%GLILANG%" == "en" echo %PROGNAME% (%PROGABBR%)
40if "%GLILANG%" == "en" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
41if "%GLILANG%" == "en" echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
42if "%GLILANG%" == "en" echo This is free software, and you are welcome to redistribute it
43
44if "%GLILANG%" == "es" echo Interfaz de la %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
45if "%GLILANG%" == "es" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
46if "%GLILANG%" == "es" echo La Interfaz de la %PROGNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
47if "%GLILANG%" == "es" echo Para mayor informaci¢n vea los t‚rminos de la licencia en LICENSE.txt
48if "%GLILANG%" == "es" echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
49
50if "%GLILANG%" == "fr" echo Interface du %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
51if "%GLILANG%" == "fr" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
52if "%GLILANG%" == "fr" echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des d‚tails, voir LICENSE.txt
53if "%GLILANG%" == "fr" echo Ceci est un logiciel libre, et vous ˆtes invit‚ …
54 le redistribuer
55
56if "%GLILANG%" == "ru" echo š¡«š®â¥ç­ë© š­â¥à䥩á %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
57if "%GLILANG%" == "ru" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
58if "%GLILANG%" == "ru" echo ˆƒ ­¥ € ¥â €‘Ž‹ž’Ž ˆŠ€Šˆ• ƒ€€’ˆ‰; €¥â «š á¬. ¢ ⥪á⥠LICENSE.TXT
59if "%GLILANG%" == "ru" echo â® - ᢮¡®€­® à á¯à®áâ࠭塞®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ‚ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
60
61echo.
62:: ---- Determine path to Greenstone home for GS2 and GS3 ----
63set GSDLPATH=
64:: Some users may set the above line manually, or it may be set as an argument
65
66set _VERSION=
67if not "%GSDLPATH%" == "" goto getVer
68 :: Otherwise gsdlpath is not yet set
69 :: Check the env vars first
70 if not "%GSDL3SRCHOME%" == "" goto ver3
71 if not "%GSDLHOME%" == "" goto ver2
72 :: If not set, the default location for the GLI is a subdirectory of Greenstone
73 set GSDLPATH=..
74 goto getVer
75
76:getVer
77call gsdlver.bat %GSDLPATH% %_VERSION% > nul
78if "%_VERSION%" == "1" goto exit
79::if we are running GS2, free up any pre-set GS3 environment variables since we won't need them
80if "%_VERSION%" == "2" set GSDL3SRCHOME=
81if "%_VERSION%" == "2" set GSDL3HOME=
82goto testGSDL
83
84
85:ver3
86set _VERSION=3
87set GSDLPATH=%GSDL3SRCHOME%
88:: if GS2 is now also set, then both GS3 and GS2 are set:
89:: warn the user that we have defaulted to GS3
90if not "%GSDLHOME%" == "" echo Both Greenstone 2 and Greenstone 3 environments are set.
91if not "%GSDLHOME%" == "" echo It is assumed you want to run Greenstone 3.
92if not "%GSDLHOME%" == "" echo If you want to run Greenstone 2, please unset the
93if not "%GSDLHOME%" == "" echo environment variable GSDL3SRCHOME before running GLI.
94if not "%GSDLHOME%" == "" echo.
95goto testGSDL
96
97
98:ver2
99set _VERSION=2
100set GSDLPATH=%GSDLHOME%
101::free up the GS3 environment variables since we are running GS2 and don't need them
102set GSDL3SRCHOME=
103set GSDL3HOME=
104goto testGSDL
105
106
107:testGSDL
108set CHECK=1
109call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
110if "%CHECK%" == "1" goto exit
111 :: otherwise installation worked well
112 goto prepGSDL
113
114
115:prepGSDL
116:: Greenstone 3 case
117if "%_VERSION%" == "3" goto prepGS3
118
119if not "%_VERSION%" == "2" echo "Greenstone version unknown"
120if not "%_VERSION%" == "2" goto :exit
121
122:: Otherwise, we are dealing with Greenstone 2
123:: Setup Greenstone 2, unless it has already been done
124if not "%GSDLHOME%" == "" goto doneGSDL
125 call "%GSDLPATH%\setup.bat" SetEnv > nul
126 goto doneGSDL
127
128
129:prepGS3
130set GSDL2PATH=
131: Some users may set the above line manually
132
133if "%GSDL3SRCHOME%" == "" goto setup3
134 if "%GSDL3HOME%" == "" goto setup3
135 ::otherwise
136 goto gs2build
137
138
139:setup3
140:: Setup Greenstone 3, unless it has already been done
141 cd | winutil\setvar.exe GLIDIR > %TMP%\setgli.bat
142 call %TMP%\setgli.bat
143 del %TMP%\setgli.bat
144 cd "%GSDLPATH%"
145 call gs3-setup.bat SetEnv > nul
146 cd %GLIDIR%
147 goto gs2build
148
149
150:gs2build
151 :: If Greenstone version 3 is running, we want to set gsdl2path
152 :: Determine GSDLHOME for GS3
153 if not "%GSDL2PATH%" == "" goto setupGS2
154 :: GSDL2PATH is not yet set.
155 :: And if GSDLHOME is not set either, then assume
156 :: that the gs2build subdir of GS3 exists
157 if "%GSDLHOME%" == "" set GSDL2PATH=%GSDL3SRCHOME%\gs2build
158 if "%GSDLHOME%" == "" goto setupGS2
159 :: Otherwise GSDLHOME is set, so set GSDL2PATH to GSDLHOME
160 echo GSDLHOME environment variable is set to %GSDLHOME%.
161 echo Will use this to find build scripts.
162 set GSDL2PATH=%GSDLHOME%
163
164:setupGS2
165set CHECK=1
166call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
167if "%CHECK%" == "1" goto exit
168 :: otherwise installation worked well
169 :: Setup Greenstone, unless it has already been done
170 if "%GSDLHOME%" == "" call "%GSDL2PATH%\setup.bat" SetEnv > nul
171 :: Either way, we can now dispose of GSDL2PATH
172 set GSDL2PATH=
173 goto doneGSDL
174
175
176:doneGSDL
177:: GSDLPATH is no longer needed, since GSDLHOME should now be set
178set GSDLPATH=
179
180
181:findPerl
182:: ---- Check Perl exists ----
183set PERLPATH=
184
185:: Some users may set the above line manually - If you do this, you need to
186:: make sure that perl is in your path otherwise lucene collections may not
187:: work
188if not "%PERLPATH%" == "" goto testPerl
189
190 :: Check if Perl is on the search path
191 echo %PATH%| winutil\which.exe perl.exe | winutil\setvar.exe PERLPATH > %TMP%\setperl.bat
192 call %TMP%\setperl.bat
193 del %TMP%\setperl.bat
194 if not "%PERLPATH%" == "" goto testPerl
195
196 :: If not, try GSDLHOME\bin\windows\perl\bin
197 if exist "%GSDLHOME%\bin\windows\perl\bin\perl.exe" goto gsdlPerl
198
199 :: Still haven't found anything, so try looking in the registry (gulp!)
200 type nul > %TMP%\perl.reg
201 regedit /E %TMP%\perl.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Perl"
202 type %TMP%\perl.reg > %TMP%\perl.txt
203 del %TMP%\perl.reg
204
205 winutil\findperl.exe %TMP%\perl.txt | winutil\setvar.exe PERLPATH > %TMP%\setperl.bat
206 del %TMP%\perl.txt
207 call %TMP%\setperl.bat
208 del %TMP%\setperl.bat
209
210 :: If nothing was found in the registry, we're stuck
211 if "%PERLPATH%" == "" goto noPerl
212
213 :: if have found perl in registry, but not in path, then we need to
214 :: add it to path for lucene stuff.
215 if "%OS%" == "Windows_NT" set PATH=%PATH%;%PERLPATH%
216 if "%OS%" == "" set PATH="%PATH%";"%PERLPATH%"
217 goto testPerl
218
219:gsdlPerl
220 set PERLPATH=%GSDLHOME%\bin\windows\perl\bin
221
222:testPerl
223:: Check that a Perl executable has been found
224if not exist "%PERLPATH%\perl.exe" goto noPerl
225echo PERL:
226echo %PERLPATH%
227echo.
228
229goto findJava
230
231:noPerl
232 echo.
233 if "%GLILANG%" == "en" echo The Greenstone Librarian Interface requires Perl in order to operate,
234 if "%GLILANG%" == "en" echo but Perl could not be detected on your system. Please ensure that Perl
235 if "%GLILANG%" == "en" echo is installed and is on your search path, then try again.
236
237 if "%GLILANG%" == "es" echo La Interfaz de la Biblioteca Digital Greenstone requiere Perl para poder
238 if "%GLILANG%" == "es" echo operar, pero ‚ste no aparece en su sistema. Por favor aseg£rese de
239 if "%GLILANG%" == "es" echo que Perl est  instalado y se encuentra en su ruta de b£squeda.
240 if "%GLILANG%" == "es" echo A continuaci¢n ejecute nuevamente este gui¢n.
241
242 if "%GLILANG%" == "fr" echo Greenstone Librarian Interface n‚cessite perl pour son fonctionnement,
243 if "%GLILANG%" == "fr" echo mais perl n'a pas pu ˆtre d‚tect‚ dans votre systŠme. Veuillez vous
244 if "%GLILANG%" == "fr" echo assurer que perl est install‚ et est sp‚cifi‚ dans votre chemin de
245 if "%GLILANG%" == "fr" echo recherche, puis red‚marrez ce script.
246
247 if "%GLILANG%" == "ru" echo š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone âॡã¥â Perl, çâ®¡ë š¬¥âì ¢®§¬®Š­®áâì
248 if "%GLILANG%" == "ru" echo à ¡®â âì, ­® Perl ­¥ ¡ë« ¢ ¢ è¥© ášá⥬¥. ®Š «ã©áâ , ¯®€â¢¥à€šâ¥,
249 if "%GLILANG%" == "ru" echo çâ® Perl ãáâ ­®¢«¥­ š ­ å®€šâáï ­  ¢ è¥¬ ¯ãâš ¯®šáª , § â¥¬
250 if "%GLILANG%" == "ru" echo ¯®¢â®à­®¢¢¥€šâ¥ íâ®â áªàš¯â.
251 goto exit
252
253
254:findJava
255winutil\search4j.exe -m "1.4.0_00" -h "%GSDLHOME%\packages\jre" | winutil\setvar.exe _JRE_HOME > %TMP%\set__jre_home.bat
256call "%TMP%\set__jre_home.bat"
257del "%TMP%\set__jre_home.bat"
258
259if "%_JRE_HOME%" == "" goto noJava
260echo %_JRE_HOME%\bin | winutil\setvar.exe JAVAPATH > %TMP%\set_javapath.bat
261call "%TMP%\set_javapath.bat"
262del "%TMP%\set_javapath.bat"
263echo JRE:
264echo %_JRE_HOME%
265echo.
266
267goto checkGLI
268
269:checkGLI
270:: ---- Check that the GLI has been compiled ----
271if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
272if exist "GLI.jar" goto runGLI
273 echo.
274 if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
275 if "%GLILANG%" == "en" echo before running this script.
276
277 if "%GLILANG%" == "es" echo Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone
278 if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
279
280 if "%GLILANG%" == "fr" echo Vous devez compiler le Greenstone Interface (en utilisant makegli.bat)
281 if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
282
283 if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
284 if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
285 goto exit
286
287
288:runGLI
289:: ---- Finally, run the GLI ----
290if not "%_VERSION%" == "" (
291 echo Greenstone Major Version:
292 echo %_VERSION%
293 echo.
294)
295
296if not "%GSDL3SRCHOME%" == "" (
297 echo GSDL3SRCHOME:
298 echo %GSDL3SRCHOME%
299 echo.
300)
301
302if not "%GSDL3HOME%" == "" (
303 echo GSDL3HOME:
304 echo %GSDL3HOME%
305 echo.
306)
307
308if not "%GSDLHOME%" == "" (
309 echo GSDLHOME:
310 echo %GSDLHOME%
311 echo.
312)
313
314if "%GLILANG%" == "en" echo Running the %PROGNAME%...
315if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
316if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
317if "%GLILANG%" == "ru" echo ’¥ªãéš© ¡š¡«š %PROGNAME%...
318
319:: -Xms32M To set minimum memory
320:: -Xmx32M To set maximum memory
321:: -verbose:gc To set garbage collection messages
322:: -Xincgc For incremental garbage collection
323:: -Xprof Function call profiling
324:: -Xloggc:<file> Write garbage collection log
325
326
327:: Run GS3 if version = 3
328if "%_VERSION%" == "3" "%JAVAPATH%\java" -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl %GSDLHOME% -gsdlos %GSDLOS% -gsdl3 %GSDL3HOME% -gsdl3src %GSDL3SRCHOME% -perl %PERLPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9
329if "%_VERSION%" == "3" goto finRun
330
331:: Run GS2 since version is 2:
332:: if FLI is running, we don't want the local Greenstone library server running
333if "%PROGABBR%" == "FLI" goto webLib
334 :: Else we're running GLI, so we want the local Greenstone library server (if server.exe exists, otherwise it will be webLib)
335 if exist "%GSDLHOME%\server.exe" goto localLib
336
337:webLib
338 ::"%JAVAPATH%\java" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl %GSDLHOME% -gsdlos %GSDLOS% -perl %PERLPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9
339 if ERRORLEVEL 2 goto webLib
340 goto finRun
341
342:localLib
343 ::"%JAVAPATH%\java" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl %GSDLHOME% -gsdlos %GSDLOS% -perl %PERLPATH% -local_library %GSDLHOME%\server.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
344 if ERRORLEVEL 2 goto localLib
345 goto finRun
346
347
348:finRun
349 if "%GLILANG%" == "en" echo Done!
350 if "%GLILANG%" == "es" echo ­Hecho!
351 if "%GLILANG%" == "fr" echo Termin‚!
352 if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
353 goto done
354
355
356:exit
357echo.
358pause
359
360:done
361:: ---- Clean up ----
362set PERLPATH=
363set JAVAPATH=
Note: See TracBrowser for help on using the repository browser.