Changeset 20189


Ignore:
Timestamp:
2009-08-10T12:03:41+12:00 (13 years ago)
Author:
kjdon
Message:

added a test for setup already sourced, and don't run again if it was the same greenstone. if it has been sourced for a differnet greenstone then print a message and carry on. exit changed to return otherwise it kills the shell in a sourced script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/gs3-setup.sh

    r20187 r20189  
    3535  if test ! -f gs3-setup.sh ; then
    3636    echo "You must source the script from within the Greenstone home directory"
    37     exit 1
    38   fi
    39 
     37    return 1
     38  fi
     39  return 0
     40}
     41
     42# if GSDL3SRCHOME is set, then we assume that we have already sourced the
     43# script so don't do it again. UNLESS, GSDL3SRCHOME doesn't match the
     44# current directory in which case it was a different gs3 installation, so lets
     45# do it now.x
     46function testAlreadySourced() {
     47  if [ ! -z "$GSDL3SRCHOME" ]; then
     48    localgs3sourcehome="`pwd`"
     49    if [ "$GSDL3SRCHOME" == "$localgs3sourcehome" ]; then
     50    echo "Your environment is already set up for Greenstone3"
     51    return 1
     52    fi
     53    echo "Your environment was set up for Greenstone 3 in $GSDL3SRCHOME."
     54    echo "Overwriting that set up for the current Greenstone 3 in $localgs3sourcehome"
     55  fi
     56  return 0
    4057}
    4158
     
    170187}
    171188
     189# Note: use return not exit from a sourced script otherwise it kills the shell
    172190echo
    173191testSource
     192if [ "$?" == "1" ]; then
     193return
     194fi
     195testAlreadySourced
     196if [ "$?" == "1" ]; then
     197return
     198fi
    174199setGS3ENV
    175200checkJava
Note: See TracChangeset for help on using the changeset viewer.