root/main/trunk/gli/gems.bat @ 31722

Revision 30592, 5.6 KB (checked in by ak19, 3 years ago)

Further changes to make sure recent updates to batch scripts still protect spaces in filepath

  • Property svn:executable set to *
Line 
1@echo off
2setlocal enabledelayedexpansion
3
4color 0A
5pushd "%CD%"
6CD /D "%~dp0"
7set GLILANG=en
8
9
10::  -------- Run the Greenstone Librarian Interface --------
11
12:: This script must be run from within the directory in which it lives
13if exist gems.bat goto start
14    if "%GLILANG%" == "en" echo This script must be run from the directory in which it resides.
15    if "%GLILANG%" == "es" echo Este gui¢n deber  ejecutarse desde el directorio en el que reside.
16    if "%GLILANG%" == "fr" echo Ce script doit ˆtre ex‚cut‚ … partir du r‚pertoire dans lequel il se trouve.
17    if "%GLILANG%" == "ru" echo â®â áªàš¯â €®«Š¥­ ¡ëâì ¢§ïâ š§ €šà¥ªâ®àšš, ¢ ª®â®à®© ®­ à á¯®«®Š¥­
18    goto exit
19
20:start
21if "%OS%" == "Windows_NT" goto progName
22    :: Invoke a new command processor to ensure there's enough environment space
23    if "%1" == "Second" goto progName
24        command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
25        shift
26        goto done
27
28
29:progName
30if "%GLILANG%" == "es" set PROGNAME=Editar conjuntos de metadatos
31if "%GLILANG%" == "fr" set PROGNAME=Editer les jeux de méta-données
32if "%GLILANG%" == "ru" set PROGNAME=Ðåäàêòèðîâàòü íàáîðû ìåòàäàííûõ
33:: if the PROGNAME is still not set, then set the language to English
34if "%PROGNAME%" == "" set PROGNAME=Greenstone Editor for Metadata Sets
35
36if "%PROGABBR%" == "" set PROGABBR=GEMS
37if "%PROGNAME_EN%" == "" set PROGNAME_EN=Greenstone Editor for Metadata Sets
38
39:: Now need to work out the _VERSION, GSDLHOME (and if GS3, then GSDL3SRCHOME and GSDL3HOME)
40:findGSDL
41call findgsdl.bat
42if "%GSDLHOME%" == "" goto exit
43
44:checkUserPermissions
45
46rem In a web-dispersed GS3 setup like in the labs, we don't require the Greenstone directory to be writable.
47rem If GS3, get the using.user.web property from build.properties and if set to true, we can skip to shiftElevated
48:: http://ss64.com/nt/syntax-substring.html
49    if "%_VERSION%" == "3" if exist "%GSDL3SRCHOME%\build.properties" for /F "usebackq tokens=1,2 delims==" %%G in ("%GSDL3SRCHOME%\build.properties") do (
50        if "%%G" == "using.user.web" if "%%H" == "true" goto :shiftElevated
51    )
52
53    echo.
54    echo Checking if the Greenstone collection directory is writable ...
55    (echo This is a temporary file. It is safe to delete it. > "!GSDLHOME!\collect\testing.tmp" ) 2>nul
56    if exist "%GSDLHOME%\collect\testing.tmp" goto deleteTempFile
57    if "%1" == "Elevated" goto printWarning
58    echo ... FAILED
59    echo The %PROGNAME% cannot write to the collection directory (!GSDLHOME!\collect)
60    echo Requesting elevated status to become admin user to continue.
61    "%GSDLHOME%\bin\windows\gstart.exe" %0 Elevated %1 %2 %3 %4 %5 %6 %7 %8 %9
62    goto done
63   
64:printWarning
65    echo ... FAILED
66    echo The %PROGNAME% cannot write to the log directory (!GSDLHOME!\collect).
67    echo Attempting to continue without permissions.
68    goto shiftElevated
69
70:deleteTempFile
71    echo ... OK
72    del "%GSDLHOME%\collect\testing.tmp"
73
74:shiftElevated
75:: Shift "Elevated" (one of our own internal command words) out of the way if present
76:: so the command-line is as it was when the user initiated the command
77    if "%1" == "Elevated" shift
78
79:: Need to find Java. If found, JAVA_EXECUTABLE will be set
80call findjava.bat
81if "%JAVA_EXECUTABLE%" == "" goto exit
82
83
84:chkGEMS
85:: ---- Check that the GEMS has been compiled ----
86if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGEMS
87if exist "GLI.jar" goto runGEMS
88    echo.
89    if "%GLILANG%" == "en" echo You need to compile the %PROGNAME% (using makegli.bat)
90    if "%GLILANG%" == "en" echo before running this script.
91
92    if "%GLILANG%" == "es" echo Usted necesita compilar la %PROGNAME%
93    if "%GLILANG%" == "es" echo (por medio de makegli.bat) antes de ejecutar este gui¢n.
94
95    if "%GLILANG%" == "fr" echo Vous devez compiler le %PROGNAME% (en utilisant makegli.bat)
96    if "%GLILANG%" == "fr" echo avant d'ex‚cuter ce script.
97
98    if "%GLILANG%" == "ru" echo ‚ë €®«Š­ë ª®¬¯š«šà®¢ âì %PROGNAME% (šá¯®«ì§ãï makegli.bat)
99    if "%GLILANG%" == "ru" echo ¯¥à¥€ ¢¢®€®¬ í⮣® áªàš¯â 
100    goto exit
101
102
103:runGEMS
104if not "%_VERSION%" == "" (
105    echo Greenstone Major Version:
106    echo %_VERSION%
107    echo.
108)
109
110if not "%GSDL3SRCHOME%" == "" (
111    echo GSDL3SRCHOME:
112    echo !GSDL3SRCHOME!
113    echo.
114)
115
116if not "%GSDL3HOME%" == "" (
117    echo GSDL3HOME:
118    echo !GSDL3HOME!
119    echo.
120)
121
122if not "%GSDLHOME%" == "" (
123    echo GSDLHOME:
124    echo !GSDLHOME!
125    echo.
126)
127
128:: ---- Finally, run the GEMS ----
129if "%GLILANG%" == "en" echo Running the %PROGNAME%...
130if "%GLILANG%" == "es" echo Ejecutando la %PROGNAME%...
131if "%GLILANG%" == "fr" echo Ex‚cution de %PROGNAME%
132if "%GLILANG%" == "ru" echo ’¥ªãéš© %PROGNAME%...
133
134:: -Xms32M          To set minimum memory
135:: -Xmx32M          To set maximum memory
136:: -verbose:gc      To set garbage collection messages
137:: -Xincgc          For incremental garbage collection
138:: -Xprof           Function call profiling
139:: -Xloggc:<file>   Write garbage collection log
140
141
142:: Run GS3 if version = 3
143if "%_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
144if "%_VERSION%" == "3" goto finRun
145
146    :: Else run GS2 since version is 2:
147    "%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
148
149:finRun
150    if "%GLILANG%" == "en" echo Done!
151    if "%GLILANG%" == "es" echo ­Hecho!
152    if "%GLILANG%" == "fr" echo Termin‚!
153    if "%GLILANG%" == "ru" echo ‚믮«­¥­®!
154    goto done
155
156
157:exit
158echo.
159pause
160color 07
161popd
162:done
163:: ---- Clean up ----
164set JAVAPATH=
165set JAVA_EXECUTABLE=
166color 07
167popd
168
169endlocal
Note: See TracBrowser for help on using the browser.