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

Revision 24374, 6.4 KB (checked in by ak19, 8 years ago)

Dr Bainbridge made some corrections so that we can use the greenstone2 setup.bat in place of the greenstone3\gs2build\setup.bat

  • 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 GSDL3SRCHOME to the current directory
22cd | winutil\setvar.exe GSDL3SRCHOME > !TMP!\setgsdl3.bat
23call !TMP!\setgsdl3.bat
24del !TMP!\setgsdl3.bat
25
26:: set GSDL3HOME 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.
42:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\gsdll32.dll
43:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\lib\*.*" set GS_LIB=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\lib
44:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\*.*" set PATH=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin;!PATH!
45:: if 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 ----
63endlocal & 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%
64
65if exist gs2build\setup.bat (
66  echo.
67  echo Running gs2build\setup.bat
68  cd gs2build
69  call setup.bat
70  cd ..
71)
72
73:: ---- Check for any setup files in ext or local folders ----
74if exist ext (
75    for /D %%e IN ("ext/*") do (
76        cd ext\%%e
77        if EXIST gs3-setup.bat (
78      call gs3-setup.bat
79    ) else (
80          if EXIST setup.bat call setup.bat
81    )
82        cd ..\..
83    )
84)
85
86
87if exist local\gs3-setup.bat (
88  echo.
89  echo Running local\gs3-setup.bat
90  cd local
91  call gs3-setup.bat
92  cd ..
93)
94
95setlocal enabledelayedexpansion
96
97:: ---- Search for java ----
98set JAVA_MIN_VERSION=1.5.0_00
99set HINT=!CD!\packages\jre
100::if search4j is present, use it
101set FOUNDJAVAHOME=
102set RUNJAVA=
103if exist bin\search4j.exe (
104  for /F "tokens=*" %%r in ('bin\search4j.exe -d -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJAVAHOME=%%r
105  for /F "tokens=*" %%r in ('bin\search4j.exe -r -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJREHOME=%%r
106)
107
108if DEFINED FOUNDJAVAHOME  (
109  set JAVA_HOME=!FOUNDJAVAHOME!
110  set PATH=!FOUNDJAVAHOME!\bin;!PATH!
111  set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe
112  goto summaryThenEnd
113)
114
115if DEFINED FOUNDJREHOME (
116  set JRE_HOME=!FOUNDJREHOME!
117  set PATH=!FOUNDJREHOME!\bin;!PATH!
118  set RUNJAVA=!FOUNDJREHOME!\bin\java.exe
119  goto summaryThenEnd
120)
121
122if exist "!HINT!\bin\java.exe" (
123  set JAVA_HOME=!HINT!
124  set PATH=!JAVA_HOME!\bin;!PATH!
125  set RUNJAVA=!JAVA_HOME!\bin\java.exe
126  goto summaryThenEnd
127)
128
129if exist "!JAVA_HOME!\bin\java.exe" (
130  set PATH=!JAVA_HOME!\bin;!PATH!
131  set RUNJAVA=!JAVA_HOME!\bin\java.exe
132  echo Using Java at !JAVA_HOME!
133  echo WARNING: Greenstone has not checked the version number of this Java installation
134  echo          The source distribution of Greenstone3 requires Java 1.5 or greater
135  echo          SVN users may still use Java 1.4
136  goto summaryThenEnd
137)
138
139if exist "!JRE_HOME!\bin\java.exe" (
140  set PATH=!JRE_HOME!\bin;!PATH!
141  set RUNJAVA=!JRE_HOME!\bin\java.exe
142  echo Using Java at !JRE_HOME!
143  echo WARNING: Greenstone has not checked the version number of this Java installation
144  echo          The source distribution of Greenstone3 requires Java 1.5 or greater
145  echo          SVN users may still use Java 1.4
146  goto summaryThenEnd
147)
148
149echo ERROR: Failed to locate Java
150echo        Please set JAVA_HOME or JRE_HOME to point to an appropriate Java
151goto end
152
153:summaryThenEnd
154
155echo GSDL3SRCHOME : !GSDL3SRCHOME!
156echo GSDL3HOME    : !GSDL3HOME!
157echo JAVA         : !RUNJAVA!
158
159if "!ANT_HOME!" == "" (
160   echo.
161   echo ANT_HOME is not yet set.
162   echo Please make sure you have Ant version 1.7.1 or higher installed
163   echo Then set ANT_HOME to the Ant installation folder
164   echo and add the path to its bin folder to the PATH environment variable
165) else (
166   echo ANT_HOME     : !ANT_HOME!
167)
168echo.
169
170:: End localisation of variables that started with the set local/set enabledelayedexpansion command
171:: Restore global variables that would otherwise be lost at script's end due to their having been initialised in a
172:: set local/set enabledelayedexpansion section. See http://ss64.com/nt/endlocal.html
173endlocal & 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%
174
175:end
Note: See TracBrowser for help on using the browser.