@echo off :: -------- Run the Greenstone Librarian Interface -------- :: This script must be run from within the directory in which it lives if exist gli.bat goto start echo This script must be run from the directory in which it resides. goto exit :start if "%OS%" == "Windows_NT" goto findGSDL :: Invoke a new command processor to ensure there's enough environment space if "%1" == "Second" goto findGSDL command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9 goto done :findGSDL :: ---- Determine GSDLHOME ---- set GSDLPATH= :: Some users may set the above line manually if not "%GSDLPATH%" == "" goto testGSDL :: The default location for the GLI is a subdirectory of Greenstone set GSDLPATH=.. :: If it is set, use the GSDLHOME environment variable if "%GSDLHOME%" == "" goto testGSDL set GSDLPATH=%GSDLHOME% :testGSDL :: Check that the Greenstone installation looks OK echo Checking GSDL: %GSDLPATH% if exist "%GSDLPATH%\setup.bat" goto prepGSDL echo. echo The Greenstone installation could not be found, or is incomplete. echo Try reinstalling Greenstone then running this script again. goto exit :prepGSDL :: Setup Greenstone, unless it has already been done if not "%GSDLHOME%" == "" goto doneGSDL call "%GSDLPATH%\setup.bat" SetEnv > nul :doneGSDL :: GSDLPATH is no longer needed, since GSDLHOME should now be set set GSDLPATH= :findPerl :: ---- Check Perl exists ---- set PERLPATH= :: Some users may set the above line manually if not "%PERLPATH%" == "" goto testPerl :: Check if Perl is on the search path echo %PATH%| winutil\which perl.exe | winutil\setvar PERLPATH > setperl.bat call setperl.bat del setperl.bat if not "%PERLPATH%" == "" goto testPerl :: If not, try GSDLHOME\bin\windows\perl\bin if exist "%GSDLHOME%\bin\windows\perl\bin\perl.exe" goto gsdlPerl :: Still haven't found anything, so try looking in the registry (gulp!) type nul > perl.reg regedit /E perl.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Perl" type perl.reg > perl.txt del perl.reg winutil\findperl perl.txt | winutil\setvar PERLPATH > setperl.bat del perl.txt call setperl.bat del setperl.bat :: If nothing was found in the registry, we're stuck if "%PERLPATH%" == "" goto noPerl goto testPerl :gsdlPerl set PERLPATH=%GSDLHOME%\bin\windows\perl\bin :testPerl :: Check that a Perl executable has been found echo Checking Perl: %PERLPATH% if exist "%PERLPATH%\perl.exe" goto findJava :noPerl echo. echo The Greenstone Librarian Interface requires perl in order to operate, echo but perl could not be detected on your system. Please ensure that perl echo is installed and is on your search path, then rerun this script. goto exit :findJava :: ---- Check Java exists ---- set JAVAPATH= :: Some users may set the above line manually if not "%JAVAPATH%" == "" goto testJava :: If it is set, use the JAVAHOME environment variable if not "%JAVAHOME%" == "" goto javahome :: Check if Java is on the search path echo %PATH%| winutil\which java.exe | winutil\setvar JAVAPATH > setjava.bat call setjava.bat del setjava.bat if not "%JAVAPATH%" == "" goto testJava :: Still haven't found anything, so try looking in the registry (gulp!) type nul > jdk.reg regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit" type jdk.reg > jdk.txt del jdk.reg type nul > jre.reg regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" type jre.reg > jre.txt del jre.reg winutil\findjava jdk.txt jre.txt | winutil\setvar JAVAPATH > setjava.bat del jdk.txt del jre.txt call setjava.bat del setjava.bat :: If nothing was found in the registry, we're stuck if "%JAVAPATH%" == "" goto noJava set JAVAPATH=%JAVAPATH%\bin goto testJava :javahome set JAVAPATH=%JAVAHOME%\bin :testJava :: Check that a Java executable has been found echo Checking Java: %JAVAPATH% if exist "%JAVAPATH%\java.exe" goto checkGLI :noJava echo. echo Failed to locate an appropriate version of Java. You must install a echo Java Runtime Environment (version 1.4 or greater) before running the echo Greenstone Librarian Interface. goto exit :checkGLI :: ---- Check that the GLI has been compiled ---- if exist "classes/org/greenstone/gatherer/Gatherer.class" goto runGLI echo. echo You need to compile the Greenstone Librarian Interface (using makegli.bat) echo before running this script. goto exit :runGLI :: ---- Finally, run the GLI ---- echo. echo Running the Greenstone Librarian Interface... :: -Xms32M To set minimum memory :: -Xmx32M To set maximum memory :: -verbose:gc To set garbage collection messages :: -Xincgc For incremental garbage collection :: -Xprof Function call profiling :: -Xloggc: Write garbage collection log "%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 echo Done! :exit echo. pause :: ---- Clean up ---- set PERLPATH= set JAVAPATH= :done