root/main/trunk/gli/gli.bat @ 24829

Revision 24829, 7.4 KB (checked in by ak19, 8 years ago)

Changes to bat files and perl code to deal with brackets in (Windows) filepath. Also checked winmake.bat files to see if changes were needed there. These changes go together with the commits 24826 to 24828 for gems.bat, and commit 24820 on makegs2.bat.

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