1 | @echo off
|
---|
2 |
|
---|
3 | :: -------- Run the Greenstone Librarian Interface --------
|
---|
4 |
|
---|
5 | :: This script must be run from within the directory in which it lives
|
---|
6 | if exist gli.bat goto start
|
---|
7 | echo This script must be run from the directory in which it resides.
|
---|
8 | goto exit
|
---|
9 |
|
---|
10 | :start
|
---|
11 | if "%OS%" == "Windows_NT" goto findGSDL
|
---|
12 | :: Invoke a new command processor to ensure there's enough environment space
|
---|
13 | if "%1" == "Second" goto findGSDL
|
---|
14 | command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
15 | goto done
|
---|
16 |
|
---|
17 | echo.
|
---|
18 | echo Greenstone Librarian Interface (GLI)
|
---|
19 | echo Copyright (C) 2003 New Zealand Digital Library Project, University Of Waikato
|
---|
20 | echo GLI comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
|
---|
21 | echo This is free software, and you are welcome to redistribute it
|
---|
22 | echo.
|
---|
23 |
|
---|
24 | :findGSDL
|
---|
25 | :: ---- Determine GSDLHOME ----
|
---|
26 | set GSDLPATH=
|
---|
27 |
|
---|
28 | :: Some users may set the above line manually
|
---|
29 | if not "%GSDLPATH%" == "" goto testGSDL
|
---|
30 |
|
---|
31 | :: The default location for the GLI is a subdirectory of Greenstone
|
---|
32 | set GSDLPATH=..
|
---|
33 |
|
---|
34 | :: If it is set, use the GSDLHOME environment variable
|
---|
35 | if "%GSDLHOME%" == "" goto testGSDL
|
---|
36 | set GSDLPATH=%GSDLHOME%
|
---|
37 |
|
---|
38 | :testGSDL
|
---|
39 | :: Check that the Greenstone installation looks OK
|
---|
40 | echo Checking GSDL: %GSDLPATH%
|
---|
41 | if exist "%GSDLPATH%\setup.bat" goto prepGSDL
|
---|
42 | echo.
|
---|
43 | echo The Greenstone installation could not be found, or is incomplete.
|
---|
44 | echo Try reinstalling Greenstone then running this script again.
|
---|
45 | goto exit
|
---|
46 |
|
---|
47 | :prepGSDL
|
---|
48 | :: Setup Greenstone, unless it has already been done
|
---|
49 | if not "%GSDLHOME%" == "" goto doneGSDL
|
---|
50 | call "%GSDLPATH%\setup.bat" SetEnv > nul
|
---|
51 |
|
---|
52 | :doneGSDL
|
---|
53 | :: GSDLPATH is no longer needed, since GSDLHOME should now be set
|
---|
54 | set GSDLPATH=
|
---|
55 |
|
---|
56 |
|
---|
57 | :findPerl
|
---|
58 | :: ---- Check Perl exists ----
|
---|
59 | set PERLPATH=
|
---|
60 |
|
---|
61 | :: Some users may set the above line manually
|
---|
62 | if not "%PERLPATH%" == "" goto testPerl
|
---|
63 |
|
---|
64 | :: Check if Perl is on the search path
|
---|
65 | echo %PATH%| winutil\which.exe perl.exe | winutil\setvar.exe PERLPATH > setperl.bat
|
---|
66 | call setperl.bat
|
---|
67 | del setperl.bat
|
---|
68 | if not "%PERLPATH%" == "" goto testPerl
|
---|
69 |
|
---|
70 | :: If not, try GSDLHOME\bin\windows\perl\bin
|
---|
71 | if exist "%GSDLHOME%\bin\windows\perl\bin\perl.exe" goto gsdlPerl
|
---|
72 |
|
---|
73 | :: Still haven't found anything, so try looking in the registry (gulp!)
|
---|
74 | type nul > perl.reg
|
---|
75 | regedit /E perl.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Perl"
|
---|
76 | type perl.reg > perl.txt
|
---|
77 | del perl.reg
|
---|
78 |
|
---|
79 | winutil\findperl.exe perl.txt | winutil\setvar.exe PERLPATH > setperl.bat
|
---|
80 | del perl.txt
|
---|
81 | call setperl.bat
|
---|
82 | del setperl.bat
|
---|
83 |
|
---|
84 | :: If nothing was found in the registry, we're stuck
|
---|
85 | if "%PERLPATH%" == "" goto noPerl
|
---|
86 |
|
---|
87 | goto testPerl
|
---|
88 |
|
---|
89 | :gsdlPerl
|
---|
90 | set PERLPATH=%GSDLHOME%\bin\windows\perl\bin
|
---|
91 |
|
---|
92 | :testPerl
|
---|
93 | :: Check that a Perl executable has been found
|
---|
94 | echo Checking Perl: %PERLPATH%
|
---|
95 | if exist "%PERLPATH%\perl.exe" goto findJava
|
---|
96 |
|
---|
97 | :noPerl
|
---|
98 | echo.
|
---|
99 | echo The Greenstone Librarian Interface requires perl in order to operate,
|
---|
100 | echo but perl could not be detected on your system. Please ensure that perl
|
---|
101 | echo is installed and is on your search path, then rerun this script.
|
---|
102 | goto exit
|
---|
103 |
|
---|
104 |
|
---|
105 | :findJava
|
---|
106 | :: ---- Check Java exists ----
|
---|
107 | set JAVAPATH=
|
---|
108 |
|
---|
109 | :: Some users may set the above line manually
|
---|
110 | if not "%JAVAPATH%" == "" goto testJava
|
---|
111 |
|
---|
112 | :: If it is set, use the JAVA_HOME environment variable
|
---|
113 | if not "%JAVA_HOME%" == "" goto javahome
|
---|
114 |
|
---|
115 | :: Check if Java is on the search path
|
---|
116 | echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
|
---|
117 | call setjava.bat
|
---|
118 | del setjava.bat
|
---|
119 | if not "%JAVAPATH%" == "" goto testJava
|
---|
120 |
|
---|
121 | :: Still haven't found anything, so try looking in the registry (gulp!)
|
---|
122 | type nul > jdk.reg
|
---|
123 | regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
|
---|
124 | type jdk.reg > jdk.txt
|
---|
125 | del jdk.reg
|
---|
126 | type nul > jre.reg
|
---|
127 | regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
|
---|
128 | type jre.reg > jre.txt
|
---|
129 | del jre.reg
|
---|
130 |
|
---|
131 | winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
|
---|
132 | del jdk.txt
|
---|
133 | del jre.txt
|
---|
134 | call setjava.bat
|
---|
135 | del setjava.bat
|
---|
136 |
|
---|
137 | :: If nothing was found in the registry, we're stuck
|
---|
138 | if "%JAVAPATH%" == "" goto noJava
|
---|
139 |
|
---|
140 | set JAVAPATH=%JAVAPATH%\bin
|
---|
141 | goto testJava
|
---|
142 |
|
---|
143 | :javahome
|
---|
144 | set JAVAPATH=%JAVA_HOME%\bin
|
---|
145 |
|
---|
146 | :testJava
|
---|
147 | :: Check that a Java executable has been found
|
---|
148 | echo Checking Java: %JAVAPATH%
|
---|
149 | if exist "%JAVAPATH%\java.exe" goto checkGLI
|
---|
150 |
|
---|
151 | :noJava
|
---|
152 | echo.
|
---|
153 | echo Failed to locate an appropriate version of Java. You must install a
|
---|
154 | echo Java Runtime Environment (version 1.4 or greater) before running the
|
---|
155 | echo Greenstone Librarian Interface.
|
---|
156 | goto exit
|
---|
157 |
|
---|
158 |
|
---|
159 | :checkGLI
|
---|
160 | :: ---- Check that the GLI has been compiled ----
|
---|
161 | if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI
|
---|
162 | if exist "GLI.jar" goto runGLI
|
---|
163 | echo.
|
---|
164 | echo You need to compile the Greenstone Librarian Interface (using makegli.bat)
|
---|
165 | echo before running this script.
|
---|
166 | goto exit
|
---|
167 |
|
---|
168 |
|
---|
169 | :runGLI
|
---|
170 | :: ---- Finally, run the GLI ----
|
---|
171 | echo.
|
---|
172 | echo Running the Greenstone Librarian Interface...
|
---|
173 |
|
---|
174 | :: -Xms32M To set minimum memory
|
---|
175 | :: -Xmx32M To set maximum memory
|
---|
176 | :: -verbose:gc To set garbage collection messages
|
---|
177 | :: -Xincgc For incremental garbage collection
|
---|
178 | :: -Xprof Function call profiling
|
---|
179 | :: -Xloggc:<file> Write garbage collection log
|
---|
180 |
|
---|
181 | if exist "%GSDLHOME%\server.exe" goto localLib
|
---|
182 | "%JAVAPATH%\java" -cp classes/;GLI.jar;lib/apache.jar;lib/calpa.jar;lib/jp.jar;lib/polloxml.jar;lib/qfslib.jar;lib/skinlf.jar;lib/nanoxml.jar org.greenstone.gatherer.Gatherer -gsdl %GSDLHOME% -perl %PERLPATH% %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
183 |
|
---|
184 | echo Done!
|
---|
185 | goto done
|
---|
186 |
|
---|
187 | :localLib
|
---|
188 | "%JAVAPATH%\java" -cp classes/;GLI.jar;lib/apache.jar;lib/calpa.jar;lib/jp.jar;lib/polloxml.jar;lib/qfslib.jar;lib/skinlf.jar;lib/nanoxml.jar org.greenstone.gatherer.Gatherer -gsdl %GSDLHOME% -perl %PERLPATH% -library %GSDLHOME%\server.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
189 |
|
---|
190 | echo Done!
|
---|
191 | goto done
|
---|
192 |
|
---|
193 | :exit
|
---|
194 | echo.
|
---|
195 | pause
|
---|
196 |
|
---|
197 | :done
|
---|
198 | :: ---- Clean up ----
|
---|
199 | set PERLPATH=
|
---|
200 | set JAVAPATH=
|
---|