source: gli/trunk/gli.bat@ 17845

Last change on this file since 17845 was 17671, checked in by max, 15 years ago

Explain how to bypass Ghostscript/Imagemagick bundled with Greenstone if needed.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.5 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
255 if "%_VERSION%" == "2" (
256 set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
257 set HINT=%GSDLHOME%\packages\jre
258 )
259 if "%_VERSION%" == "3" (
260 set SEARCH4J_EXECUTABLE=%GSDL3SRCHOME%\bin\search4j.exe
261 set HINT=%GSDL3SRCHOME%\packages\jre
262 )
263
264 "%SEARCH4J_EXECUTABLE%" -e -m "1.4.0_00" -p "%HINT%" | winutil\setvar.exe JAVA_EXECUTABLE > %TMP%\set_java_executable.bat
265 call "%TMP%\set_java_executable.bat"
266 del "%TMP%\set_java_executable.bat"
267
268 if "%JAVA_EXECUTABLE%" == "" goto noJava
269 echo Java:
270 echo %JAVA_EXECUTABLE%
271 echo.
272
273 goto checkGLI
274
275:noJava
276 echo.
277 if "%GLILANG%" == "en" echo Failed to locate an appropriate version of Java. You must install a
278 if "%GLILANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
279 if "%GLILANG%" == "en" echo Greenstone Librarian Interface.
280
281 if "%GLILANG%" == "es" echo No se pudo localizar una versi¢n apropiada de Java. Usted deber
282 if "%GLILANG%" == "es" echo instalar un Ambiente de Ejecuci¢n Java (versi¢n 1.4 o superior)
283 if "%GLILANG%" == "es" echo antes de correr la Interfaz de la Biblioteca Digital Greenstone.
284
285 if "%GLILANG%" == "fr" echo Une version ad?quate de Java n'a pas pu ?tre localis?e. Vous devez
286 if "%GLILANG%" == "fr" echo installer un Java Runtime Environment (version 1.4 ou sup?rieur)
287 if "%GLILANG%" == "fr" echo avant de d?marrer Greenstone Librarian Interface.
288
289 if "%GLILANG%" == "ru" echo ¥ 〠«®áì ®¯à¥€¥«šâì ¬¥áâ®­ 宊€¥­š¥ ᮮ⢥âáâ¢ãî饩 ¢¥àᚚ Java.
290 if "%GLILANG%" == "ru" echo ?ë €®«Š­ë ãáâ ­®¢šâì Java Runtime Environment (¢¥àášî 1.4 š«š ¢ëè¥) ¯¥à¥€ ¢¢®€®¬
291 if "%GLILANG%" == "ru" echo ¡š¡«š®â¥ç­®£® š­â¥à䥩á Greenstone.
292 goto exit
293
294:checkGLI
295:: ---- Check that the GLI has been compiled ----
296if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
297if exist "GLI.jar" goto runGLI
298 echo.
299 if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
300 if "%GLILANG%" == "en" echo before running this script.
301
302 if "%GLILANG%" == "es" echo Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone
303 if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
304
305 if "%GLILANG%" == "fr" echo Vous devez compiler le Greenstone Interface (en utilisant makegli.bat)
306 if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
307
308 if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
309 if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
310 goto exit
311
312
313:runGLI
314
315if not "%_VERSION%" == "" (
316 echo Greenstone Major Version:
317 echo %_VERSION%
318 echo.
319)
320
321if not "%GSDL3SRCHOME%" == "" (
322 echo GSDL3SRCHOME:
323 echo %GSDL3SRCHOME%
324 echo.
325)
326
327if not "%GSDL3HOME%" == "" (
328 echo GSDL3HOME:
329 echo %GSDL3HOME%
330 echo.
331)
332
333if not "%GSDLHOME%" == "" (
334 echo GSDLHOME:
335 echo %GSDLHOME%
336 echo.
337)
338
339:: ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
340echo.
341if 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.
342echo.
343echo.
344if 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.
345echo.
346echo.
347
348
349:: ---- Finally, run the GLI ----
350if "%GLILANG%" == "en" echo Running the %PROGNAME%...
351if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
352if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
353if "%GLILANG%" == "ru" echo ’¥ªãéš© ¡š¡«š %PROGNAME%...
354
355:: -Xms32M To set minimum memory
356:: -Xmx32M To set maximum memory
357:: -verbose:gc To set garbage collection messages
358:: -Xincgc For incremental garbage collection
359:: -Xprof Function call profiling
360:: -Xloggc:<file> Write garbage collection log
361
362
363:: Run GS3 if version = 3
364if "%_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
365if "%_VERSION%" == "3" goto finRun
366
367:: Run GS2 since version is 2:
368:: if FLI is running, we don't want the local Greenstone library server running
369if "%PROGABBR%" == "FLI" goto webLib
370 :: Else we're running GLI, so we want the local Greenstone library server (if server.exe exists, otherwise it will be webLib)
371 if exist "%GSDLHOME%\server.exe" goto localLib
372
373:webLib
374 "%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
375 if ERRORLEVEL 2 if not "%localLibFailed%" == "true" (
376 echo webLib failed, going to localLib
377 set webLibFailed=true
378 goto localLib
379 )
380 goto finRun
381
382:localLib
383 "%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
384 if ERRORLEVEL 2 if not "%webLibFailed%" == "true" (
385 echo localLib failed, going to webLib
386 set localLibFailed=true
387 goto webLib
388 )
389 goto finRun
390
391
392:finRun
393 if "%GLILANG%" == "en" echo Done!
394 if "%GLILANG%" == "es" echo ­Hecho!
395 if "%GLILANG%" == "fr" echo Termin‚!
396 if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
397 goto done
398
399
400:exit
401echo.
402pause
403
404:done
405:: ---- Clean up ----
406set PERLPATH=
407set JAVA_EXECUTABLE=
Note: See TracBrowser for help on using the repository browser.