root/gli/trunk/gli.bat @ 17942

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