source: gli/trunk/gli.bat@ 19226

Last change on this file since 19226 was 18415, checked in by ak19, 15 years ago

Minor correction: comment was marked as label instead.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 15.4 KB
RevLine 
[5824]1@echo off
[17942]2color 0A
3pushd "%CD%"
4CD /D "%~dp0"
[6749]5set GLILANG=en
[5824]6
[6749]7
[5824]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
[6749]12 if "%GLILANG%" == "en" echo This script must be run from the directory in which it resides.
[6753]13 if "%GLILANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
[6749]14 if "%GLILANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ …
[6754]15 partir du r‚pertoire dans lequel il se trouve.
[5824]16 if "%GLILANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
17 goto exit
18
[15608]19:start
[5824]20if "%OS%" == "Windows_NT" goto progName
[15608]21 :: Invoke a new command processor to ensure there's enough environment space
[5824]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
[15608]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
[6669]39
[6667]40:findGSDL
[15608]41echo.
[17942]42if "%GLILANG%" == "en" echo %PROGNAME% (%PROGABBR%)
[15608]43if "%GLILANG%" == "en" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
[6749]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
[15608]46
[17942]47if "%GLILANG%" == "es" echo Interfaz de la %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
[15608]48if "%GLILANG%" == "es" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
[6959]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
[6753]51if "%GLILANG%" == "es" echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
[15608]52
[17942]53if "%GLILANG%" == "fr" echo Interface du %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
[15608]54if "%GLILANG%" == "fr" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
[6955]55if "%GLILANG%" == "fr" echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des d‚tails, voir LICENSE.txt
[6754]56if "%GLILANG%" == "fr" echo Ceci est un logiciel libre, et vous ˆtes invit‚ …
[15608]57 le redistribuer
[17942]58
[7041]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
[6667]62if "%GLILANG%" == "ru" echo â® - ᢮¡®€­® à á¯à®áâ࠭塞®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ‚ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
[15608]63
[5824]64echo.
[15608]65:: ---- Determine path to Greenstone home for GS2 and GS3 ----
[5824]66set GSDLPATH=
[15608]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
[5824]76 set GSDLPATH=..
[15608]77 goto getVer
[17061]78
[15608]79:getVer
[15628]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
[15608]83if "%_VERSION%" == "2" set GSDL3SRCHOME=
[5824]84if "%_VERSION%" == "2" set GSDL3HOME=
85goto testGSDL
[15608]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
[15628]102set _VERSION=2
103set GSDLPATH=%GSDLHOME%
104::free up the GS3 environment variables since we are running GS2 and don't need them
[15608]105set GSDL3SRCHOME=
106set GSDL3HOME=
107goto testGSDL
[5824]108
[15608]109
[17061]110:testGSDL
[15608]111set CHECK=1
112call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
113if "%CHECK%" == "1" goto exit
[6749]114 :: otherwise installation worked well
[6753]115 goto prepGSDL
[15608]116
117
118:prepGSDL
[6754]119:: Greenstone 3 case
[15608]120if "%_VERSION%" == "3" goto prepGS3
[18407]121
[5824]122if not "%_VERSION%" == "2" echo "Greenstone version unknown"
[15608]123if not "%_VERSION%" == "2" goto exit
124
[5824]125:: Otherwise, we are dealing with Greenstone 2
[17911]126:: Setup Greenstone 2, unless it has already been done
[15608]127if not "%GSDLHOME%" == "" goto doneGSDL
[5824]128 call "%GSDLPATH%\setup.bat" SetEnv
[15608]129 goto doneGSDL
130
131
[18415]132:prepGS3
[15608]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
[17911]146 del %TMP%\setgli.bat
[15608]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
[17061]167:setupGS2
[15608]168set CHECK=1
169call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
170if "%CHECK%" == "1" goto exit
[17911]171 :: otherwise installation worked well
[15608]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
[5824]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 ----
[15199]186set PERLPATH=
187
188:: Some users may set the above line manually - If you do this, you need to
[5824]189:: make sure that perl is in your path otherwise lucene collections may not
190:: work
191if not "%PERLPATH%" == "" goto testPerl
[15354]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
[5824]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
[15354]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"
[5824]205 type %TMP%\perl.reg > %TMP%\perl.txt
[15354]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
[5824]210 call %TMP%\setperl.bat
211 del %TMP%\setperl.bat
212
213 :: If nothing was found in the registry, we're stuck
[15199]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.
[5824]218 if "%OS%" == "Windows_NT" set PATH=%PATH%;%PERLPATH%
219 if "%OS%" == "" set PATH="%PATH%";"%PERLPATH%"
220 goto testPerl
221
[15199]222:gsdlPerl
[5824]223 set PERLPATH=%GSDLHOME%\bin\windows\perl\bin
[17332]224
225:testPerl
[17861]226:: Check that a Perl executable has been found
[17332]227if not exist "%PERLPATH%\perl.exe" goto noPerl
[15608]228echo Perl:
[5824]229echo %PERLPATH%
[17332]230echo.
231
[5824]232goto findJava
233
[17139]234:noPerl
235 echo.
[16679]236 if "%GLILANG%" == "en" echo The Greenstone Librarian Interface requires Perl in order to operate,
[6749]237 if "%GLILANG%" == "en" echo but Perl could not be detected on your system. Please ensure that Perl
[6753]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.
[6749]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
[6754]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 ­¥ ¡ë« ¢ ¢ è¥© ášá⥬¥. ®Š «ã©áâ , ¯®€â¢¥à€šâ¥,
[5824]252 if "%GLILANG%" == "ru" echo çâ® Perl ãáâ ­®¢«¥­ š ­ å®€šâáï ­  ¢ è¥¬ ¯ãâš ¯®šáª , § â¥¬
253 if "%GLILANG%" == "ru" echo ¯®¢â®à­®¢¢¥€šâ¥ íâ®â áªàš¯â.
254 goto exit
255
[17501]256
257:findJava
258 if "%_VERSION%" == "2" (
259 set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
260 set HINT=%GSDLHOME%\packages\jre
261 )
[17655]262 if "%_VERSION%" == "3" (
[17501]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:
[5824]273 echo %JAVA_EXECUTABLE%
[17501]274 echo.
[5824]275
[17501]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
[5824]281 if "%GLILANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
[17501]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.
[5824]295 goto exit
296
297:checkGLI
298:: ---- Check that the GLI has been compiled ----
299if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
[6749]300if exist "GLI.jar" goto runGLI
301 echo.
302 if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
[6753]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
[10787]306 if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
[6749]307
[6754]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
[5824]311 if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
312 if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
313 goto exit
314
[17671]315
[17332]316:runGLI
317
318if not "%_VERSION%" == "" (
319 echo Greenstone Major Version:
320 echo %_VERSION%
[7680]321 echo.
[17332]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.
[17671]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
[15629]351
352:: ---- Finally, run the GLI ----
353if "%GLILANG%" == "en" echo Running the %PROGNAME%...
[16548]354if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
[5824]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
[12695]363:: -Xloggc:<file> Write garbage collection log
[15608]364
[17501]365
[15608]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)
[12689]374 if exist "%GSDLHOME%\server.exe" goto localLib
[17501]375
[18408]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
[17474]378 if ERRORLEVEL 2 (
[15608]379 goto webLib
[12689]380 )
[5824]381 goto finRun
[17501]382
[18408]383:localLib
384 "%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
[17474]385 if ERRORLEVEL 2 (
[15608]386 goto localLib
[12689]387 )
[15608]388 goto finRun
389
[6749]390
[6753]391:finRun
[6749]392 if "%GLILANG%" == "en" echo Done!
[6754]393 if "%GLILANG%" == "es" echo ­Hecho!
[5927]394 if "%GLILANG%" == "fr" echo Termin‚!
[5824]395 if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
[15608]396 goto done
[5824]397
398
399:exit
[17942]400echo.
401pause
[5824]402color 07
[5927]403popd
[5824]404
405:done
[17501]406:: ---- Clean up ----
[17942]407set PERLPATH=
408set JAVA_EXECUTABLE=
409color 07
410popd
Note: See TracBrowser for help on using the repository browser.