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

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

Corrected the pathname to search for in PATH, it is no longer expanded to the full pathname before searching for it. Removed some comments.

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