root/main/trunk/greenstone3/gs3-setup.bat @ 22024

Revision 22024, 5.2 KB (checked in by ak19, 9 years ago)

Fixed more delayed expansion issues with brackets

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1@echo off
2
3set java_min_version=1.5.0_00
4
5if exist gs3-setup.bat goto start
6  echo This script must be run from within the Greenstone 3 home directory
7  goto exit
8
9:start
10:: ---- Set some relevant environment variables ----
11
12:: this is the default
13:: greenstone3 (%GSDL3SRCHOME%)
14:: +-- web (%GSDL3HOME%)
15:: +-- packages
16::      +-- tomcat (%TOMCAT_HOME%)
17::      +-- ant (%ANT_HOME%)
18
19:: set GSDLSRCHOME to the current directory
20cd | winutil\setvar.exe GSDL3SRCHOME > %TMP%\setgsdl3.bat
21call %TMP%\setgsdl3.bat
22del %TMP%\setgsdl3.bat
23
24:: set GSDLHOME to the 'web' subdirectory
25set GSDL3HOME=%GSDL3SRCHOME%\web
26
27:: change if using external tomcat or ant
28set TOMCAT_HOME=%GSDL3SRCHOME%\packages\tomcat
29if exist "%GSDL3SRCHOME%\packages\ant\*.*" set ANT_HOME=%GSDL3SRCHOME%\packages\ant
30
31:: other important environment variables
32set GSDLOS=windows
33
34:: ---- Set the CLASSPATH and PATH environment variables ----
35if "%GS_CP_SET%" == "yes" goto skipSetCp
36set CLASSPATH=%GSDL3HOME%\WEB-INF\classes;%GSDL3SRCHOME%\resources\java;%GSDL3SRCHOME%\cp.jar;%CLASSPATH%;
37set PATH=%PATH%;%GSDL3SRCHOME%\bin;%GSDL3SRCHOME%\bin\script;%GSDL3SRCHOME%\lib\jni;%ANT_HOME%\bin
38
39:: Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
40if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\gsdll32.dll
41if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\lib\*.*" set GS_LIB=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\lib
42if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\*.*" set PATH=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin;%PATH%
43if exist "%GSDL3SRCHOME%\gs2build\bin\windows\imagemagick\*.*" set PATH=%GSDL3SRCHOME%\gs2build\bin\windows\imagemagick;%PATH%
44
45:: a little dynamic set cp stuff
46if exist %TMP%\setcp.bat del %TMP%\setcp.bat
47for %%j in ("%TOMCAT_HOME%"\common\endorsed\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %TMP%\setcp.bat
48for %%j in ("%TOMCAT_HOME%"\lib\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %TMP%\setcp.bat
49if exist %TMP%\setcp.bat call %TMP%\setcp.bat
50if exist %TMP%\setcp.bat del %TMP%\setcp.bat
51
52set GS_CP_SET=yes
53:skipSetCp
54
55:: ---- if gs2build is there, run its setup.bat file ----
56
57if exist gs2build\setup.bat (
58  echo.
59  echo Running gs2build\setup.bat
60  cd gs2build
61  call setup.bat
62  cd ..
63)
64
65:: ---- Check for any setup files in ext or local folders ----
66if exist ext (
67    for /D %%e IN ("ext/*") do (
68        cd ext\%%e
69        if EXIST setup.bat call setup.bat
70        cd ..\..
71    )
72)
73
74
75if exist local\gs3-setup.bat (
76  echo.
77  echo Running local\gs3-setup.bat
78  cd local
79  call gs3-setup.bat
80  cd ..
81)
82
83:: ---- Search for java ----
84set JAVA_MIN_VERSION=1.5.0_00
85set HINT=%CD%\packages\jre
86::if search4j is present, use it
87set FOUNDJAVAHOME=
88set RUNJAVA=
89if exist bin\search4j.exe (
90  for /F "tokens=*" %%r in ('bin\search4j.exe -d -p "%HINT%" -m %JAVA_MIN_VERSION%') do set FOUNDJAVAHOME=%%r
91  for /F "tokens=*" %%r in ('bin\search4j.exe -r -p "%HINT%" -m %JAVA_MIN_VERSION%') do set FOUNDJREHOME=%%r
92)
93
94setlocal enabledelayedexpansion
95
96if DEFINED FOUNDJAVAHOME  (
97  set JAVA_HOME=!FOUNDJAVAHOME!
98  set PATH=!FOUNDJAVAHOME!\bin;!PATH!
99  set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe
100  goto summaryThenEnd
101)
102
103if DEFINED FOUNDJREHOME (
104  set JRE_HOME=!FOUNDJREHOME!
105  set PATH=!FOUNDJREHOME!\bin;!PATH!
106  set RUNJAVA=!FOUNDJREHOME!\bin\java.exe
107  goto summaryThenEnd
108)
109
110if exist "%HINT%\bin\java.exe" (
111  set JAVA_HOME=%HINT%
112  set PATH=%JAVA_HOME%\bin;%PATH%
113  set RUNJAVA=%JAVA_HOME%\bin\java.exe
114  goto summaryThenEnd
115)
116
117if exist "%JAVA_HOME%\bin\java.exe" (
118  set PATH=%JAVA_HOME%\bin;%PATH%
119  set RUNJAVA=%JAVA_HOME%\bin\java.exe
120  echo Using java at %JAVA_HOME%
121  echo WARNING: Greenstone has not checked the version number of this java installation
122  echo          The source distribution of Greenstone3 requires java 1.5 or greater
123  echo          SVN users may still use java 1.4
124  goto summaryThenEnd
125)
126
127if exist "%JRE_HOME%\bin\java.exe" (
128  set PATH=%JRE_HOME%\bin;%PATH%
129  set RUNJAVA=%JRE_HOME%\bin\java.exe
130  echo Using java at %JRE_HOME%
131  echo WARNING: Greenstone has not checked the version number of this java installation
132  echo          The source distribution of Greenstone3 requires java 1.5 or greater
133  echo          SVN users may still use java 1.4
134  goto summaryThenEnd
135)
136
137echo ERROR: Failed to locate java
138echo        Please set JAVA_HOME or JRE_HOME to point to an appropriate java
139goto end
140
141:summaryThenEnd
142
143echo GSDL3SRCHOME : %GSDL3SRCHOME%
144echo GSDL3HOME    : %GSDL3HOME%
145echo JAVA         : %RUNJAVA%
146if "!ANT_HOME!" == "" (
147   echo.
148   echo ANT_HOME is not yet set.
149   echo Please make sure you have Ant version 1.7.1 or higher installed
150   echo Then set ANT_HOME to the ant installation folder
151   echo and add the path to its bin folder to the PATH
152) else (
153   echo ANT_HOME     : !ANT_HOME!
154)
155echo.
156
157endlocal
158
159set PATH=%PATH%
160set GSDL3HOME=%GSDL3HOME%
161set GSDL3SRCHOME=%GSDL3SRCHOME%
162set JAVA_HOME=%JAVA_HOME%
163set JRE_HOME=%JRE_HOME%
164set ANT_HOME=%ANT_HOME%
165
166:end
Note: See TracBrowser for help on using the browser.