source: main/trunk/gli/gli.bat@ 29711

Last change on this file since 29711 was 25939, checked in by ak19, 12 years ago

Added in the code for restarting GLI for GS3 on Windows after language preferences have changed. It already worked on Linux for GS2 and GS3 and on Windows for GS2.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1@echo off
2setlocal enabledelayedexpansion
3
4color 0A
5set startdir=%CD%
6rem pushd "%CD%"
7CD /D "%~dp0"
8set GLILANG=en
9
10if "%GLIMODE%" == "" set GLIMODE=local
11
12:: -------- Run the Greenstone Librarian Interface --------
13
14:: This script must be run from within the directory in which it lives
15if exist gli.bat goto start
16 if "%GLILANG%" == "en" echo This script must be run from the directory in which it resides.
17 if "%GLILANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
18 if "%GLILANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ …
19 partir du r‚pertoire dans lequel il se trouve.
20 if "%GLILANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
21 goto exit
22
23:start
24if "%OS%" == "Windows_NT" goto progName
25 :: Invoke a new command processor to ensure there's enough environment space
26 if "%1" == "Second" goto progName
27 command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
28 shift
29 goto done
30
31:progName
32if not "%PROGNAME%" == "" goto findGSDL
33 :: otherwise PROGNAME was not set, so default to the Greenstone Librarian Interface (GLI) program
34 if "%GLILANG%" == "es" set PROGNAME=Biblioteca Digital Greenstone
35 if "%GLILANG%" == "fr" set PROGNAME=Bibliothécaire Greenstone
36 if "%GLILANG%" == "ru" set PROGNAME=ÉÎÔÅÒÆÅÊÓ Greenstone
37 :: if the PROGNAME is still not set, then set the language to English
38 if "%PROGNAME%" == "" set PROGNAME=Greenstone Librarian Interface
39
40
41if "%PROGABBR%" == "" set PROGABBR=GLI
42if "%PROGNAME_EN%" == "" set PROGNAME_EN=Greenstone Librarian Interface
43
44:: Now need to work out the _VERSION, GSDLHOME (and if GS3, then GSDL3SRCHOME and GSDL3HOME)
45:findGSDL
46call findgsdl.bat
47if "%GSDLHOME%" == "" goto exit
48
49:checkUserPermissions
50 echo.
51 echo Checking if the Greenstone collection directory is writable ...
52 (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\collect\testing.tmp" ) 2>nul
53 if exist "%GSDLHOME%\collect\testing.tmp" goto deleteTempFile
54 if "%1" == "Elevated" goto printWarning
55 echo ... FAILED
56 echo The %PROGNAME% cannot write to the collection directory (!GSDLHOME!\collect)
57 echo Requesting elevated status to become admin user to continue.
58 "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
59 goto done
60
61:printWarning
62 echo ... FAILED
63 echo The %PROGNAME% cannot write to the log directory (!GSDLHOME!\collect).
64 echo Attempting to continue without permissions.
65 goto shiftElevated
66
67:deleteTempFile
68 echo ... OK
69 del "%GSDLHOME%\collect\testing.tmp"
70
71:shiftElevated
72:: Shift "Elevated" (one of our own internal command words) out of the way if present
73:: so the command-line is as it was when the user initiated the command
74 if "%1" == "Elevated" shift
75
76:: Make sure we're in the GLI folder, even if located outside a GS installation
77CD /D "%~dp0"
78
79:findPerl
80:: Now need to find Perl. If found, PERLPATH will be set
81call findperl.bat
82if "%PERLPATH%" == "" goto exit
83
84:: Need to find Java. If found, JAVA_EXECUTABLE will be set
85call findjava.bat
86if "%JAVA_EXECUTABLE%" == "" goto exit
87
88
89:checkGLI
90:: ---- Check that the GLI has been compiled ----
91if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
92if exist "GLI.jar" goto runGLI
93 echo.
94 if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
95 if "%GLILANG%" == "en" echo before running this script.
96
97 if "%GLILANG%" == "es" echo Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone
98 if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
99
100 if "%GLILANG%" == "fr" echo Vous devez compiler le Greenstone Interface (en utilisant makegli.bat)
101 if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
102
103 if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
104 if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
105 goto exit
106
107
108:runGLI
109
110if not "%_VERSION%" == "" (
111 echo Greenstone Major Version :
112 echo %_VERSION%
113 echo.
114)
115
116if not "%GSDL3SRCHOME%" == "" (
117 echo GSDL3SRCHOME:
118 echo !GSDL3SRCHOME!
119 echo.
120)
121
122if not "%GSDL3HOME%" == "" (
123 echo GSDL3HOME:
124 echo !GSDL3HOME!
125 echo.
126)
127
128if not "%GSDLHOME%" == "" (
129 echo GSDLHOME:
130 echo !GSDLHOME!
131 echo.
132)
133
134:: ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
135echo.
136if 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.
137echo.
138echo.
139if 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.
140echo.
141echo.
142
143
144:: ---- Finally, run the GLI ----
145if "%GLILANG%" == "en" echo Running the %PROGNAME%...
146if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
147if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
148if "%GLILANG%" == "ru" echo ’¥ªãéš© ¡š¡«š %PROGNAME%...
149
150:: -Xms32M To set minimum memory
151:: -Xmx32M To set maximum memory
152:: -verbose:gc To set garbage collection messages
153:: -Xincgc For incremental garbage collection
154:: -Xprof Function call profiling
155:: -Xloggc:<file> Write garbage collection log
156
157
158:: Run GS3 if version = 3
159:rungs3
160 if "%_VERSION%" == "3" "%JAVA_EXECUTABLE%" -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar;lib/rsyntaxtextarea.jar org.greenstone.gatherer.GathererProg -gsdl "%GSDLHOME%" -gsdlos %GSDLOS% -gsdl3 "%GSDL3HOME%" -gsdl3src "%GSDL3SRCHOME%" -perl "%PERLPATH%" %1 %2 %3 %4 %5 %6 %7 %8 %9
161 if ERRORLEVEL 2 (
162 goto rungs3
163 )
164 if "%_VERSION%" == "3" goto finRun
165
166:: Run GS2 since version is 2:
167:: if FLI is running, we don't want the local Greenstone library server running
168if "%PROGABBR%" == "FLI" goto webLib
169 :: Else we're running GLI, so we want the local Greenstone library server (if server.exe/gs2-web-server.bat exists, otherwise it will be webLib)
170 if not exist "%GSDLHOME%\server.exe" if not exist "%GSDLHOME%\gs2-web-server.bat" goto webLib
171
172:localLib
173 if exist "%GSDLHOME%\server.exe" (
174 set locallib=!GSDLHOME!\server.exe
175 ) else (
176 set locallib=!GSDLHOME!\gs2-web-server.bat
177 )
178
179 "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar;lib/rsyntaxtextarea.jar org.greenstone.gatherer.GathererProg -gsdl "%GSDLHOME%" -gsdlos %GSDLOS% -perl "%PERLPATH%" -local_library "%locallib%" %1 %2 %3 %4 %5 %6 %7 %8 %9
180 if ERRORLEVEL 2 (
181 goto localLib
182 )
183 goto finRun
184
185:webLib
186 "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/qfslib.jar;lib/rsyntaxtextarea.jar org.greenstone.gatherer.GathererProg -gsdl "%GSDLHOME%" -gsdlos %GSDLOS% -perl "%PERLPATH%" %1 %2 %3 %4 %5 %6 %7 %8 %9
187 if ERRORLEVEL 2 (
188 goto webLib
189 )
190 goto finRun
191
192:finRun
193 if "%GLILANG%" == "en" echo Done.
194 if "%GLILANG%" == "es" echo Hecho.
195 if "%GLILANG%" == "fr" echo Termin‚.
196 if "%GLILANG%" == "ru" echo ‚믮«­¥­®.
197 goto done
198
199
200:exit
201echo.
202pause
203color 07
204rem popd
205
206:done
207:: ---- Clean up ----
208set PERLPATH=
209set JAVA_EXECUTABLE=
210set GLIMODE=
211set PROGNAME=
212set PROGNAME_EN=
213set PROGFULLNAME=
214set PROGABBR=
215color 07
216rem popd
217cd "%startdir%"
218set startdir=
219
220endlocal
Note: See TracBrowser for help on using the repository browser.