[5824] | 1 | @echo off
|
---|
| 2 |
|
---|
[6211] | 3 | echo Greenstone Librarian Interface (GLI)
|
---|
| 4 | echo Copyright (C) 2002 Greenstone Digital Libraries, University Of Waikato
|
---|
| 5 | echo GLI comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
|
---|
| 6 | echo This is free software, and you are welcome to redistribute it
|
---|
[6223] | 7 | echo.
|
---|
[5824] | 8 |
|
---|
| 9 | :: -------- Run the Greenstone Librarian Interface --------
|
---|
| 10 |
|
---|
| 11 | :: This script must be run from within the directory in which it lives
|
---|
| 12 | if exist gli.bat goto start
|
---|
| 13 | echo This script must be run from the directory in which it resides.
|
---|
| 14 | goto exit
|
---|
| 15 |
|
---|
| 16 | :start
|
---|
| 17 | if "%OS%" == "Windows_NT" goto findGSDL
|
---|
| 18 | :: Invoke a new command processor to ensure there's enough environment space
|
---|
| 19 | if "%1" == "Second" goto findGSDL
|
---|
| 20 | command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
| 21 | goto done
|
---|
| 22 |
|
---|
| 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 JAVAHOME environment variable
|
---|
| 113 | if not "%JAVAHOME%" == "" 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=%JAVAHOME%\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!
|
---|
[5927] | 185 | goto done
|
---|
[5824] | 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!
|
---|
[5927] | 191 | goto done
|
---|
[5824] | 192 |
|
---|
| 193 | :exit
|
---|
| 194 | echo.
|
---|
| 195 | pause
|
---|
| 196 |
|
---|
[5927] | 197 | :done
|
---|
[5824] | 198 | :: ---- Clean up ----
|
---|
| 199 | set PERLPATH=
|
---|
| 200 | set JAVAPATH=
|
---|