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

Revision 22082, 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
RevLine 
[15071]1@echo off
2
[22069]3setlocal enabledelayedexpansion
4
[20191]5set java_min_version=1.5.0_00
[15071]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
[15363]12:: ---- Set some relevant environment variables ----
13
14:: this is the default
[22069]15:: greenstone3 (!GSDL3SRCHOME!)
16:: +-- web (!GSDL3HOME!)
[15363]17:: +-- packages
[22069]18::      +-- tomcat (!TOMCAT_HOME!)
19::      +-- ant (!ANT_HOME!)
[15363]20
21:: set GSDLSRCHOME to the current directory
[22069]22cd | winutil\setvar.exe GSDL3SRCHOME > !TMP!\setgsdl3.bat
23call !TMP!\setgsdl3.bat
24del !TMP!\setgsdl3.bat
[15363]25
26:: set GSDLHOME to the 'web' subdirectory
[22069]27set GSDL3HOME=!GSDL3SRCHOME!\web
[15071]28
[15363]29:: change if using external tomcat or ant
[22069]30set TOMCAT_HOME=!GSDL3SRCHOME!\packages\tomcat
31if exist "!GSDL3SRCHOME!\packages\ant\*.*" set ANT_HOME=!GSDL3SRCHOME!\packages\ant
[15071]32
[15363]33:: other important environment variables
[15071]34set GSDLOS=windows
[15363]35
36:: ---- Set the CLASSPATH and PATH environment variables ----
[22069]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
[15071]40
[20304]41:: Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
[22069]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!
[20304]46
[15363]47:: a little dynamic set cp stuff
[22075]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
[22069]56if exist !TMP!\setcp.bat call !TMP!\setcp.bat
57if exist !TMP!\setcp.bat del !TMP!\setcp.bat
[15363]58
59set GS_CP_SET=yes
[15071]60:skipSetCp
61
[21320]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
[15363]90:: ---- Search for java ----
[20300]91set JAVA_MIN_VERSION=1.5.0_00
[22069]92set HINT=!CD!\packages\jre
[20300]93::if search4j is present, use it
94set FOUNDJAVAHOME=
95set RUNJAVA=
96if exist bin\search4j.exe (
[22069]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
[20300]99)
[15071]100
[21988]101if DEFINED FOUNDJAVAHOME  (
102  set JAVA_HOME=!FOUNDJAVAHOME!
103  set PATH=!FOUNDJAVAHOME!\bin;!PATH!
104  set RUNJAVA=!FOUNDJAVAHOME!\bin\java.exe
[20300]105  goto summaryThenEnd
106)
[15071]107
[21988]108if DEFINED FOUNDJREHOME (
109  set JRE_HOME=!FOUNDJREHOME!
110  set PATH=!FOUNDJREHOME!\bin;!PATH!
111  set RUNJAVA=!FOUNDJREHOME!\bin\java.exe
[20307]112  goto summaryThenEnd
113)
114
[22069]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
[20300]119  goto summaryThenEnd
120)
[15071]121
[22069]122if exist "!JAVA_HOME!\bin\java.exe" (
123  set PATH=!JAVA_HOME!\bin;!PATH!
124  set RUNJAVA=!JAVA_HOME!\bin\java.exe
[22082]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
[20300]129  goto summaryThenEnd
130)
131
[22069]132if exist "!JRE_HOME!\bin\java.exe" (
133  set PATH=!JRE_HOME!\bin;!PATH!
134  set RUNJAVA=!JRE_HOME!\bin\java.exe
[22082]135  echo Using Java at !JRE_HOME!
[22081]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
[22082]138  echo          SVN users may still use Java 1.4
[20300]139  goto summaryThenEnd
140)
141
[22082]142echo ERROR: Failed to locate Java
143echo        Please set JAVA_HOME or JRE_HOME to point to an appropriate Java
[20300]144goto end
145
146:summaryThenEnd
147
[22069]148echo GSDL3SRCHOME : !GSDL3SRCHOME!
149echo GSDL3HOME    : !GSDL3HOME!
150echo JAVA         : !RUNJAVA!
[22075]151
[22024]152if "!ANT_HOME!" == "" (
[20493]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
[22082]156   echo Then set ANT_HOME to the Ant installation folder
[22075]157   echo and add the path to its bin folder to the PATH environment variable
[20493]158) else (
[22024]159   echo ANT_HOME     : !ANT_HOME!
[20493]160)
161echo.
[22015]162
[22069]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
[22075]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%
[22015]167
[20300]168:end
Note: See TracBrowser for help on using the browser.