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