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

Revision 31726, 9.0 KB (checked in by ak19, 3 years ago)

Fix to previous commit. The path to using build.properties is now conditional, so we don't do it when launching GLI for GS2

  • 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
50rem In a web-dispersed GS3 setup like in the labs, we don't require the Greenstone directory to be writable.
51rem If GS3, get the using.user.web property from build.properties and if set to true, we can skip to shiftElevated
52:: http://ss64.com/nt/syntax-substring.html
53    if "%_VERSION%" == "3" if exist "%GSDL3SRCHOME%\build.properties" for /F "usebackq tokens=1,2 delims==" %%G in ("%GSDL3SRCHOME%\build.properties") do (
54        if "%%G" == "using.user.web" if "%%H" == "true" goto :shiftElevated
55    )
56    echo.
57    echo Checking if the Greenstone collection directory is writable ...
58    (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\collect\testing.tmp" ) 2>nul
59    if exist "%GSDLHOME%\collect\testing.tmp" goto deleteTempFile
60    if "%1" == "Elevated" goto printWarning
61    echo ... FAILED
62    echo The %PROGNAME% cannot write to the collection directory (!GSDLHOME!\collect)
63    echo Requesting elevated status to become admin user to continue.
64    "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
65    goto done
66   
67:printWarning
68    echo ... FAILED
69    echo The %PROGNAME% cannot write to the log directory (!GSDLHOME!\collect).
70    echo Attempting to continue without permissions.
71    goto shiftElevated
72
73:deleteTempFile
74    echo ... OK
75    del "%GSDLHOME%\collect\testing.tmp"
76
77:shiftElevated
78:: Shift "Elevated" (one of our own internal command words) out of the way if present
79:: so the command-line is as it was when the user initiated the command
80    if "%1" == "Elevated" shift
81
82:: Make sure we're in the GLI folder, even if located outside a GS installation
83CD /D "%~dp0"
84
85:findPerl
86:: Now need to find Perl. If found, PERLPATH will be set
87call findperl.bat
88if "%PERLPATH%" == "" goto exit
89
90:: Need to find Java. If found, JAVA_EXECUTABLE will be set
91call findjava.bat
92if "%JAVA_EXECUTABLE%" == "" goto exit
93
94
95:checkGLI
96:: ---- Check that the GLI has been compiled ----
97if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
98if exist "GLI.jar" goto runGLI
99    echo.
100    if "%GLILANG%" == "en" echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
101    if "%GLILANG%" == "en" echo before running this script.
102
103    if "%GLILANG%" == "es" echo Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone
104    if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
105
106    if "%GLILANG%" == "fr" echo Vous devez compiler le Greenstone Interface (en utilisant makegli.bat)
107    if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
108
109    if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì ¡š¡«š®â¥ç­ë© š­â¥à䥩á Greenstone (šá¯®«ì§ãï makegli.bat)
110    if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
111    goto exit
112
113
114:runGLI
115
116if not "%_VERSION%" == "" (
117  echo Greenstone Major Version :
118  echo %_VERSION%
119    echo.
120)
121
122if not "%GSDL3SRCHOME%" == "" (
123    echo GSDL3SRCHOME:
124    echo !GSDL3SRCHOME!
125    echo.
126)
127
128if not "%GSDL3HOME%" == "" (
129    echo GSDL3HOME:
130    echo !GSDL3HOME!
131    echo.
132)
133
134if not "%GSDLHOME%" == "" (
135    echo GSDLHOME:
136    echo !GSDLHOME!
137    echo.
138)
139
140:: ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
141echo.
142if 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.
143echo.
144echo.
145if 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.
146echo.
147echo.
148
149
150:: ---- Finally, run the GLI ----
151if "%GLILANG%" == "en" echo Running the %PROGNAME%...
152if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
153if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
154if "%GLILANG%" == "ru" echo ’¥ªãéš© ¡š¡«š %PROGNAME%...
155
156:: -Xms32M          To set minimum memory
157:: -Xmx32M          To set maximum memory
158:: -verbose:gc      To set garbage collection messages
159:: -Xincgc          For incremental garbage collection
160:: -Xprof           Function call profiling
161:: -Xloggc:<file>   Write garbage collection log
162
163
164:: Run GS3 if version = 3
165:rungs3
166    rem In a web-dispersed GS3 set up like in the labs, gsdl3home.isreadonly would be true and
167    rem we need to run the web server in read-only mode. This section of code borrowed from gs3-server.bat.
168    if "%_VERSION%" == "3" for /F "usebackq tokens=1,2 delims==" %%G in ("%GSDL3SRCHOME%\build.properties") do (
169        if "%%G"=="gsdl3home.isreadonly" if "%%H" == "true" (
170            set gsdl3_writablehome=%TMP%\greenstone\web
171            :: not used
172            set opt_properties="-Dgsdl3home.isreadonly=true" -Dgsdl3.writablehome="%gsdl3_writablehome%"
173            echo Setting Greenstone3 web home writable area to be: %gsdl3_writablehome%
174            pushd "%GSDL3SRCHOME%"
175            :: passing opt_properties is no longer necessary because ant.bat is unmodified (doesn't make use of it)
176            :: and because build.xml already contains the properties with the correct values
177            cmd /c ant.bat %opt_properties% configure-web
178            popd
179        )
180    )
181
182    if "%_VERSION%" == "3" "%JAVA_EXECUTABLE%" -cp classes/;GLI.jar;lib/apache.jar;lib/jna.jar;lib/jna-platform.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
183    if ERRORLEVEL 2 (
184        goto rungs3
185    )
186    if "%_VERSION%" == "3" goto finRun
187
188:: Run GS2 since version is 2:
189:: if FLI is running, we don't want the local Greenstone library server running
190if "%PROGABBR%" == "FLI" goto webLib
191    :: 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)
192    if not exist "%GSDLHOME%\server.exe" if not exist "%GSDLHOME%\gs2-web-server.bat" goto webLib
193
194:localLib
195    if exist "%GSDLHOME%\server.exe" (
196    set locallib=!GSDLHOME!\server.exe
197    ) else (
198    set locallib=!GSDLHOME!\gs2-web-server.bat
199    )
200
201    "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/jna.jar;lib/jna-platform.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
202    if ERRORLEVEL 2 (
203        goto localLib
204    )
205    goto finRun
206
207:webLib
208    "%JAVA_EXECUTABLE%" -Xmx128M -cp classes/;GLI.jar;lib/apache.jar;lib/jna.jar;lib/jna-platform.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
209    if ERRORLEVEL 2 (
210        goto webLib
211    )
212    goto finRun
213
214:finRun
215    if "%GLILANG%" == "en" echo Done.
216    if "%GLILANG%" == "es" echo Hecho.
217    if "%GLILANG%" == "fr" echo Termin‚.
218    if "%GLILANG%" == "ru" echo ‚믮«­¥­®.
219    goto done
220
221
222:exit
223echo.
224pause
225color 07
226rem popd
227
228:done
229:: ---- Clean up ----
230set PERLPATH=
231set JAVA_EXECUTABLE=
232set GLIMODE=
233set PROGNAME=
234set PROGNAME_EN=
235set PROGFULLNAME=
236set PROGABBR=
237color 07
238rem popd
239cd "%startdir%"
240set startdir=
241
242endlocal
Note: See TracBrowser for help on using the browser.