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

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

When gs2-server.bat is called with the glisite.cfg configfile, it means it's launched through GLI. In that case an extra DOS prompt would have been launched and would need to be closed upon exit. So gs2-server.bat now makes a call to the batch cmd exit when it's launched with glisite.cfg.

File size: 4.7 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:: Setup Greenstone2, unless it has already been done
28:: If either GSDLHOME or GSDLOS is not set, need to run setup.bat first
29:: OR operations in an IF stmt: http://fixunix.com/ms-dos/21057-how-implement-if-condition-batch-file.html
30for %%i in ("%GSDLOS%" "%GSDLHOME%") do if %%i == "" set OR=True
31if "%OR%" == "True" (
32 pushd "%gsdl2path%"
33 call setup.bat
34 echo **** GSDLOS: %GSDLOS% and GSDLHOME: %GSDLHOME%
35 popd
36)
37
38
39:: First test that there is actually something that can be run...
40:: Exit if the apache-httpd folder doesn't exist for some reason
41:: (The errors reported when the apache webserver does not exist
42:: in the correct location are not at all helpful).
43
44:: "You cannot use the if command to test directly for a directory, but
45:: the null (NUL) device does exist in every directory. As a result, you
46:: can test for the null device to determine whether a directory exists."
47::echo %GSDLHOME%\apache-httpd\nul
48if not exist %GSDLHOME%\apache-httpd\nul (
49 echo.
50 echo UNABLE TO CONTINUE: There is no apache-httpd directory.
51 echo It does not look like the local apache webserver has been installed.
52 echo Exiting...
53 echo.
54 goto exit
55)
56:: exit 1
57
58
59:: If there's no llssite.cfg file, copy from the template
60if exist "%GSDLHOME%\llssite.cfg" goto cfgfile
61if exist "%GSDLHOME%\llssite.cfg.in" (
62 copy "%GSDLHOME%\llssite.cfg.in" "%GSDLHOME%\llssite.cfg"
63) else (
64 echo Warning: could not find llssite.cfg.in to create llssite.cfg from.
65)
66
67:cfgfile
68:: ---- Determine GSDLHOME ----
69:: JRE_HOME or JAVA_HOME must be set correctly to run this program
70bin\windows\search4j -m %java_min_version% > nul
71echo.
72:: In Java code, '...getResourceAsStream("build.properties")'
73:: needs up to be in the right directory when run
74if %ERRORLEVEL% equ 0 pushd %GSDL2PATH%
75
76:: http://ss64.com/nt/call.html (and leave in trailing slash)
77call :isinpath %GSDLHOME%\lib\java
78
79:: After the call, we come back here
80goto chkjava
81
82:isinpath
83:: http://ss64.com/nt/syntax-replace.html and http://ss64.com/nt/syntax-args.html
84:: (Does not work: section "Finding items within the PATH environment variable")
85:: Instead, we expand the filepath of parameter 1 to its full path and
86:: try to subtract it from the classpath.
87::call set test_cpath=%%CLASSPATH:%~f1=%%
88call set test_cpath=%%CLASSPATH:%1=%%
89
90:: If there IS a difference in the classpath before and after,
91:: then the filepath was already on the classpath
92if not "%CLASSPATH%" == "%test_cpath%" (
93 echo - CLASSPATH already correct
94 echo %CLASSPATH%
95 goto :eof
96)
97
98:: If there was NO difference in the classpath before and after,
99:: then the filepath needs to be added to the classpath
100set CLASSPATH=%GSDLHOME%\lib\java;%CLASSPATH%
101
102:: http://ss64.com/nt/for_r.html and (for call) http://ss64.com/nt/for.html
103:: http://ss64.com/nt/syntax-args.html
104FOR /R "%GSDLHOME%\lib\java" %%G IN (*.jar) DO call :putinpath %%G
105echo - Adjusted CLASSPATH
106echo.
107::echo CLASSPATH:& echo %CLASSPATH%
108goto :eof
109
110
111:putinpath
112echo jarfile: %1
113set CLASSPATH=%CLASSPATH%;%1
114goto :eof
115
116:: ---- Check Java ----
117:chkjava
118:: call the script with source, so that we have the variables it sets ($javapath)
119set exit_status=0
120:: Need to find Java. If found, JAVA_EXECUTABLE will be set
121:: call findjava.bat %serverlang% %PROGNAME%
122call "%GSDLHOME%\findjava.bat"
123if "%JAVA_EXECUTABLE%" == "" echo **** No Java executable found& goto exit
124
125
126:: ---- Run the Greenstone Server Interface ----
127echo.
128"%JAVA_EXECUTABLE%" org.greenstone.server.Server2 "%GSDLHOME%" "%serverlang%" %*
129::echo ******* Second argument to gs2-server.bat is: %2
130:: The 1st argument to gs2-server.bat (if any) would be --config, the 2nd is the config
131:: filename if it is glisite.cfg, then this script was launched through GLI and would
132:: have opened a DOS console. Need to exit from this script then to close the console.
133if "%2" == "%GSDLHOME%\glisite.cfg" goto quitcmd
134goto exit
135
136:: Exit the batch script (close the console)
137:quitcmd
138popd
139ENDLOCAL
140exit 0
141
142:: Just end the script without closing the console
143:exit
144popd
145ENDLOCAL
Note: See TracBrowser for help on using the repository browser.