source: gli/trunk/gli.bat@ 18299

Last change on this file since 18299 was 17942, checked in by max, 15 years ago

Do not need to be run from the directory in which it resides anymore (necesarry for Vista elevation). Show green logo.

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