source: main/trunk/greenstone3/gs3-setup.bat@ 24336

Last change on this file since 24336 was 24336, checked in by davidb, 12 years ago

Matching test for gs3-setup.sh with setup.bash when checking for extensions

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
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"
49
50:: http://ss64.com/nt/for_cmd.html, how to deal with spaces in the file list in a for command
51:: Note that TOMCAT_HOME\common\endorsed only exists for Tomcat 5, not Tomcat 6
52:: (where it contains xercesImpl.jar and xml-apis.jar which aren't there in Tomcat 6)
53if exist "!TOMCAT_HOME!\common\endorsed\*.jar" for /f %%j in ('dir/b ^"!TOMCAT_HOME!\common\endorsed\*.jar^"') do echo set CLASSPATH=%%CLASSPATH%%;%%TOMCAT_HOME%%\common\endorsed\%%j>> !TMP!\setcp.bat
54for /f %%j in ('dir/b ^"!TOMCAT_HOME!\lib\*.jar^"') do echo set CLASSPATH=%%CLASSPATH%%;%%TOMCAT_HOME%%\lib\%%j>> !TMP!\setcp.bat
55
56if exist !TMP!\setcp.bat call !TMP!\setcp.bat
57if exist !TMP!\setcp.bat del !TMP!\setcp.bat
58
59set GS_CP_SET=yes
60:skipSetCp
61
62:: ---- if gs2build is there, run its setup.bat file ----
63
64if exist gs2build\setup.bat (
65 echo.
66 echo Running gs2build\setup.bat
67 cd gs2build
68 call setup.bat
69 cd ..
70)
71
72:: ---- Check for any setup files in ext or local folders ----
73if exist ext (
74 for /D %%e IN ("ext/*") do (
75 cd ext\%%e
76 if EXIST gs3-setup.bat (
77 call gs3-setup.bat
78 ) else (
79 if EXIST setup.bat call setup.bat
80 )
81 cd ..\..
82 )
83)
84
85
86if exist local\gs3-setup.bat (
87 echo.
88 echo Running local\gs3-setup.bat
89 cd local
90 call gs3-setup.bat
91 cd ..
92)
93
94:: ---- Search for java ----
95set JAVA_MIN_VERSION=1.5.0_00
96set HINT=!CD!\packages\jre
97::if search4j is present, use it
98set FOUNDJAVAHOME=
99set RUNJAVA=
100if exist bin\search4j.exe (
101 for /F "tokens=*" %%r in ('bin\search4j.exe -d -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJAVAHOME=%%r
102 for /F "tokens=*" %%r in ('bin\search4j.exe -r -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJREHOME=%%r
103)
104
105if DEFINED FOUNDJAVAHOME (
106 set JAVA_HOME=!FOUNDJAVAHOME!
107 set PATH=!FOUNDJAVAHOME!\bin;!PATH!
108 set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe
109 goto summaryThenEnd
110)
111
112if DEFINED FOUNDJREHOME (
113 set JRE_HOME=!FOUNDJREHOME!
114 set PATH=!FOUNDJREHOME!\bin;!PATH!
115 set RUNJAVA=!FOUNDJREHOME!\bin\java.exe
116 goto summaryThenEnd
117)
118
119if exist "!HINT!\bin\java.exe" (
120 set JAVA_HOME=!HINT!
121 set PATH=!JAVA_HOME!\bin;!PATH!
122 set RUNJAVA=!JAVA_HOME!\bin\java.exe
123 goto summaryThenEnd
124)
125
126if exist "!JAVA_HOME!\bin\java.exe" (
127 set PATH=!JAVA_HOME!\bin;!PATH!
128 set RUNJAVA=!JAVA_HOME!\bin\java.exe
129 echo Using Java at !JAVA_HOME!
130 echo WARNING: Greenstone has not checked the version number of this Java installation
131 echo The source distribution of Greenstone3 requires Java 1.5 or greater
132 echo SVN users may still use Java 1.4
133 goto summaryThenEnd
134)
135
136if exist "!JRE_HOME!\bin\java.exe" (
137 set PATH=!JRE_HOME!\bin;!PATH!
138 set RUNJAVA=!JRE_HOME!\bin\java.exe
139 echo Using Java at !JRE_HOME!
140 echo WARNING: Greenstone has not checked the version number of this Java installation
141 echo The source distribution of Greenstone3 requires Java 1.5 or greater
142 echo SVN users may still use Java 1.4
143 goto summaryThenEnd
144)
145
146echo ERROR: Failed to locate Java
147echo Please set JAVA_HOME or JRE_HOME to point to an appropriate Java
148goto end
149
150:summaryThenEnd
151
152echo GSDL3SRCHOME : !GSDL3SRCHOME!
153echo GSDL3HOME : !GSDL3HOME!
154echo JAVA : !RUNJAVA!
155
156if "!ANT_HOME!" == "" (
157 echo.
158 echo ANT_HOME is not yet set.
159 echo Please make sure you have Ant version 1.7.1 or higher installed
160 echo Then set ANT_HOME to the Ant installation folder
161 echo and add the path to its bin folder to the PATH environment variable
162) else (
163 echo ANT_HOME : !ANT_HOME!
164)
165echo.
166
167:: End localisation of variables that started with the set local/set enabledelayedexpansion command
168:: Restore global variables that would otherwise be lost at script's end due to their having been initialised in a
169:: set local/set enabledelayedexpansion section. See http://ss64.com/nt/endlocal.html
170endlocal & set RUNJAVA=%RUNJAVA%& set PATH=%PATH%& set GSDLOS=%GSDLOS%& set GSDLHOME=%GSDLHOME%& set GSDL3HOME=%GSDL3HOME%& set GSDL3SRCHOME=%GSDL3SRCHOME%& set JAVA_HOME=%JAVA_HOME%& set JRE_HOME=%JRE_HOME%& set ANT_HOME=%ANT_HOME%& set CLASSPATH=%CLASSPATH%
171
172:end
Note: See TracBrowser for help on using the repository browser.