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