root/gli/trunk/gli.bat @ 19336

Revision 19336, 10.6 KB (checked in by ak19, 11 years ago)

client-gli.bat and gli.bat both go through the findjava part of the script, so moved this into a separate scriptfile that can be called by both.

  • 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" (
42        echo %PROGNAME% ^(%PROGABBR%^)
43        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
44        echo %PROGABBR% comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
45        echo This is free software, and you are welcome to redistribute it
46    )
47
48if "%GLILANG%" == "es" (
49        echo Interfaz de la %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
50        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
51        echo La Interfaz de la %PROGNAME% NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÖA.
52        echo Para mayor informaci¢n vea los t‚rminos de la licencia en LICENSE.txt
53        echo Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita
54    )
55
56if "%GLILANG%" == "fr" (
57        echo Interface du %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
58        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
59        echo %PROGABBR% est fourni sans AUCUNE GARANTIE; pour des d‚tails, voir LICENSE.txt
60        echo Ceci est un logiciel libre, et vous ˆtes invit‚ … le redistribuer
61    )
62
63if "%GLILANG%" == "ru" (
64        echo š¡«š®â¥ç­ë© š­â¥à䥩á %PROGNAME% ^(%PROGNAME_EN% - %PROGABBR%^)
65        echo Copyright ^(C^) 2008, New Zealand Digital Library Project, University Of Waikato
66        echo ˆƒ ­¥ € ¥â €‘Ž‹ž’Ž ˆŠ€Šˆ• ƒ€€’ˆ‰; €¥â «š á¬. ¢ ⥪á⥠LICENSE.TXT
67        echo â® - ᢮¡®€­® à á¯à®áâ࠭塞®¥ ¯à®£à ¬¬­®¥ ®¡¥á¯¥ç¥­š¥ š ‚ë ¬®Š¥â¥ à á¯à®áâà ­ïâì ¥£®
68    )
69
70echo.
71::  ---- Determine path to Greenstone home for GS2 and GS3 ----
72set GSDLPATH=
73:: Some users may set the above line manually, or it may be set as an argument
74
75set _VERSION=
76if not "%GSDLPATH%" == "" goto getVer
77    :: Otherwise gsdlpath is not yet set
78    :: Check the env vars first
79    if not "%GSDL3SRCHOME%" == "" goto ver3
80        if not "%GSDLHOME%" == "" goto ver2
81            :: If not set, the default location for the GLI is a subdirectory of Greenstone
82            set GSDLPATH=..
83            goto getVer
84
85:getVer
86call gsdlver.bat %GSDLPATH% %_VERSION% > nul
87if "%_VERSION%" == "1" goto exit
88::if we are running GS2, free up any pre-set GS3 environment variables since we won't need them
89if "%_VERSION%" == "2" set GSDL3SRCHOME=
90if "%_VERSION%" == "2" set GSDL3HOME=
91goto testGSDL
92
93
94:ver3
95set _VERSION=3
96set GSDLPATH=%GSDL3SRCHOME%
97:: if GS2 is now also set, then both GS3 and GS2 are set:
98:: warn the user that we have defaulted to GS3
99if not "%GSDLHOME%" == "" echo Both Greenstone 2 and Greenstone 3 environments are set.
100if not "%GSDLHOME%" == "" echo It is assumed you want to run Greenstone 3.
101if not "%GSDLHOME%" == "" echo If you want to run Greenstone 2, please unset the
102if not "%GSDLHOME%" == "" echo environment variable GSDL3SRCHOME before running GLI.
103if not "%GSDLHOME%" == "" echo.
104goto testGSDL
105
106
107:ver2
108set _VERSION=2
109set GSDLPATH=%GSDLHOME%
110::free up the GS3 environment variables since we are running GS2 and don't need them
111set GSDL3SRCHOME=
112set GSDL3HOME=
113goto testGSDL
114
115
116:testGSDL
117set CHECK=1
118call chkinst.bat "%GSDLPATH%" %_VERSION% %GLILANG% %CHECK% > nul
119if "%CHECK%" == "1" goto exit
120    :: otherwise installation worked well
121    goto prepGSDL
122
123
124:prepGSDL
125:: Greenstone 3 case
126if "%_VERSION%" == "3" goto prepGS3
127
128if not "%_VERSION%" == "2" echo "Greenstone version unknown"
129if not "%_VERSION%" == "2" goto exit
130
131:: Otherwise, we are dealing with Greenstone 2
132:: Setup Greenstone 2, unless it has already been done
133if not "%GSDLHOME%" == "" goto doneGSDL
134    call "%GSDLPATH%\setup.bat" SetEnv
135    goto doneGSDL
136
137
138:prepGS3
139set GSDL2PATH=
140:: Some users may set the above line manually
141
142if "%GSDL3SRCHOME%" == "" goto setup3
143    if "%GSDL3HOME%" == "" goto setup3
144        ::otherwise
145        goto gs2build
146
147
148:setup3
149:: Setup Greenstone 3, unless it has already been done
150    cd | winutil\setvar.exe GLIDIR > %TMP%\setgli.bat
151    call %TMP%\setgli.bat
152    del %TMP%\setgli.bat
153    cd "%GSDLPATH%"
154    call gs3-setup.bat SetEnv
155    cd %GLIDIR%
156    goto gs2build
157
158
159:gs2build
160    :: If Greenstone version 3 is running, we want to set gsdl2path
161    :: Determine GSDLHOME for GS3
162    if not "%GSDL2PATH%" == "" goto setupGS2
163        :: GSDL2PATH is not yet set.
164        :: And if GSDLHOME is not set either, then assume
165        :: that the gs2build subdir of GS3 exists
166        if "%GSDLHOME%" == "" set GSDL2PATH=%GSDL3SRCHOME%\gs2build
167        if "%GSDLHOME%" == "" goto setupGS2
168            :: Otherwise GSDLHOME is set, so set GSDL2PATH to GSDLHOME
169            echo GSDLHOME environment variable is set to %GSDLHOME%.   
170            echo Will use this to find build scripts.
171            set GSDL2PATH=%GSDLHOME%
172
173:setupGS2
174set CHECK=1
175call chkinst.bat "%GSDL2PATH%" 2 %GLILANG% %CHECK% > nul
176if "%CHECK%" == "1" goto exit
177    :: otherwise installation worked well
178    :: Setup Greenstone, unless it has already been done
179    if "%GSDLHOME%" == "" call "%GSDL2PATH%\setup.bat" SetEnv
180    :: Either way, we can now dispose of GSDL2PATH
181    set GSDL2PATH= 
182    goto doneGSDL
183
184
185:doneGSDL
186:: GSDLPATH is no longer needed, since GSDLHOME should now be set
187set GSDLPATH=
188
189
190:: Now need to find Perl. If found, PERLPATH will be set
191call findperl.bat
192if "%PERLPATH%" == "" goto exit
193
194:: Need to find Java. If found, JAVA_EXECUTABLE will be set
195call findjava.bat
196if "%JAVA_EXECUTABLE%" == "" goto exit
197
198
199:checkGLI
200:: ---- Check that the GLI has been compiled ----
201if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
202if exist "GLI.jar" goto runGLI
203    echo.
204    if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
205    if "%GLILANG%" == "en" echo before running this script.
206
207    if "%GLILANG%" == "es" echo Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone
208    if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
209
210    if "%GLILANG%" == "fr" echo Vous devez compiler le Greenstone Interface (en utilisant makegli.bat)
211    if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
212
213    if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
214    if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
215    goto exit
216
217
218:runGLI
219
220if not "%_VERSION%" == "" (
221    echo Greenstone Major Version:
222    echo %_VERSION%
223    echo.
224)
225
226if not "%GSDL3SRCHOME%" == "" (
227    echo GSDL3SRCHOME:
228    echo %GSDL3SRCHOME%
229    echo.
230)
231
232if not "%GSDL3HOME%" == "" (
233    echo GSDL3HOME:
234    echo %GSDL3HOME%
235    echo.
236)
237
238if not "%GSDLHOME%" == "" (
239    echo GSDLHOME:
240    echo %GSDLHOME%
241    echo.
242)
243
244:: ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
245echo.
246if 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.
247echo.
248echo.
249if 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.
250echo.
251echo.
252
253
254:: ---- Finally, run the GLI ----
255if "%GLILANG%" == "en" echo Running the %PROGNAME%...
256if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
257if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
258if "%GLILANG%" == "ru" echo ’¥ªãéš© ¡š¡«š %PROGNAME%...
259
260:: -Xms32M          To set minimum memory
261:: -Xmx32M          To set maximum memory
262:: -verbose:gc      To set garbage collection messages
263:: -Xincgc          For incremental garbage collection
264:: -Xprof           Function call profiling
265:: -Xloggc:<file>   Write garbage collection log
266
267
268:: Run GS3 if version = 3
269if "%_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
270if "%_VERSION%" == "3" goto finRun
271
272:: Run GS2 since version is 2:
273:: if FLI is running, we don't want the local Greenstone library server running
274if "%PROGABBR%" == "FLI" goto webLib
275    :: Else we're running GLI, so we want the local Greenstone library server (if server.exe exists, otherwise it will be webLib)
276    if exist "%GSDLHOME%\server.exe" goto localLib
277
278:webLib
279    "%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
280    if ERRORLEVEL 2 (
281        goto webLib
282    )
283    goto finRun
284
285:localLib
286    "%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
287    if ERRORLEVEL 2 (
288        goto localLib
289    )
290    goto finRun
291
292
293:finRun
294    if "%GLILANG%" == "en" echo Done!
295    if "%GLILANG%" == "es" echo ­Hecho!
296    if "%GLILANG%" == "fr" echo Termin‚!
297    if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
298    goto done
299
300
301:exit
302echo.
303pause
304color 07
305popd
306
307:done
308:: ---- Clean up ----
309set PERLPATH=
310set JAVA_EXECUTABLE=
311color 07
312popd
Note: See TracBrowser for help on using the browser.