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

Last change on this file since 30568 was 30568, checked in by ak19, 8 years ago

All the commits for a distributed GS3 on Windows (no changes made for linux yet). In a distributed GS3, the GS3 is installed in a read-only location and the tomcat runs from the writable TMP area, while the collections go to a writable userweb location specified by the user. (The DVD-only mode still works and is separate.) A problem remains, but exists in the TSG patched version too, and since the current commit breaks nothing, I'm committing it. The user needs to modify 4 properties in build.properties, one of which is new.They need to set using.user.web to true, set web.home to the userweb location, set gsdl3home.isreadonly to true and set gsdl3.writablehome to the tmpdir. The problem is that I can't successfully build the simple html collection if the GS3 installed location is read-only, as the perl code wants to create temporary files in gs2build\tmp which is read-only.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1@echo off
2
3setlocal enabledelayedexpansion
4
5set java_min_version=1.5.0_00
6
7if exist gs3-setup.bat goto prelim
8 echo This script must be run from within the Greenstone 3 home directory
9 goto done
10
11:prelim
12if "!GSDL3SRCHOME!" == "" goto start
13if "!GSDL3SRCHOME!" == "!CD!" (
14 echo Your environment is already set up for Greenstone3
15 goto done
16) else (
17 echo Your environment was set up for Greenstone 3 in !GSDL3SRCHOME!.
18 echo Overwriting that set up for the current Greenstone 3 in !CD!.
19)
20
21:start
22:: ---- Set some relevant environment variables ----
23
24:: this is the default
25:: greenstone3 (!GSDL3SRCHOME!)
26:: +-- web (!GSDL3HOME!)
27:: +-- packages
28:: +-- tomcat (!TOMCAT_HOME!)
29:: +-- ant (!ANT_HOME!)
30
31:: set GSDL3SRCHOME to the current directory
32cd | winutil\setvar.exe GSDL3SRCHOME > !TMP!\setgsdl3.bat
33call !TMP!\setgsdl3.bat
34del !TMP!\setgsdl3.bat
35
36:: set GSDL3HOME to the 'web' subdirectory
37set GSDL3HOME=!GSDL3SRCHOME!\web
38set TOMCATWEB=!GSDL3SRCHOME!\web
39:: set GSDL3HOME to any web.home property provided, and create that folder if it doesn't exist
40:: Replace forward slashes in web.home with back slashes
41:: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed
42if exist "!GSDL3SRCHOME!\build.properties" for /F "tokens=1,2 delims==" %%G in (!GSDL3SRCHOME!\build.properties) do (
43 if "%%G"=="web.home" (
44 set GSDL3HOME=%%H
45 set GSDL3HOME=!GSDL3HOME:/=\!
46 set TOMCATWEB=!GSDL3HOME!
47 if not exist "!GSDL3HOME!" cmd /c "!GSDL3SRCHOME!\userweb.cmd"
48 )
49)
50
51:: Whatever the web directory is, it should contain the WEB-INF\classes folder, else go back to using default for this
52:: The WEB-INF\classes folder will be absent in a userweb folder, but will be present if GSDL3HOME=GSDL3SRCHOME\web
53:: or if web.home points to GS3 as a webapp inside tomcat
54if not exist "!GSDL3HOME!\WEB-INF\classes" set TOMCATWEB=!GSDL3SRCHOME!\web
55
56:: change if using external tomcat or ant
57set TOMCAT_HOME=!GSDL3SRCHOME!\packages\tomcat
58if exist "!GSDL3SRCHOME!\packages\ant\*.*" set ANT_HOME=!GSDL3SRCHOME!\packages\ant
59
60:: other important environment variables
61set GSDLOS=windows
62
63:: ---- Set the CLASSPATH and PATH environment variables ----
64if "!GS_CP_SET!" == "yes" goto skipSetCp
65set CLASSPATH=!TOMCATWEB!\WEB-INF\classes;!GSDL3SRCHOME!\resources\java;!GSDL3SRCHOME!\cp.jar;!CLASSPATH!;
66set PATH=!GSDL3SRCHOME!\bin;!GSDL3SRCHOME!\bin\script;!GSDL3SRCHOME!\lib\jni;!ANT_HOME!\bin;!PATH!
67
68:: Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
69:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\gsdll32.dll
70:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\lib\*.*" set GS_LIB=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\lib
71:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin\*.*" set PATH=!GSDL3SRCHOME!\gs2build\bin\windows\ghostscript\bin;!PATH!
72:: if exist "!GSDL3SRCHOME!\gs2build\bin\windows\imagemagick\*.*" set PATH=!GSDL3SRCHOME!\gs2build\bin\windows\imagemagick;!PATH!
73
74:: a little dynamic set cp stuff
75if exist "!TMP!\setcp.bat" del "!TMP!\setcp.bat"
76
77:: http://ss64.com/nt/for_cmd.html, how to deal with spaces in the file list in a for command
78:: Note that TOMCAT_HOME\common\endorsed only exists for Tomcat 5, not Tomcat 6
79:: (where it contains xercesImpl.jar and xml-apis.jar which aren't there in Tomcat 6)
80if 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
81for /f %%j in ('dir/b ^"!TOMCAT_HOME!\lib\*.jar^"') do echo set CLASSPATH=%%CLASSPATH%%;%%TOMCAT_HOME%%\lib\%%j>> !TMP!\setcp.bat
82
83if exist !TMP!\setcp.bat call !TMP!\setcp.bat
84if exist !TMP!\setcp.bat del !TMP!\setcp.bat
85
86set GS_CP_SET=yes
87:skipSetCp
88
89:: ---- if gs2build is there, run its setup.bat file ----
90endlocal & 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%
91
92if exist gs2build\setup.bat (
93 echo.
94 echo Running gs2build\setup.bat
95 cd gs2build
96 call setup.bat
97 cd ..
98)
99
100:: ---- Check for any setup files in ext or local folders ----
101if exist ext (
102 for /D %%e IN ("ext/*") do (
103 cd ext\%%e
104 if EXIST gs3-setup.bat (
105 call gs3-setup.bat
106 ) else (
107 if EXIST setup.bat call setup.bat
108 )
109 cd ..\..
110 )
111)
112
113
114if exist local\gs3-setup.bat (
115 echo.
116 echo Running local\gs3-setup.bat
117 cd local
118 call gs3-setup.bat
119 cd ..
120)
121
122setlocal enabledelayedexpansion
123
124:: ---- Search for java ----
125set JAVA_MIN_VERSION=1.5.0_00
126set HINT=!CD!\packages\jre
127::if search4j is present, use it
128set FOUNDJAVAHOME=
129set RUNJAVA=
130if exist bin\search4j.exe (
131 for /F "tokens=*" %%r in ('bin\search4j.exe -d -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJAVAHOME=%%r
132 for /F "tokens=*" %%r in ('bin\search4j.exe -r -p "!HINT!" -m !JAVA_MIN_VERSION!') do set FOUNDJREHOME=%%r
133)
134
135if DEFINED FOUNDJAVAHOME (
136 set JAVA_HOME=!FOUNDJAVAHOME!
137 set PATH=!FOUNDJAVAHOME!\bin;!PATH!
138 set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe
139 goto summaryThenEnd
140)
141
142if DEFINED FOUNDJREHOME (
143 set JRE_HOME=!FOUNDJREHOME!
144 set PATH=!FOUNDJREHOME!\bin;!PATH!
145 set RUNJAVA=!FOUNDJREHOME!\bin\java.exe
146 goto summaryThenEnd
147)
148
149if exist "!HINT!\bin\java.exe" (
150 set JAVA_HOME=!HINT!
151 set PATH=!JAVA_HOME!\bin;!PATH!
152 set RUNJAVA=!JAVA_HOME!\bin\java.exe
153 goto summaryThenEnd
154)
155
156if exist "!JAVA_HOME!\bin\java.exe" (
157 set PATH=!JAVA_HOME!\bin;!PATH!
158 set RUNJAVA=!JAVA_HOME!\bin\java.exe
159 echo Using Java at !JAVA_HOME!
160 echo WARNING: Greenstone has not checked the version number of this Java installation
161 echo The source distribution of Greenstone3 requires Java 1.5 or greater
162 echo SVN users may still use Java 1.4
163 goto summaryThenEnd
164)
165
166if exist "!JRE_HOME!\bin\java.exe" (
167 set PATH=!JRE_HOME!\bin;!PATH!
168 set RUNJAVA=!JRE_HOME!\bin\java.exe
169 echo Using Java at !JRE_HOME!
170 echo WARNING: Greenstone has not checked the version number of this Java installation
171 echo The source distribution of Greenstone3 requires Java 1.5 or greater
172 echo SVN users may still use Java 1.4
173 goto summaryThenEnd
174)
175
176echo ERROR: Failed to locate Java
177echo Please set JAVA_HOME or JRE_HOME to point to an appropriate Java
178goto end
179
180:summaryThenEnd
181
182echo GSDL3SRCHOME : !GSDL3SRCHOME!
183echo GSDL3HOME : !GSDL3HOME!
184echo JAVA : !RUNJAVA!
185
186if "!ANT_HOME!" == "" (
187 echo.
188 echo ANT_HOME is not yet set.
189 echo Please make sure you have Ant version 1.7.1 or higher installed
190 echo Then set ANT_HOME to the Ant installation folder
191 echo and add the path to its bin folder to the PATH environment variable
192) else (
193 echo ANT_HOME : !ANT_HOME!
194)
195echo.
196
197:done
198:: End localisation of variables that started with the set local/set enabledelayedexpansion command
199:: Restore global variables that would otherwise be lost at script's end due to their having been initialised in a
200:: set local/set enabledelayedexpansion section. See http://ss64.com/nt/endlocal.html
201endlocal & 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%
202
203:end
Note: See TracBrowser for help on using the repository browser.