root/gli/trunk/gems.bat @ 17943

Revision 17943, 10.6 KB (checked in by max, 11 years ago)

Now uses the same logic as gli.bat, use search4j, support vista elevation.

  • Property svn:mime-type set to application/octet-stream
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 gems.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 "%GLILANG%" == "es" set PROGNAME=Editar conjuntos de metadatos
28if "%GLILANG%" == "fr" set PROGNAME=Editer les jeux de méta-données
29if "%GLILANG%" == "ru" set PROGNAME=Ðåäàêòèðîâàòü íàáîðû ìåòàäàííûõ
30:: if the PROGNAME is still not set, then set the language to English
31if "%PROGNAME%" == "" set PROGNAME=Greenstone Editor for Metadata Sets
32
33if "%PROGABBR%" == "" set PROGABBR=GEMS
34if "%PROGNAME_EN%" == "" set PROGNAME_EN=Greenstone Editor for Metadata Sets
35
36:findGSDL
37echo.
38if "%GLILANG%" == "en" echo %PROGNAME% (%PROGABBR%)
39if "%GLILANG%" == "en" echo Copyright (C) 2008, 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 %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
44if "%GLILANG%" == "es" echo Copyright (C) 2008, New Zealand Digital Library Project, University Of Waikato
45if "%GLILANG%" == "es" echo %PROGABBR% 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 %PROGNAME% (%PROGNAME_EN% - %PROGABBR%)
50if "%GLILANG%" == "fr" echo Copyright (C) 2008, 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) 2008, 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% SetEnv > 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% SetEnv > 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% SetEnv > 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:findJava
180    if "%_VERSION%" == "2" (
181        set SEARCH4J_EXECUTABLE=%GSDLHOME%\bin\windows\search4j.exe
182        set HINT=%GSDLHOME%\packages\jre
183    )
184    if "%_VERSION%" == "3" (
185        set SEARCH4J_EXECUTABLE=%GSDL3SRCHOME%\bin\search4j.exe
186        set HINT=%GSDL3SRCHOME%\packages\jre
187    )
188   
189    "%SEARCH4J_EXECUTABLE%" -e -m "1.4.0_00" -p "%HINT%" | winutil\setvar.exe JAVA_EXECUTABLE > %TMP%\set_java_executable.bat
190    call "%TMP%\set_java_executable.bat"
191    del "%TMP%\set_java_executable.bat"
192   
193    if "%JAVA_EXECUTABLE%" == "" goto noJava
194    echo Java:
195    echo %JAVA_EXECUTABLE%
196    echo.
197
198    goto chkGEMS
199
200
201:noJava
202    echo.
203    if "%GLILANG%" == "en" echo Failed to locate an appropriate version of Java. You must install a
204    if "%GLILANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
205    if "%GLILANG%" == "en" echo Greenstone Librarian Interface.
206
207    if "%GLILANG%" == "es" echo No se pudo localizar una versi¢n apropiada de Java. Usted deber
208    if "%GLILANG%" == "es" echo instalar un Ambiente de Ejecuci¢n Java (versi¢n 1.4 o superior)
209    if "%GLILANG%" == "es" echo antes de correr la Interfaz de la Biblioteca Digital Greenstone.
210
211    if "%GLILANG%" == "fr" echo Une version ad?quate de Java n'a pas pu ?tre localis?e. Vous devez
212    if "%GLILANG%" == "fr" echo installer un Java Runtime Environment (version 1.4 ou sup?rieur)
213    if "%GLILANG%" == "fr" echo avant de d?marrer Greenstone Librarian Interface.
214
215    if "%GLILANG%" == "ru" echo ¥ 〠«®áì ®¯à¥€¥«šâì ¬¥áâ®­ 宊€¥­š¥ ᮮ⢥âáâ¢ãî饩 ¢¥àᚚ Java.
216    if "%GLILANG%" == "ru" echo ?ë €®«Š­ë ãáâ ­®¢šâì Java Runtime Environment (¢¥àášî 1.4 š«š ¢ëè¥) ¯¥à¥€ ¢¢®€®¬
217    if "%GLILANG%" == "ru" echo ¡š¡«š®â¥ç­®£® š­â¥àä¥©á  Greenstone.
218    goto exit
219
220
221:chkGEMS
222:: ---- Check that the GEMS has been compiled ----
223if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGEMS
224if exist "GLI.jar" goto runGEMS
225    echo.
226    if "%GLILANG%" == "en" echo You need to compile the %PROGNAME% (using makegli.bat)
227    if "%GLILANG%" == "en" echo before running this script.
228
229    if "%GLILANG%" == "es" echo Usted necesita compilar la %PROGNAME%
230    if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
231
232    if "%GLILANG%" == "fr" echo Vous devez compiler le %PROGNAME% (en utilisant makegli.bat)
233    if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
234
235    if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì %PROGNAME% (šá¯®«ì§ãï makegli.bat)
236    if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
237    goto exit
238
239
240:runGEMS
241if not "%_VERSION%" == "" (
242    echo Greenstone Major Version:
243    echo %_VERSION%
244    echo.
245)
246
247if not "%GSDL3SRCHOME%" == "" (
248    echo GSDL3SRCHOME:
249    echo %GSDL3SRCHOME%
250    echo.
251)
252
253if not "%GSDL3HOME%" == "" (
254    echo GSDL3HOME:
255    echo %GSDL3HOME%
256    echo.
257)
258
259if not "%GSDLHOME%" == "" (
260    echo GSDLHOME:
261    echo %GSDLHOME%
262    echo.
263)
264
265:: ---- Finally, run the GEMS ----
266if "%GLILANG%" == "en" echo Running the %PROGNAME%...
267if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
268if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
269if "%GLILANG%" == "ru" echo ’¥ªãéš© %PROGNAME%...
270
271:: -Xms32M          To set minimum memory
272:: -Xmx32M          To set maximum memory
273:: -verbose:gc      To set garbage collection messages
274:: -Xincgc          For incremental garbage collection
275:: -Xprof           Function call profiling
276:: -Xloggc:<file>   Write garbage collection log
277
278
279:: Run GS3 if version = 3
280if "%_VERSION%" == "3" "%JAVA_EXECUTABLE%" -cp classes/;GLI.jar;lib/apache.jar org.greenstone.gatherer.gems.GEMS -gsdl3 %GSDL3HOME% %1 %2 %3 %4 %5 %6 %7 %8 %9
281if "%_VERSION%" == "3" goto finRun
282
283    :: Else run GS2 since version is 2:
284    "%JAVA_EXECUTABLE%" -cp classes/;GLI.jar;lib/apache.jar org.greenstone.gatherer.gems.GEMS -gsdl %GSDLHOME% %1 %2 %3 %4 %5 %6 %7 %8 %9
285
286:finRun
287    if "%GLILANG%" == "en" echo Done!
288    if "%GLILANG%" == "es" echo ­Hecho!
289    if "%GLILANG%" == "fr" echo Termin‚!
290    if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
291    goto done
292
293
294:exit
295echo.
296pause
297color 07
298popd
299:done
300:: ---- Clean up ----
301set JAVAPATH=
302set JAVA_EXECUTABLE=
303color 07
304popd
Note: See TracBrowser for help on using the browser.