1 | @echo off
|
---|
2 |
|
---|
3 | setlocal enabledelayedexpansion
|
---|
4 |
|
---|
5 | pushd "%CD%"
|
---|
6 | CD /D "%~dp0"
|
---|
7 | set GSDLLANG=en
|
---|
8 |
|
---|
9 | :: This script's contents were created in Windows codepage 850 (Western European).
|
---|
10 | :: When this script is run in non-English locales like the Chinese locale, the
|
---|
11 | :: character content/encoding of this script can get wrongly interpreted by the
|
---|
12 | :: different encoding of the locale. And then the GS environment gets set wrongly
|
---|
13 | :: or incompletely in those cases.
|
---|
14 | :: So we force this script to be run and interpreted in codepage 850.
|
---|
15 | :: However, the Russian display strings in this script were desgined to work in the
|
---|
16 | :: default Russian Windows codepage 866. Whereas, codepage 850 works for this
|
---|
17 | :: script's remaining English, French, Spanish display strings. So:
|
---|
18 | if ("!GSDLLANG!" == "ru") (
|
---|
19 | chcp 866
|
---|
20 | ) else (
|
---|
21 | chcp 850
|
---|
22 | )
|
---|
23 |
|
---|
24 | echo.
|
---|
25 | echo.
|
---|
26 | echo #### #
|
---|
27 | echo ## #
|
---|
28 | echo # ### ## ## ### ### ### ## ### ##
|
---|
29 | echo # # # #### #### # # ## # # # # # ####
|
---|
30 | echo ## # # # # # # # # # # # # #
|
---|
31 | echo #### # ### ### # # ### ## ## # # ###
|
---|
32 | echo (C) 2008, New Zealand Digital Library Project
|
---|
33 | echo.
|
---|
34 | echo.
|
---|
35 | echo.
|
---|
36 |
|
---|
37 | if "!GSDLHOME!" == "" goto start
|
---|
38 | if "!GSDLHOME!" == "!CD!" if not "!GSDLOS!" == "" (
|
---|
39 | echo Your environment is already set up for Greenstone
|
---|
40 | goto done
|
---|
41 | )
|
---|
42 |
|
---|
43 | :start
|
---|
44 | if "!OS!" == "Windows_NT" goto WinNT
|
---|
45 | if "!OS!" == "" goto Win95
|
---|
46 | if "!GSDLLANG!" == "en" echo Setup failed - your PATH has not been set
|
---|
47 | if "!GSDLLANG!" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
|
---|
48 | if "!GSDLLANG!" == "fr" echo Echc de l'installation - votre variable PATH n'a pas t ajuste
|
---|
49 | if "!GSDLLANG!" == "ru" echo áâ ®¢ª ¥ 〠« áì - ¥ ¡ë« ãáâ ®¢«¥
|
---|
50 | goto End
|
---|
51 |
|
---|
52 | :WinNT
|
---|
53 | set GSDLHOME=%CD%
|
---|
54 | set GSDLOS=windows
|
---|
55 |
|
---|
56 | REM Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
|
---|
57 | if exist "!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL=!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll
|
---|
58 | if exist "!GSDLHOME!\bin\windows\ghostscript\lib\*.*" set GS_LIB=!GSDLHOME!\bin\windows\ghostscript\lib
|
---|
59 | if exist "!GSDLHOME!\bin\windows\ghostscript\bin\*.*" set PATH=!GSDLHOME!\bin\windows\ghostscript\bin;!PATH!
|
---|
60 | :: ImageMagick environment vars are now set in bin\script\gs-magick.pl
|
---|
61 | ::if exist "!GSDLHOME!\bin\windows\imagemagick\*.*" set PATH=!GSDLHOME!\bin\windows\imagemagick;!PATH!
|
---|
62 |
|
---|
63 | if "!GS_CP_SET!" == "yes" goto Success
|
---|
64 | set PATH=!GSDLHOME!\bin\windows;!GSDLHOME!\bin\script;!PATH!
|
---|
65 | if exist "!GSDLHOME!\bin\windows\perl\bin" (
|
---|
66 | set PERLPATH=!GSDLHOME!\bin\windows\perl\bin
|
---|
67 | set PATH=!PERLPATH!;!PATH!
|
---|
68 | )
|
---|
69 |
|
---|
70 | set GS_CP_SET=yes
|
---|
71 | goto Success
|
---|
72 |
|
---|
73 | :Win95
|
---|
74 | if "%1" == "SetEnv" goto Win95Env
|
---|
75 | REM We'll invoke a second copy of the command processor to make
|
---|
76 | REM sure there's enough environment space
|
---|
77 | COMMAND /E:2048 /K %0 SetEnv
|
---|
78 | goto End
|
---|
79 |
|
---|
80 | :Win95Env
|
---|
81 | set GSDLHOME=%CD%
|
---|
82 | set GSDLOS=windows
|
---|
83 |
|
---|
84 | REM Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
|
---|
85 | if exist "!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll" set GS_DLL="!GSDLHOME!\bin\windows\ghostscript\bin\gsdll32.dll"
|
---|
86 | if exist "!GSDLHOME!\bin\windows\ghostscript\lib\*.*" set GS_LIB="!GSDLHOME!\bin\windows\ghostscript\lib"
|
---|
87 | if exist "!GSDLHOME!\bin\windows\ghostscript\bin\*.*" set PATH="!GSDLHOME!\bin\windows\ghostscript\bin";"!PATH!"
|
---|
88 | :: ImageMagick environment vars are now set in bin\script\gs-magick.pl
|
---|
89 | ::if exist "!GSDLHOME!\bin\windows\imagemagick\*.*" set PATH="!GSDLHOME!\bin\windows\imagemagick";"!PATH!"
|
---|
90 |
|
---|
91 | if "!GS_CP_SET!" == "yes" goto Success
|
---|
92 | set PATH=!GSDLHOME!\bin\windows;!GSDLHOME!\bin\script;!PATH!
|
---|
93 | if exist "!GSDLHOME!\bin\windows\perl\bin" (
|
---|
94 | set PERLPATH=!GSDLHOME!\bin\windows\perl\bin
|
---|
95 | set PATH=!PERLPATH!;!PATH!
|
---|
96 | )
|
---|
97 | set GS_CP_SET=yes
|
---|
98 | goto Success
|
---|
99 |
|
---|
100 |
|
---|
101 | :Success
|
---|
102 | if "!GSDLLANG!" == "en" echo.
|
---|
103 | if "!GSDLLANG!" == "en" echo Your environment has successfully been set up to run Greenstone.
|
---|
104 | if "!GSDLLANG!" == "en" echo Note that these settings will only have effect within this MS-DOS
|
---|
105 | if "!GSDLLANG!" == "en" echo session. You will therefore need to rerun setup.bat if you want
|
---|
106 | if "!GSDLLANG!" == "en" echo to run Greenstone programs from a different MS-DOS session.
|
---|
107 | if "!GSDLLANG!" == "en" echo.
|
---|
108 |
|
---|
109 | if "!GSDLLANG!" == "es" echo.
|
---|
110 | if "!GSDLLANG!" == "es" echo Su ambiente ha sido configurado para correr los programas Greenstone.
|
---|
111 | if "!GSDLLANG!" == "es" echo Recuerde que estos ajustes £nicamente tendr n efecto dentro de esta sesi¢n
|
---|
112 | if "!GSDLLANG!" == "es" echo MS-DOS. Por lo tanto deber ejecutar nuevamente setup.bat si desea
|
---|
113 | if "!GSDLLANG!" == "es" echo correr los programas de Greenstone desde una sesi¢n MS-DOS diferente.
|
---|
114 | if "!GSDLLANG!" == "es" echo.
|
---|
115 |
|
---|
116 | if "!GSDLLANG!" == "fr" echo.
|
---|
117 | if "!GSDLLANG!" == "fr" echo Votre environnement a t configure avec succs pour excuter Greenstone
|
---|
118 | if "!GSDLLANG!" == "fr" echo Notez que ces paramtrages n'auront d'effet que dans cette session MS-DOS.
|
---|
119 | if "!GSDLLANG!" == "fr" echo Vous devrez par consquent rexcuter setup.bat si vous voulez faire
|
---|
120 | if "!GSDLLANG!" == "fr" echo lancer des programmes Greenstone dans une autre session MS-DOS.
|
---|
121 | if "!GSDLLANG!" == "fr" echo.
|
---|
122 |
|
---|
123 | if "!GSDLLANG!" == "ru" echo.
|
---|
124 | if "!GSDLLANG!" == "ru" echo è¥ ®ªà㊥š¥ ¡ë«® ãá¯¥è® áâ஥®, ç⮡ë ãáâ ®¢šâì Greenstone ¡à âšâ¥
|
---|
125 | if "!GSDLLANG!" == "ru" echo ¢š¬ š¥, çâ® íâš § ç¥šï ¡ã€ãâ ⮫쪮 š¬¥âì íä䥪⠢ ¯à¥€¥« å í⮣® MS DOS
|
---|
126 | if "!GSDLLANG!" == "ru" echo á¥áášï. ë ¡ã€¥â¥ ¯®í⮬㠀®«Šë ¯®¢â®à® ã¯à ¢«ïâì setup.bat, ¥á«š ë å®âšâ¥
|
---|
127 | if "!GSDLLANG!" == "ru" echo ã¯à ¢«ïâì ¯à®£à ¬¬ ¬š ¥«ñëå š§¢¥àŠ¥ëå ¯®à®€ ®â à §«šç®© á¥áášš MS DOS.
|
---|
128 | if "!GSDLLANG!" == "ru" echo.
|
---|
129 |
|
---|
130 | :End
|
---|
131 | endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS%
|
---|
132 |
|
---|
133 | set savedir=%CD%
|
---|
134 | cd "%GSDLHOME%"
|
---|
135 | if exist ext (
|
---|
136 | for /D %%e IN ("ext/*") do call :addexts %%e
|
---|
137 | )
|
---|
138 | cd "%savedir%"
|
---|
139 | set savedir=
|
---|
140 | goto :doneexts
|
---|
141 |
|
---|
142 | :addexts
|
---|
143 | set folder=%1
|
---|
144 | cd "ext\%folder%"
|
---|
145 | if EXIST setup.bat call setup.bat
|
---|
146 | cd ..\..
|
---|
147 | goto :eof
|
---|
148 |
|
---|
149 | :doneexts
|
---|
150 |
|
---|
151 |
|
---|
152 | if exist "%GSDLHOME%\local\setup.bat" (
|
---|
153 | echo.
|
---|
154 | echo Running %GSDLHOME%\local\setup.bat
|
---|
155 | cd "%GSDLHOME%\local"
|
---|
156 | call setup.bat
|
---|
157 | cd "%GSDLHOME%"
|
---|
158 | )
|
---|
159 |
|
---|
160 | setlocal enabledelayedexpansion
|
---|
161 |
|
---|
162 | if exist "%GSDLHOME%\local" (
|
---|
163 | set PATH=!GSDLHOME!\local\bin;!PATH!
|
---|
164 | )
|
---|
165 |
|
---|
166 | if exist "%GSDLHOME%\apache-httpd" (
|
---|
167 | echo +Adding in executable path for apache-httpd
|
---|
168 | set PATH=!GSDLHOME!\apache-httpd\!GSDLOS!\bin;!PATH!
|
---|
169 | set PATH=!GSDLHOME!\apache-httpd\!GSDLOS!\lib;!PATH!
|
---|
170 | )
|
---|
171 |
|
---|
172 | :: test writability of GSDLHOME
|
---|
173 | @call "!GSDLHOME!\bin\script\checkwritability.bat"
|
---|
174 |
|
---|
175 | ::::::::::::::::::::::::::::::
|
---|
176 | if "!GSDL3SRCHOME!" == "" (goto javacheck) else (goto done)
|
---|
177 |
|
---|
178 | :javacheck
|
---|
179 | :: Only for GS2: work out java, and if the bundled jre is found, then set Java env vars with it
|
---|
180 | :: Then the same java will be consistently available for all aspects of GS2 (server or GLI, and any subshells these launch)
|
---|
181 | echo.
|
---|
182 | set MINIMUM_JAVA_VERSION=1.5.0_00
|
---|
183 | echo GS2 installation: Checking for Java of version !MINIMUM_JAVA_VERSION! or above
|
---|
184 |
|
---|
185 | set BUNDLED_JRE=!GSDLHOME!\packages\jre
|
---|
186 | if exist "!BUNDLED_JRE!" (
|
---|
187 | set HINT=!BUNDLED_JRE!
|
---|
188 | ) else (
|
---|
189 | echo No bundled JRE
|
---|
190 | set HINT=
|
---|
191 | )
|
---|
192 |
|
---|
193 | set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\!GSDLOS!\search4j.exe
|
---|
194 | if not exist "!SEARCH4J_EXECUTABLE!" (
|
---|
195 | echo Can't check for java, no Search4j
|
---|
196 | if not exist "!BUNDLED_JRE!" echo Ensure Java environment variables are set ^(either JAVA_HOME or JRE_HOME and on PATH^) & goto done
|
---|
197 | :: else use Bundled JRE
|
---|
198 | echo Will use the bundled JRE and unset any JAVA_HOME to prevent conflicts
|
---|
199 | set JAVA_HOME=
|
---|
200 | set JRE_HOME=!BUNDLED_JRE!
|
---|
201 | set PATH=!BUNDLED_JRE!\bin;!PATH!
|
---|
202 | goto done
|
---|
203 | )
|
---|
204 |
|
---|
205 | :: Need the call stmt, the usebackq with backticks around the full command, AND the double quotes around filepaths to properly handle spaces in the filepaths
|
---|
206 | for /f "usebackq tokens=*" %%r in (`call "!GSDLHOME!\bin\!GSDLOS!\search4j.exe" -p "!HINT!" -m !MINIMUM_JAVA_VERSION!`) do set GS_JAVA_HOME=%%r
|
---|
207 |
|
---|
208 |
|
---|
209 | if "!GS_JAVA_HOME!" == "" (
|
---|
210 | if not exist "!BUNDLED_JRE!" echo There's no bundled JRE.
|
---|
211 | echo setup.bat: Could not find Java in the environment or installation.
|
---|
212 | echo Set JAVA_HOME or JRE_HOME, and put it on the PATH, if working with Java tools like Lucene.
|
---|
213 | goto done
|
---|
214 | )
|
---|
215 |
|
---|
216 | :: found java, now GS_JAVA_HOME env vars set, set JAVA_HOME else JRE_HOME
|
---|
217 |
|
---|
218 | if "!GS_JAVA_HOME!" == "!BUNDLED_JRE!" (
|
---|
219 | :: since our bundled JRE was selected by search4j and we'll be using that, clearing any existing JAVA_HOME to prevent version conflicts
|
---|
220 | echo Found a bundled JRE. Setting up GS2's Java environment to use this ^(and unsetting any JAVA_HOME to prevent version conflicts^)
|
---|
221 | set JAVA_HOME=
|
---|
222 | set JRE_HOME=!BUNDLED_JRE!
|
---|
223 | set PATH=!BUNDLED_JRE!\bin;!PATH!
|
---|
224 | goto done
|
---|
225 | )
|
---|
226 |
|
---|
227 | :: Otherwise, the java that search4j found is not the bundled jre. In that case
|
---|
228 | :: if JAVA_HOME or JRE_HOME is already set to the Java found, then PATH presumably would already be set too.
|
---|
229 | if "!JAVA_HOME!" == "!GS_JAVA_HOME!" (
|
---|
230 | echo Looks like the Java environment is already set up with a JAVA_HOME
|
---|
231 | ::echo Looks like the Java environment is already set up with a JAVA_HOME, unsetting any JRE_HOME
|
---|
232 | goto done
|
---|
233 | )
|
---|
234 | if "!JRE_HOME!" == "!GS_JAVA_HOME!" (
|
---|
235 | echo Looks like the Java environment is already set up with a JRE_HOME, unsetting any JAVA_HOME to prevent java version conflicts
|
---|
236 | set JAVA_HOME=
|
---|
237 | goto done
|
---|
238 | )
|
---|
239 |
|
---|
240 | :: if Java env vars not already set, then set them to the GS_JAVA_HOME found
|
---|
241 | echo Found a Java on the system. Setting up GS2's Java environment to use this
|
---|
242 | ::echo Found a Java on the system. Setting up GS2's Java environment to use this: !GS_JAVA_HOME!
|
---|
243 | set PATH=!GS_JAVA_HOME!\bin;!PATH!
|
---|
244 | :: extract the last 4 chars from folder name. Could be \jre or jre\ or otherwise
|
---|
245 | set javafoldername=!GS_JAVA_HOME:~-4!
|
---|
246 | :: now can test if the foldername contains jre or otherwise, and based on that set either JAVA_HOME or JRE_HOME
|
---|
247 | :: https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file
|
---|
248 | :: https://ss64.com/nt/syntax-substring.html
|
---|
249 | if /i "x!javafoldername:jre=!" == "x!javafoldername!" (
|
---|
250 | echo Setting JAVA_HOME, and unsetting any JRE_HOME to prevent version conflicts
|
---|
251 | set JAVA_HOME=!GS_JAVA_HOME!
|
---|
252 | set JRE_HOME=
|
---|
253 | ) else (
|
---|
254 | echo Setting JRE_HOME, and unsetting any JAVA_HOME to prevent version conflicts
|
---|
255 | set JRE_HOME=!GS_JAVA_HOME!
|
---|
256 | set JAVA_HOME=
|
---|
257 | )
|
---|
258 |
|
---|
259 | ::::::::::::::::::::::::::::::
|
---|
260 |
|
---|
261 | :done
|
---|
262 |
|
---|
263 | :: COMMENTING OUT THE 2 LINES DETERMINING AND SETTING THE BITNESS (32/64) ON WIN MACHINES
|
---|
264 | :: AS IT MAY BE USEFUL IN FUTURE AND IT TOOK ME SOME TIME TO GET THESE LINES WORKING RIGHT
|
---|
265 | :: To know bitness (32 vs 64) of a Windows machine, the cmd is "SET Processor"
|
---|
266 | :: and look through the lines of output for the line PROCESSOR_ARCHITECTURE=x86
|
---|
267 | :: or PROCESSOR_ARCHITECTURE=x64. See techgenix.com/aquicktiptocheckoperatingsystemarchitecture/
|
---|
268 | :: The following runs the cmd "set Processor". Then, among the multiline output, it finds the line
|
---|
269 | :: containing "PROCESSOR_ARCHITECTURE", splits this line on the delimiter "=" and stores the 2nd token in %%G
|
---|
270 | :: Based on the example "_ping_cmd" at https://ss64.com/nt/for_cmd.html
|
---|
271 | :: REM for /f "tokens=2 delims==" %%G in ('set Processor ^|find "PROCESSOR_ARCHITECTURE"') do set BITNESS=%%G
|
---|
272 | :: Easier way to above: %PROCESSOR_ARCHITECTURE% already contains a value of amd64/x64 or x86. So don't need to run the "set Processor"
|
---|
273 | :: command and hunt for PROCESSOR_ARCHITECTURE line. See https://superuser.com/questions/321988/how-do-i-determine-if-my-windows-is-32-bit-or-64-bit-using-a-command
|
---|
274 | REM set BITNESS=%PROCESSOR_ARCHITECTURE%
|
---|
275 | :: BITNESS will now be "x86" for 32 bit or something like "amd64" or "x64" for 64 bit
|
---|
276 | :: From https://ss64.com/nt/syntax-substring.html
|
---|
277 | :: "To do a string comparison, remove the SearchString and compare the result with the original
|
---|
278 | :: variable before removal. If both strings are the same, then SearchString was not found:"
|
---|
279 | REM if /i "%BITNESS:64=%" == "%BITNESS%" (set BITNESS=32) else (set BITNESS=64)
|
---|
280 |
|
---|
281 |
|
---|
282 | popd
|
---|
283 | endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS%& set JRE_HOME=%JRE_HOME%& set JAVA_HOME=%JAVA_HOME%
|
---|
284 | REM & set BITNESS=%BITNESS%
|
---|
285 |
|
---|
286 | if not "%JAVA_HOME%" == "" echo JAVA_HOME: %JAVA_HOME%
|
---|
287 | if not "%JRE_HOME%" == "" echo JRE_HOME: %JRE_HOME%
|
---|
288 | :: if GS3, then we'll do some more checking such as bundled JRE if the bitness is right
|
---|
289 | if "%GSDL3SRCHOME%" == "" if "%JAVA_HOME%" == "" if "%JRE_HOME%" == "" echo Warning: Neither JAVA_HOME nor JRE_HOME set. Ensure one is set and on PATH.
|
---|
290 | if not "%GSDL3SRCHOME%" == "" if "%JAVA_HOME%" == "" if "%JRE_HOME%" == "" echo Neither JAVA_HOME nor JRE_HOME set. Will shortly check for bundled JRE of correct bitness.
|
---|
291 |
|
---|
292 | :: Perl >= v5.18.* randomises map iteration order within a process
|
---|
293 | set PERL_PERTURB_KEYS=0
|
---|
294 |
|
---|
295 | :: The user can customise wget flags like number of retries and setting timeouts in the Wgetrc file.
|
---|
296 | :: The WGETRC environment variable is used by wget to find a user wgetrc file overriding any system level one
|
---|
297 | :: https://www.gnu.org/software/wget/manual/html_node/Wgetrc-Location.html
|
---|
298 | set WGETRC=%GSDLHOME%/bin/%GSDLOS%/wgetrc
|
---|
299 |
|
---|
300 |
|
---|
301 | :: On other localse, like Chinese locales, for XMLParsers to read (XML) files
|
---|
302 | :: in UTF-8 encoding (instead of defaulting to encoding GBK when on Chinese locale),
|
---|
303 | :: need to pass -Dfile.encoding=UTF-8 to the JVM. Can have this passed to the JVM by
|
---|
304 | :: setting the JAVA_TOOL_OPTIONS environment variable to this here.
|
---|
305 | :: For example, the example at https://www.mkyong.com/java/how-to-read-utf-8-xml-file-in-java-sax-parser/
|
---|
306 | :: doesn't work in a Chinese locale until the program is run with
|
---|
307 | :: java -Dfile.encoding=UTF-8 <ReadXMLUTF8FileSAX>
|
---|
308 | ::
|
---|
309 | ::set JAVA_TOOL_OPTIONS=%JAVA_TOOL_OPTIONS% -Dfile.encoding=UTF-8
|
---|
310 | rem set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
|
---|