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

Revision 21988, 5.0 KB (checked in by ak19, 9 years ago)

Updating gs3-setup.bat to handle JAVA_HOME and PATH having brackets

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1@echo off
2
3setlocal enabledelayedexpansion
4
5set java_min_version=1.5.0_00
6
7if exist gs3-setup.bat goto start
8  echo This script must be run from within the Greenstone 3 home directory
9  goto exit
10
11:start
12:: ---- Set some relevant environment variables ----
13
14:: this is the default
15:: greenstone3 (%GSDL3SRCHOME%)
16:: +-- web (%GSDL3HOME%)
17:: +-- packages
18::      +-- tomcat (%TOMCAT_HOME%)
19::      +-- ant (%ANT_HOME%)
20
21:: set GSDLSRCHOME to the current directory
22cd | winutil\setvar.exe GSDL3SRCHOME > %TMP%\setgsdl3.bat
23call %TMP%\setgsdl3.bat
24del %TMP%\setgsdl3.bat
25
26:: set GSDLHOME to the 'web' subdirectory
27set GSDL3HOME=%GSDL3SRCHOME%\web
28
29:: change if using external tomcat or ant
30set TOMCAT_HOME=%GSDL3SRCHOME%\packages\tomcat
31if exist "%GSDL3SRCHOME%\packages\ant\*.*" set ANT_HOME=%GSDL3SRCHOME%\packages\ant
32
33:: other important environment variables
34set GSDLOS=windows
35
36:: ---- Set the CLASSPATH and PATH environment variables ----
37if "%GS_CP_SET%" == "yes" goto skipSetCp
38set CLASSPATH=%GSDL3HOME%\WEB-INF\classes;%GSDL3SRCHOME%\resources\java;%GSDL3SRCHOME%\cp.jar;%CLASSPATH%;
39set PATH=%PATH%;%GSDL3SRCHOME%\bin;%GSDL3SRCHOME%\bin\script;%GSDL3SRCHOME%\lib\jni;%ANT_HOME%\bin
40
41:: Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
42if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\gsdll32.dll
43if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\lib\*.*" set GS_LIB=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\lib
44if exist "%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin\*.*" set PATH=%GSDL3SRCHOME%\gs2build\bin\windows\ghostscript\bin;%PATH%
45if exist "%GSDL3SRCHOME%\gs2build\bin\windows\imagemagick\*.*" set PATH=%GSDL3SRCHOME%\gs2build\bin\windows\imagemagick;%PATH%
46
47:: a little dynamic set cp stuff
48if exist %TMP%\setcp.bat del %TMP%\setcp.bat
49for %%j in ("%TOMCAT_HOME%"\common\endorsed\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %TMP%\setcp.bat
50for %%j in ("%TOMCAT_HOME%"\lib\*.jar) do echo set CLASSPATH=%%CLASSPATH%%;%%j>> %TMP%\setcp.bat
51if exist %TMP%\setcp.bat call %TMP%\setcp.bat
52if exist %TMP%\setcp.bat del %TMP%\setcp.bat
53
54set GS_CP_SET=yes
55:skipSetCp
56
57:: ---- if gs2build is there, run its setup.bat file ----
58
59if exist gs2build\setup.bat (
60  echo.
61  echo Running gs2build\setup.bat
62  cd gs2build
63  call setup.bat
64  cd ..
65)
66
67:: ---- Check for any setup files in ext or local folders ----
68if exist ext (
69    for /D %%e IN ("ext/*") do (
70        cd ext\%%e
71        if EXIST setup.bat call setup.bat
72        cd ..\..
73    )
74)
75
76
77if exist local\gs3-setup.bat (
78  echo.
79  echo Running local\gs3-setup.bat
80  cd local
81  call gs3-setup.bat
82  cd ..
83)
84
85:: ---- Search for java ----
86set JAVA_MIN_VERSION=1.5.0_00
87set HINT=%CD%\packages\jre
88::if search4j is present, use it
89set FOUNDJAVAHOME=
90set RUNJAVA=
91if exist bin\search4j.exe (
92  for /F "tokens=*" %%r in ('bin\search4j.exe -d -p "%HINT%" -m %JAVA_MIN_VERSION%') do set FOUNDJAVAHOME=%%r
93  for /F "tokens=*" %%r in ('bin\search4j.exe -r -p "%HINT%" -m %JAVA_MIN_VERSION%') do set FOUNDJREHOME=%%r
94)
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:end
Note: See TracBrowser for help on using the browser.