[13235] | 1 | @echo off
|
---|
[13931] | 2 |
|
---|
[13235] | 3 | set SERVERLANG=en
|
---|
| 4 |
|
---|
[13553] | 5 | :: -------- Run the Greenstone 3 Server --------
|
---|
| 6 |
|
---|
[13235] | 7 | :: This script must be run from within the directory in which it lives
|
---|
| 8 | if exist gs3-server.bat goto start
|
---|
[13553] | 9 | if "%SERVERLANG%" == "en" echo This script must be run from the directory in which it resides.
|
---|
| 10 | if "%SERVERLANG%" == "es" echo Este gui¢n deber ejecutarse desde el directorio en el que reside.
|
---|
| 11 | if "%SERVERLANG%" == "fr" echo Ce script doit Ëtre exâcutâ ⊠partir du râpertoire dans lequel il se trouve.
|
---|
| 12 | if "%SERVERLANG%" == "ru" echo Ââ®â áªà š¯â €®«Š¥ ¡ëâì ¢§ïâ š§ €šà ¥ªâ®à šš, ¢ ª®â®à ®© ® à  á¯®«®Š¥Â
|
---|
[13235] | 13 | goto exit
|
---|
| 14 |
|
---|
[13553] | 15 | :start
|
---|
| 16 | if "%OS%" == "Windows_NT" goto findGSDL
|
---|
| 17 | :: Invoke a new command processor to ensure there's enough environment space
|
---|
| 18 | if "%1" == "Second" goto findGSDL
|
---|
| 19 | command /E:2048 /C %0 Second %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
| 20 | goto done
|
---|
| 21 |
|
---|
| 22 | :findGSDL
|
---|
[13235] | 23 | echo.
|
---|
[13553] | 24 | if "%SERVERLANG%" == "en" echo Greenstone3 Server
|
---|
| 25 | if "%SERVERLANG%" == "en" echo Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato
|
---|
| 26 | if "%SERVERLANG%" == "en" echo This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
|
---|
| 27 | if "%SERVERLANG%" == "en" echo This is free software, and you are welcome to redistribute it
|
---|
[13235] | 28 |
|
---|
| 29 | echo.
|
---|
[13553] | 30 | :: ---- Determine GSDL3HOME ----
|
---|
[13235] | 31 | set GSDL3PATH=
|
---|
| 32 |
|
---|
| 33 | :: Some users may set the above line manually
|
---|
[13553] | 34 | if not "%GSDL3PATH%" == "" goto prepGSDL
|
---|
[13235] | 35 |
|
---|
[13553] | 36 | :: The default location is the current directory
|
---|
| 37 | set GSDL3PATH=.
|
---|
[13235] | 38 |
|
---|
[13553] | 39 | :: If it is set, use the GSDLHOME environment variable
|
---|
| 40 | if "%GSDL3SRCHOME%" == "" goto prepGSDL
|
---|
| 41 | set GSDL3PATH=%GSDL3SRCHOME%
|
---|
[13235] | 42 |
|
---|
| 43 | :prepGSDL
|
---|
| 44 | :: Setup Greenstone, unless it has already been done
|
---|
| 45 | if not "%GSDL3SRCHOME%" == "" goto doneGSDL
|
---|
[13931] | 46 | call "%GSDL3PATH%\gs3-setup.bat" SetEnv > nul
|
---|
[13235] | 47 |
|
---|
| 48 | :doneGSDL
|
---|
| 49 | :: GSDL3PATH is no longer needed, since GSDL3SRCHOME should now be set
|
---|
| 50 | set GSDL3PATH=
|
---|
| 51 |
|
---|
[13553] | 52 | :findJava
|
---|
[13235] | 53 | :: ---- Check Java exists ----
|
---|
[13614] | 54 | set JAVAPATH=
|
---|
[13235] | 55 |
|
---|
| 56 | :: Some users may set the above line manually
|
---|
| 57 | if not "%JAVAPATH%" == "" goto testJava
|
---|
| 58 |
|
---|
[13553] | 59 | :: If it is set, use the JAVA_HOME environment variable
|
---|
| 60 | if not "%JAVA_HOME%" == "" goto javahome
|
---|
[13235] | 61 |
|
---|
[13553] | 62 | :: Check if Java is on the search path
|
---|
| 63 | echo %PATH%| winutil\which.exe java.exe | winutil\setvar.exe JAVAPATH > setjava.bat
|
---|
| 64 | call setjava.bat
|
---|
| 65 | del setjava.bat
|
---|
| 66 | if not "%JAVAPATH%" == "" goto testJava
|
---|
[13235] | 67 |
|
---|
| 68 | :: Still haven't found anything, so try looking in the registry (gulp!)
|
---|
| 69 | type nul > jdk.reg
|
---|
| 70 | regedit /E jdk.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit"
|
---|
| 71 | type jdk.reg > jdk.txt
|
---|
| 72 | del jdk.reg
|
---|
| 73 | type nul > jre.reg
|
---|
| 74 | regedit /E jre.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
|
---|
| 75 | type jre.reg > jre.txt
|
---|
| 76 | del jre.reg
|
---|
| 77 |
|
---|
| 78 | winutil\findjava.exe jdk.txt jre.txt | winutil\setvar.exe JAVAPATH > setjava.bat
|
---|
| 79 | del jdk.txt
|
---|
| 80 | del jre.txt
|
---|
| 81 | call setjava.bat
|
---|
| 82 | del setjava.bat
|
---|
| 83 |
|
---|
| 84 | :: If nothing was found in the registry, we're stuck
|
---|
[13931] | 85 | if "%JAVAPATH%" == "" goto noJava
|
---|
[13235] | 86 |
|
---|
[13931] | 87 | set JAVAPATH=%JAVAPATH%\bin
|
---|
| 88 | goto testJava
|
---|
[13235] | 89 |
|
---|
| 90 | :javahome
|
---|
| 91 | set JAVAPATH=%JAVA_HOME%\bin
|
---|
| 92 |
|
---|
| 93 | :testJava
|
---|
| 94 | :: Check that a Java executable has been found
|
---|
[13553] | 95 | if "%SERVERLANG%" == "en" echo Checking Java: %JAVAPATH%
|
---|
| 96 | if "%SERVERLANG%" == "es" echo Revisando Java: %JAVAPATH%
|
---|
| 97 | if "%SERVERLANG%" == "fr" echo Vârification de Java: %JAVAPATH%
|
---|
| 98 | if "%SERVERLANG%" == "ru" echo Âà ®¢¥à ª Java: %JAVAPATH%
|
---|
| 99 | if exist "%JAVAPATH%\java.exe" goto checkServer
|
---|
[13235] | 100 |
|
---|
| 101 | :noJava
|
---|
[13553] | 102 | echo.
|
---|
| 103 | if "%SERVERLANG%" == "en" echo Failed to locate an appropriate version of Java. You must install a
|
---|
| 104 | if "%SERVERLANG%" == "en" echo Java Runtime Environment (version 1.4 or greater) before running the
|
---|
| 105 | if "%SERVERLANG%" == "en" echo Greenstone3 Server.
|
---|
| 106 | goto exit
|
---|
[13235] | 107 |
|
---|
| 108 | :checkServer
|
---|
[13553] | 109 | ::---- Check that the server program has been compiled ----
|
---|
[13235] | 110 | if exist "server.jar" goto runServer
|
---|
[13553] | 111 | if "%SERVERLANG%" == "en" echo "You need to compile the code before running the server"
|
---|
[13235] | 112 | goto exit
|
---|
| 113 |
|
---|
| 114 | :runServer
|
---|
| 115 | echo Running the Greenstone Server
|
---|
| 116 | :: -Xms32M To set minimum memory
|
---|
| 117 | :: -Xmx32M To set maximum memory
|
---|
| 118 | :: -verbose:gc To set garbage collection messages
|
---|
| 119 | :: -Xincgc For incremental garbage collection
|
---|
| 120 | :: -Xprof Function call profiling
|
---|
| 121 | :: -Xloggc:<file> Write garbage collection log
|
---|
| 122 |
|
---|
[13619] | 123 | "%JAVAPATH%\java" -cp "%CLASSPATH%" org.greenstone.server.Server "%GSDL3SRCHOME%"
|
---|
[13235] | 124 |
|
---|
[13553] | 125 | :exit
|
---|
[13235] | 126 |
|
---|
[13553] | 127 | :done
|
---|
| 128 | :: ---- Clean up ----
|
---|
| 129 | set JAVAPATH=
|
---|
| 130 |
|
---|
[13235] | 131 | |
---|