[20391] | 1 | @echo off
|
---|
| 2 | SETLOCAL
|
---|
| 3 |
|
---|
| 4 | set serverlang=en
|
---|
| 5 | set java_min_version=1.4.0_00
|
---|
| 6 | set PROGNAME="gs2-server"
|
---|
| 7 | pushd "%CD%"
|
---|
| 8 | CD /D "%~dp0"
|
---|
| 9 |
|
---|
| 10 | echo Greenstone 2 Server
|
---|
| 11 | echo Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato
|
---|
| 12 | echo This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
|
---|
| 13 | echo This is free software, and you are welcome to redistribute it
|
---|
| 14 |
|
---|
| 15 | :: -------- Run the Greenstone 2 Server --------
|
---|
| 16 |
|
---|
| 17 | :: ---- Determine GSDLHOME ----
|
---|
| 18 | set gsdl2path=
|
---|
| 19 |
|
---|
| 20 | :: Some users may set the above line manually
|
---|
| 21 | if "%gsdl2path%" == "" (
|
---|
| 22 | set GSDLHOME=%CD%
|
---|
| 23 | set gsdl2path=%CD%
|
---|
| 24 | )
|
---|
| 25 | echo GS2 Home: %GSDLHOME%
|
---|
| 26 |
|
---|
| 27 | ::goto autoset_gsdl_home %gsdl2path%
|
---|
| 28 |
|
---|
| 29 | :: Setup Greenstone2, unless it has already been done
|
---|
| 30 | if "%GSDLHOME%" == "" (
|
---|
| 31 | pushd "%GSDLHOME%"
|
---|
| 32 | call setup.bat
|
---|
| 33 | popd
|
---|
| 34 | )
|
---|
| 35 |
|
---|
| 36 |
|
---|
| 37 | :: First test that there is actually something that can be run...
|
---|
| 38 | :: Exit if the apache-httpd folder doesn't exist for some reason
|
---|
| 39 | :: (The errors reported when the apache webserver does not exist
|
---|
| 40 | :: in the correct location are not at all helpful).
|
---|
| 41 |
|
---|
| 42 | :: "You cannot use the if command to test directly for a directory, but
|
---|
| 43 | :: the null (NUL) device does exist in every directory. As a result, you
|
---|
| 44 | :: can test for the null device to determine whether a directory exists."
|
---|
| 45 | ::echo %GSDLHOME%\apache-httpd\nul
|
---|
| 46 | if not exist %GSDLHOME%\apache-httpd\nul (
|
---|
| 47 | echo.
|
---|
| 48 | echo UNABLE TO CONTINUE: There is no apache-httpd directory.
|
---|
| 49 | echo It does not look like the local apache webserver has been installed.
|
---|
| 50 | echo Exiting...
|
---|
| 51 | echo.
|
---|
| 52 | goto exit
|
---|
| 53 | )
|
---|
| 54 | :: exit 1
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | :: If there's no llssite.cfg file, copy from the template
|
---|
| 58 | if exist "%GSDLHOME%\llssite.cfg" goto cfgfile
|
---|
| 59 | if exist "%GSDLHOME%\llssite.cfg.in" (
|
---|
| 60 | copy "%GSDLHOME%\llssite.cfg.in" "%GSDLHOME%\llssite.cfg"
|
---|
| 61 | ) else (
|
---|
| 62 | echo Warning: could not find llssite.cfg.in to create llssite.cfg from.
|
---|
| 63 | )
|
---|
| 64 |
|
---|
| 65 | :cfgfile
|
---|
| 66 | :: ---- Determine GSDLHOME ----
|
---|
| 67 | :: JRE_HOME or JAVA_HOME must be set correctly to run this program
|
---|
| 68 | bin\windows\search4j -m %java_min_version% > nul
|
---|
| 69 | echo.
|
---|
| 70 | :: In Java code, '...getResourceAsStream("build.properties")'
|
---|
| 71 | :: needs up to be in the right directory when run
|
---|
| 72 | if %ERRORLEVEL% equ 0 pushd %GSDL2PATH%
|
---|
| 73 |
|
---|
| 74 | :: http://ss64.com/nt/call.html (and leave in trailing slash)
|
---|
| 75 | call :isinpath %GSDLHOME%\lib\java
|
---|
| 76 |
|
---|
| 77 | :: After the call, we come back here
|
---|
| 78 | goto chkjava
|
---|
| 79 |
|
---|
| 80 | :isinpath
|
---|
[20392] | 81 | :: http://ss64.com/nt/syntax-replace.html and http://ss64.com/nt/syntax-args.html
|
---|
| 82 | :: (Does not work: section "Finding items within the PATH environment variable")
|
---|
[20391] | 83 | :: Instead, we expand the filepath of parameter 1 to its full path and
|
---|
| 84 | :: try to subtract it from the classpath.
|
---|
[20392] | 85 | ::call set test_cpath=%%CLASSPATH:%~f1=%%
|
---|
| 86 | call set test_cpath=%%CLASSPATH:%1=%%
|
---|
[20391] | 87 |
|
---|
| 88 | :: If there IS a difference in the classpath before and after,
|
---|
| 89 | :: then the filepath was already on the classpath
|
---|
| 90 | if not "%CLASSPATH%" == "%test_cpath%" (
|
---|
| 91 | echo - CLASSPATH already correct
|
---|
| 92 | echo %CLASSPATH%
|
---|
| 93 | goto :eof
|
---|
| 94 | )
|
---|
| 95 |
|
---|
| 96 | :: If there was NO difference in the classpath before and after,
|
---|
| 97 | :: then the filepath needs to be added to the classpath
|
---|
| 98 | set CLASSPATH=%GSDLHOME%\lib\java;%CLASSPATH%
|
---|
| 99 |
|
---|
[20392] | 100 | :: http://ss64.com/nt/for_r.html and (for call) http://ss64.com/nt/for.html
|
---|
[20391] | 101 | :: http://ss64.com/nt/syntax-args.html
|
---|
| 102 | FOR /R "%GSDLHOME%\lib\java" %%G IN (*.jar) DO call :putinpath %%G
|
---|
| 103 | echo - Adjusted CLASSPATH
|
---|
| 104 | echo.
|
---|
| 105 | ::echo CLASSPATH:& echo %CLASSPATH%
|
---|
| 106 | goto :eof
|
---|
| 107 |
|
---|
| 108 |
|
---|
| 109 | :putinpath
|
---|
| 110 | echo jarfile: %1
|
---|
| 111 | set CLASSPATH=%CLASSPATH%;%1
|
---|
| 112 | goto :eof
|
---|
| 113 |
|
---|
| 114 | :: ---- Check Java ----
|
---|
| 115 | :chkjava
|
---|
| 116 | :: call the script with source, so that we have the variables it sets ($javapath)
|
---|
| 117 | set exit_status=0
|
---|
| 118 | :: Need to find Java. If found, JAVA_EXECUTABLE will be set
|
---|
| 119 | :: call findjava.bat %serverlang% %PROGNAME%
|
---|
| 120 | call findjava.bat
|
---|
| 121 | if "%JAVA_EXECUTABLE%" == "" echo **** No Java executable found& goto exit
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | :: ---- Run the Greenstone Server Interface ----
|
---|
| 125 | echo.
|
---|
| 126 | "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
|
---|
| 127 | goto exit
|
---|
| 128 |
|
---|
| 129 | :exit
|
---|
| 130 | popd
|
---|
| 131 | ENDLOCAL
|
---|