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
|
---|
81 | :: http://ss64.com/nt/syntax-args.html
|
---|
82 | ECHO Param 1: %1
|
---|
83 | ECHO Full path of param 1: %~f1
|
---|
84 | set mypath=%~f1
|
---|
85 | echo.
|
---|
86 |
|
---|
87 | :: Does not work: http://ss64.com/nt/syntax-replace.html,
|
---|
88 | :: section "Finding items within the PATH environment variable"
|
---|
89 |
|
---|
90 | :: Instead, we expand the filepath of parameter 1 to its full path and
|
---|
91 | :: try to subtract it from the classpath.
|
---|
92 | call set test_cpath=%%CLASSPATH:%~f1=%%
|
---|
93 | ECHO Test_cpath: %test_cpath%& echo.
|
---|
94 | ECHO classpath: %CLASSPATH%& echo.
|
---|
95 |
|
---|
96 | :: If there IS a difference in the classpath before and after,
|
---|
97 | :: then the filepath was already on the classpath
|
---|
98 | if not "%CLASSPATH%" == "%test_cpath%" (
|
---|
99 | echo - CLASSPATH already correct
|
---|
100 | echo %CLASSPATH%
|
---|
101 | goto :eof
|
---|
102 | )
|
---|
103 |
|
---|
104 | :: If there was NO difference in the classpath before and after,
|
---|
105 | :: then the filepath needs to be added to the classpath
|
---|
106 | set CLASSPATH=%GSDLHOME%\lib\java;%CLASSPATH%
|
---|
107 |
|
---|
108 | :: http://ss64.com/nt/for_r.html and http://ss64.com/nt/for.html
|
---|
109 | :: http://ss64.com/nt/syntax-args.html
|
---|
110 | FOR /R "%GSDLHOME%\lib\java" %%G IN (*.jar) DO call :putinpath %%G
|
---|
111 | echo - Adjusted CLASSPATH
|
---|
112 | echo.
|
---|
113 | ::echo CLASSPATH:& echo %CLASSPATH%
|
---|
114 | goto :eof
|
---|
115 |
|
---|
116 |
|
---|
117 | :putinpath
|
---|
118 | echo jarfile: %1
|
---|
119 | set CLASSPATH=%CLASSPATH%;%1
|
---|
120 | goto :eof
|
---|
121 |
|
---|
122 | :: ---- Check Java ----
|
---|
123 | :chkjava
|
---|
124 | :: call the script with source, so that we have the variables it sets ($javapath)
|
---|
125 | set exit_status=0
|
---|
126 | :: Need to find Java. If found, JAVA_EXECUTABLE will be set
|
---|
127 | :: call findjava.bat %serverlang% %PROGNAME%
|
---|
128 | call findjava.bat
|
---|
129 | if "%JAVA_EXECUTABLE%" == "" echo **** No Java executable found& goto exit
|
---|
130 |
|
---|
131 |
|
---|
132 | :: ---- Run the Greenstone Server Interface ----
|
---|
133 | echo.
|
---|
134 | "%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
|
---|
135 | goto exit
|
---|
136 |
|
---|
137 | :exit
|
---|
138 | popd
|
---|
139 | ENDLOCAL
|
---|