source: gsdl/trunk/gs2-server.bat@ 20391

Last change on this file since 20391 was 20391, checked in by ak19, 15 years ago

Added a windows version of the script gs2-server.sh which also requires a local copy of findjava.bat. (The original is in the GLI folder since GLI uses it as well).

File size: 4.0 KB
Line 
1@echo off
2SETLOCAL
3
4set serverlang=en
5set java_min_version=1.4.0_00
6set PROGNAME="gs2-server"
7pushd "%CD%"
8CD /D "%~dp0"
9
10echo Greenstone 2 Server
11echo Copyright (C) 2009, New Zealand Digital Library Project, University Of Waikato
12echo This software comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt
13echo This is free software, and you are welcome to redistribute it
14
15:: -------- Run the Greenstone 2 Server --------
16
17:: ---- Determine GSDLHOME ----
18set gsdl2path=
19
20:: Some users may set the above line manually
21if "%gsdl2path%" == "" (
22 set GSDLHOME=%CD%
23 set gsdl2path=%CD%
24)
25echo GS2 Home: %GSDLHOME%
26
27::goto autoset_gsdl_home %gsdl2path%
28
29:: Setup Greenstone2, unless it has already been done
30if "%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
46if 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
58if exist "%GSDLHOME%\llssite.cfg" goto cfgfile
59if 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
68bin\windows\search4j -m %java_min_version% > nul
69echo.
70:: In Java code, '...getResourceAsStream("build.properties")'
71:: needs up to be in the right directory when run
72if %ERRORLEVEL% equ 0 pushd %GSDL2PATH%
73
74:: http://ss64.com/nt/call.html (and leave in trailing slash)
75call :isinpath %GSDLHOME%\lib\java
76
77:: After the call, we come back here
78goto chkjava
79
80:isinpath
81:: http://ss64.com/nt/syntax-args.html
82ECHO Param 1: %1
83ECHO Full path of param 1: %~f1
84set mypath=%~f1
85echo.
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.
92call set test_cpath=%%CLASSPATH:%~f1=%%
93ECHO Test_cpath: %test_cpath%& echo.
94ECHO 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
98if 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
106set 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
110FOR /R "%GSDLHOME%\lib\java" %%G IN (*.jar) DO call :putinpath %%G
111echo - Adjusted CLASSPATH
112echo.
113::echo CLASSPATH:& echo %CLASSPATH%
114goto :eof
115
116
117:putinpath
118echo jarfile: %1
119set CLASSPATH=%CLASSPATH%;%1
120goto :eof
121
122:: ---- Check Java ----
123:chkjava
124:: call the script with source, so that we have the variables it sets ($javapath)
125set exit_status=0
126:: Need to find Java. If found, JAVA_EXECUTABLE will be set
127:: call findjava.bat %serverlang% %PROGNAME%
128call findjava.bat
129if "%JAVA_EXECUTABLE%" == "" echo **** No Java executable found& goto exit
130
131
132:: ---- Run the Greenstone Server Interface ----
133echo.
134"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
135goto exit
136
137:exit
138popd
139ENDLOCAL
Note: See TracBrowser for help on using the repository browser.