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

Revision 22081, 5.9 KB (checked in by dmn, 10 years ago)

message tidying

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