Changeset 34568
- Timestamp:
- 2020-11-26T14:06:49+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/gs3-setup.sh
r34317 r34568 43 43 # script so don't do it again. UNLESS, GSDL3SRCHOME doesn't match the 44 44 # current directory in which case it was a different gs3 installation, so lets 45 # do it now. x45 # do it now. 46 46 function testAlreadySourced() { 47 47 if [ ! -z "$GSDL3SRCHOME" ]; then 48 48 localgs3sourcehome="`pwd`" 49 if [ "$GSDL3SRCHOME" = ="$localgs3sourcehome" ]; then49 if [ "$GSDL3SRCHOME" = "$localgs3sourcehome" ]; then 50 50 echo "Your environment is already set up for Greenstone3" 51 51 return 1 … … 74 74 fi 75 75 export GSDLOS 76 echo " - Exported GSDL3HOME, GSDL3SRCHOME and GSDLOS" 76 echo " - Exported GSDL3HOME=$GSDL3HOME" 77 echo " GSDL3SRCHOME=$GSDL3SRCHOME" 78 echo " GSDLOS=$GSDLOS" 77 79 78 80 #change this if external tomcat … … 85 87 addtopath PATH "$GSDL3SRCHOME/bin" 86 88 echo " - Adjusted PATH" 89 if [ "$DEBUG" = "true" ]; then 90 echo " = $PATH" 91 fi 87 92 88 93 #MANPATH 89 94 addtopath MANPATH "$GSDL3SRCHOME/doc/man" 90 95 echo " - Adjusted MANPATH" 96 if [ "$DEBUG" = "true" ]; then 97 echo " = $MANPATH" 98 fi 91 99 92 100 #CLASSPATH … … 102 110 103 111 # Tomcat 5 jar files 112 if test -d "$TOMCAT_HOME"/common/endorsed ; then 104 113 for JARFILE in "$TOMCAT_HOME"/common/endorsed/*.jar; do 105 114 addtopath CLASSPATH "$JARFILE" 106 115 done 116 fi 107 117 # Tomcat 6 jar files 118 if test -d "$TOMCAT_HOME"/lib ; then 108 119 for JARFILE in "$TOMCAT_HOME"/lib/*.jar; do 109 120 addtopath CLASSPATH "$JARFILE" 110 121 done 111 122 fi 123 112 124 #shouldn't need these as they will have been copied to their correct locations elsewhere in the greenstone3 installation 113 125 #for JARFILE in "$GSDL3SRCHOME"/build/*.jar; do … … 116 128 117 129 echo " - Adjusted CLASSPATH" 130 if [ "$DEBUG" = "true" ]; then 131 echo " = $CLASSPATH" 132 fi 118 133 119 134 #LD_LIBRARY_PATH 120 135 addtopath LD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni" 121 136 addtopath DYLD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni" 122 echo " - Adjusted LD_LIBRARY_PATH and DYLD_LIBRARY_PATH" 137 echo " - Adjusted LD_LIBRARY_PATH" 138 if [ "$DEBUG" = "true" ]; then 139 echo " = $LD_LIBRARY_PATH" 140 fi 141 142 echo " - Adjusted DYLD_LIBRARY_PATH" 143 if [ "$DEBUG" = "true" ]; then 144 echo " = $DYLD_LIBRARY_PATH" 145 fi 123 146 124 147 #ImageMagick … … 165 188 BUNDLED_JRE="`pwd`/packages/jre" 166 189 HINT=$BUNDLED_JRE 167 168 #if [ "$GSDLOS" = "darwin" ] && [ ! -d "$HINT" ]; then 190 169 191 if [ "$GSDLOS" = "darwin" ]; then 170 if [ "$JAVA_HOME" != "" ] && [ -d "$JAVA_HOME" ]; then 192 # try $JAVA_HOME first, if it is set 193 if [ "$JAVA_HOME" != "" ] && [ -d "$JAVA_HOME" ]; then 171 194 HINT=$JAVA_HOME 172 elif [ ! -d "$HINT" ]; then 173 HINT=`/usr/libexec/java_home` 174 # old code used as fallback: 195 elif [ ! -d "$HINT" ]; then 196 #we test for the existence of bundled_jre - will be present in binary release. Use that if it is there as we know that it works with GS 197 # but if its not there, try the following: 198 # this will print out the path to java 199 HINT=`/usr/libexec/java_home` 200 # old code used as fallback: 201 # But actually this is not valid for Mojave and Catalina 175 202 if [ ! -d "$HINT" ]; then 176 203 HINT=/System/Library/Frameworks/JavaVM.framework/Home … … 179 206 fi 180 207 181 if [ "$DEBUG" = ="true" ]; then echo "**********************************************"; fi208 if [ "$DEBUG" = "true" ]; then echo "**********************************************"; fi 182 209 183 210 # If the file utility exists, use it to determine the bitness of this GS3, 184 # particularly of this GS3's lib \jni\libgdbmjava.so (gdbmjava.dll), since we prefer a matching java211 # particularly of this GS3's lib/jni/libgdbmjava.so/jnilib, since we prefer a matching java 185 212 # If any executable doesn't exist, the return value is 127. 186 213 # If file utility exists, then 0 is returned on successful execution, 1 is an error exit code … … 188 215 189 216 # Determine the bitness of this GS3 installation, by running: 190 # `file lib/jni/libgdbmjava.so `217 # `file lib/jni/libgdbmjava.so/jnilib` 191 218 # Output: 192 219 # lib/jni/libgdbmjava.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), … … 197 224 fileexists=`file 2&> /dev/null` 198 225 226 TESTFILE="$GSDL3SRCHOME/lib/jni/libgdbmjava.so" 227 if test "$GSDLOS" = "darwin"; then 228 TESTFILE="$GSDL3SRCHOME/lib/jni/libgdbmjava.jnilib" 229 fi 230 199 231 # Integer comparison, http://tldp.org/LDP/abs/html/comparison-ops.html 200 232 # can also use double brackets: if [[ $? > 1 ]]; then ... 201 233 if [ "$?" -gt "1" ]; then 202 if [ "$DEBUG" = ="true" ]; then234 if [ "$DEBUG" = "true" ]; then 203 235 echo " 'file' utility not found installed on this unix-based system." 204 236 echo " Unable to use 'file' utility to determine bitness of this GS3 to see if it matches that of any Java found." 205 237 fi 206 238 bitness=-1 207 elif [ ! -f "$ GSDL3SRCHOME/lib/jni/libgdbmjava.so" ]; then239 elif [ ! -f "$TESTFILE" ]; then 208 240 # the file we want to test the bitness of, to determine GS3's bitness by, doesn't exist yet 241 echo " $TESTFILE is not found, unable to determine bitness of this Greenstone3" 209 242 bitness=-1 210 243 else 211 bitness=`file $ GSDL3SRCHOME/lib/jni/libgdbmjava.so`212 if [[ $bitness = =*"64-bit"* ]]; then244 bitness=`file $TESTFILE` 245 if [[ $bitness = *"64-bit"* ]]; then 213 246 bitness=64 214 247 echo "The installed Greenstone is $bitness bit" 215 elif [[ $bitness = =*"32-bit"* ]]; then248 elif [[ $bitness = *"32-bit"* ]]; then 216 249 bitness=32 217 250 echo "The installed Greenstone is $bitness bit" … … 221 254 fi 222 255 fi 256 echo bitness = $bitness 223 257 224 258 # If search4j is present, use it to locate a java. … … 237 271 238 272 # 1. check the bitness of any JDK java found by search4j, and use if appropriate 239 if [ "$javahome_retval" = ="0" ]; then273 if [ "$javahome_retval" = "0" ]; then 240 274 setJavaIfOK "$DEBUG" "$bitness" "$FOUNDJAVAHOME" "JDK" 241 if [ "$?" = ="0" ]; then javaset="true"; fi275 if [ "$?" = "0" ]; then javaset="true"; fi 242 276 fi 243 277 244 278 # 2. check the bitness of any JRE java found by search4j, and use if appropriate 245 if [ "$javaset" != "true" ] && [ "$jrehome_retval" = ="0" ]; then279 if [ "$javaset" != "true" ] && [ "$jrehome_retval" = "0" ]; then 246 280 setJavaIfOK "$DEBUG" "$bitness" "$FOUNDJREHOME" "JRE" 247 if [ "$?" = ="0" ]; then javaset="true"; fi281 if [ "$?" = "0" ]; then javaset="true"; fi 248 282 fi 249 283 … … 252 286 if [ "$javaset" != "true" ] && [ -d "$BUNDLED_JRE" ]; then 253 287 setJavaIfOK "$DEBUG" "$bitness" "$BUNDLED_JRE" "bundled JRE" 254 if [ "$?" = ="0" ]; then javaset="true"; fi288 if [ "$?" = "0" ]; then javaset="true"; fi 255 289 fi 256 290 … … 262 296 if [ "$javaset" != "true" ]; then 263 297 # go with any JAVA_HOME else JRE_HOME that search4j found, else with any bundled JRE if present 264 if [ "$javahome_retval" = ="0" ]; then298 if [ "$javahome_retval" = "0" ]; then 265 299 setupJavaAt "$FOUNDJAVAHOME" "JDK" 266 300 javaset=true 267 elif [ "$jrehome_retval" = ="0" ]; then301 elif [ "$jrehome_retval" = "0" ]; then 268 302 setupJavaAt "$FOUNDJREHOME" "JRE" 269 303 javaset=true … … 290 324 #echo "*** Attempting to use JAVA_HOME else JRE_HOME in the environment" 291 325 echo "Checking for Java explicitly set through environment variables" 292 if [ "$JAVA_HOME" != "" ] && [ "`which java`" = ="$JAVA_HOME/bin/java" ]; then326 if [ "$JAVA_HOME" != "" ] && [ "`which java`" = "$JAVA_HOME/bin/java" ]; then 293 327 echo " - Using Java at $JAVA_HOME" 294 328 echo " - Detected Java version: `$JAVA_HOME/bin/java -version 2>&1 | head -n 1`" … … 297 331 # echo " The source distribution of Greenstone3 requires java 1.5 or greater" 298 332 # echo " (SVN users may still use java 1.4)" 299 elif [ "$JRE_HOME" != "" ] && [ "`which java`" = ="$JRE_HOME/bin/java" ]; then333 elif [ "$JRE_HOME" != "" ] && [ "`which java`" = "$JRE_HOME/bin/java" ]; then 300 334 echo " - Using java at $JRE_HOME" 301 335 echo " - Detected Java version: `$JAVA_HOME/bin/java -version 2>&1 | head -n 1`" … … 326 360 fi 327 361 checkJavaBitnessAgainstGSBitness "$JAVA_FOUND" "$bitness" 328 if [ "$?" = ="1" ]; then362 if [ "$?" = "1" ]; then 329 363 echo "*** WARNING: Detected mismatch between the bit-ness of your GS installation ($bitness bit)" 330 364 echo "*** and the Java found at $JAVA_FOUND/bin/java" … … 341 375 fi 342 376 343 if [ "$DEBUG" = ="true" ]; then echo "**********************************************"; fi377 if [ "$DEBUG" = "true" ]; then echo "**********************************************"; fi 344 378 345 379 } … … 348 382 function setJavaIfOK { 349 383 350 if [ "$DEBUG" = ="true" ]; then echo "Testing java at $3"; fi384 if [ "$DEBUG" = "true" ]; then echo "Testing java at $3"; fi 351 385 352 386 DEBUG=$1 … … 360 394 isjavaset=false 361 395 362 if [ "$check_status" = ="0" ]; then396 if [ "$check_status" = "0" ]; then 363 397 # http://tldp.org/LDP/abs/html/comparison-ops.html 364 if [ "$bitness" != "-1" ] && [ "$DEBUG" = ="true" ]; then398 if [ "$bitness" != "-1" ] && [ "$DEBUG" = "true" ]; then 365 399 # java matches GS bitness 366 if [[ "$JDKorJRE" = =*"bundled"* ]]; then400 if [[ "$JDKorJRE" = *"bundled"* ]]; then 367 401 echo "*** Changing to use Greenstone's $bitness-bit $JDKorJRE at $PATHTOJAVA" 368 402 else … … 373 407 isjavaset=true 374 408 375 elif [ "$bitness" != "-1" ] && [ "$DEBUG" = ="true" ]; then376 if [[ "$JDKorJRE" = =*"bundled"* ]]; then409 elif [ "$bitness" != "-1" ] && [ "$DEBUG" = "true" ]; then 410 if [[ "$JDKorJRE" = *"bundled"* ]]; then 377 411 echo " The $JDKorJRE java is an incompatible bit architecture" 378 412 else … … 381 415 fi 382 416 383 if [ "$isjavaset" = ="true" ]; then417 if [ "$isjavaset" = "true" ]; then 384 418 return 0 # success 385 419 else … … 390 424 # if bitness (parameter #2) is -1, then this function returns 0 (generally meaning success). 391 425 function checkJavaBitnessAgainstGSBitness() { 392 # if [ "$DEBUG" = ="true" ]; then echo "Testing bitness of java found at $java_installation"; fi426 # if [ "$DEBUG" = "true" ]; then echo "Testing bitness of java found at $java_installation"; fi 393 427 java_installation="$1" 394 428 bitness="$2" … … 396 430 # bitness can be -1 if the 'file' utility could not be found to determine bitness 397 431 # or if its output no longer prints "32-bit" or "64-bit". Should continue gracefully 398 if [ "$bitness" = ="-1" ]; then432 if [ "$bitness" = "-1" ]; then 399 433 return 0 400 434 fi … … 405 439 `$java_installation/bin/java -d$bitness -version 2> /dev/null` 406 440 407 if [ "$?" = ="0" ]; then441 if [ "$?" = "0" ]; then 408 442 return 0 409 elif [ "$?" = ="1" ]; then443 elif [ "$?" = "1" ]; then 410 444 411 445 # Newer Java's don't support -d, so result to using 'file' to determin bitness of 'java' binary 412 446 java_bitness=`file $java_installation/bin/java` 413 if [[ $java_bitness = =*"$bitness-bit"* ]]; then447 if [[ $java_bitness = *"$bitness-bit"* ]]; then 414 448 return 0 415 449 else … … 426 460 427 461 # check the second parameter if non-null 428 if [ -n "$2" ] && [ "$2" = ="JRE" ]; then462 if [ -n "$2" ] && [ "$2" = "JRE" ]; then 429 463 export JRE_HOME="$1" 430 464 addtopath PATH "$JRE_HOME/bin" 431 465 432 466 BUNDLED_JRE="`pwd`/packages/jre" 433 if [[ "$JRE_HOME" = =*"$BUNDLED_JRE"* ]]; then467 if [[ "$JRE_HOME" = *"$BUNDLED_JRE"* ]]; then 434 468 msg="the bundled" 435 469 fi … … 452 486 function isinpath() { 453 487 for file in `echo $1 | sed 's/:/ /g'`; do 454 if [ "$file" = ="$2" ]; then488 if [ "$file" = "$2" ]; then 455 489 echo true 456 490 return … … 463 497 eval "PV=\$$1" 464 498 #echo "$1 += $2" 465 if [ "$PV" = ="" ]; then499 if [ "$PV" = "" ]; then 466 500 cmd="$1=\"$2\"" 467 501 else … … 473 507 474 508 # Note: use return not exit from a sourced script otherwise it kills the shell 475 echo476 509 testSource 477 if [ "$?" = ="1" ]; then510 if [ "$?" = "1" ]; then 478 511 return 479 512 fi 513 480 514 testAlreadySourced 481 if [ "$?" = ="1" ]; then515 if [ "$?" = "1" ]; then 482 516 return 483 517 fi 518 484 519 setGS3ENV 520 521 echo "done" 485 522 486 523 if test -e gs2build/setup.bash ; then … … 534 571 else 535 572 which ant &> /dev/null 536 if [ "$?" = ="0" ]; then573 if [ "$?" = "0" ]; then 537 574 echo " - System install ant detected" 538 575 echo " - `ant -version`"
Note:
See TracChangeset
for help on using the changeset viewer.