root/gli/trunk/gli.bat @ 17911

Revision 17911, 15.5 KB (checked in by max, 11 years ago)

Now shows the error message produced if GSDLHOME do not have write permissions.

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