Changeset 20077


Ignore:
Timestamp:
2009-07-22T17:26:26+12:00 (13 years ago)
Author:
oranfry
Message:

work (hopefully improvements) on gs3-setup.sh

File:
1 edited

Legend:

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

    r20059 r20077  
    6464
    6565  #PATH
    66   if [ `isinpath "$PATH" "$GSDL3SRCHOME/bin"` == "false" ]; then
    67     PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
    68     export PATH
    69     MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
    70     export MANPATH
    71     echo "  - Adjusted PATH"
     66  addtopath PATH "$GSDL3SRCHOME/bin/script"
     67  addtopath PATH "$GSDL3SRCHOME/bin"
     68  echo "  - Adjusted PATH"
     69
     70  #MANPATH
     71  addtopath MANPATH "$GSDL3SRCHOME/doc/man"
     72  echo "  - Adjusted MANPATH"
     73 
     74  #CLASSPATH
     75  addtopath CLASSPATH "$GSDL3HOME/WEB-INF/classes"
     76  addtopath CLASSPATH "$GSDL3SRCHOME/resources/java"
     77  for JARFILE in $GSDL3SRCHOME/*.jar; do
     78    addtopath CLASSPATH "$JARFILE"
     79  done
     80  for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
     81    addtopath CLASSPATH "$JARFILE"
     82  done
     83  for JARFILE in $GSDL3SRCHOME/lib/java/*.jar; do
     84    addtopath CLASSPATH "$JARFILE"
     85  done
     86  for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
     87    addtopath CLASSPATH "$JARFILE"
     88  done
     89  for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
     90    addtopath CLASSPATH "$JARFILE"
     91  done   
     92  for JARFILE in $GSDL3SRCHOME/build/*.jar; do
     93    addtopath CLASSPATH "$JARFILE"
     94  done
     95  echo "  - Adjusted CLASSPATH"
     96
     97  #LD_LIBRARY_PATH
     98  addtopath LD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni"
     99  addtopath DYLD_LIBRARY_PATH "$GSDL3SRCHOME/lib/jni"
     100  echo "  - Adjusted LD_LIBRARY_PATH and DYLD_LIBRARY_PATH"
     101
     102  #ant
     103  if [ -x "$GSDL3SRCHOME/packages/ant/bin/ant" ]; then
     104    ANT_HOME="$GSDL3SRCHOME/packages/ant"
     105    export ANT_HOME
     106    addtopath PATH "$ANT_HOME/bin"
     107    echo "  - Setup ant"
    72108  else
    73     echo "  - PATH already correct"
     109    which ant &> /dev/null
     110    if [ "$?" == "0" ]; then
     111      echo "  - Greenstone 'Ant' package missing - falling back to system Ant"
     112    else
     113      echo "  NOTE: Greenstone 'Ant' package missing - please install Ant yourself"
     114    fi
    74115  fi
    75116
    76   #CLASSPATH
    77   if [ `isinpath "$CLASSPATH" "$GSDL3HOME/WEB-INF/classes"` == "false" ]; then
    78     CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
    79     for JARFILE in $GSDL3SRCHOME/*.jar; do
    80       CLASSPATH=$CLASSPATH:$JARFILE
    81     done
    82     for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
    83       CLASSPATH=$CLASSPATH:$JARFILE
    84     done
    85     for JARFILE in $GSDL3SRCHOME/lib/java/*.jar; do
    86       CLASSPATH=$CLASSPATH:$JARFILE
    87     done
    88     for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
    89       CLASSPATH=$CLASSPATH:$JARFILE
    90     done
    91     for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
    92       CLASSPATH=$CLASSPATH:$JARFILE
    93     done   
    94     for JARFILE in $GSDL3SRCHOME/build/*.jar; do
    95       CLASSPATH=$CLASSPATH:$JARFILE
    96     done
    97     export CLASSPATH
    98     echo "  - Adjusted CLASSPATH"
    99   else
    100     echo "  - CLASSPATH already correct"
    101   fi
    102 
    103   #LD_LIBRARY_PATH
    104   if [ `isinpath "$LD_LIBRARY_PATH" "$GSDL3SRCHOME/lib/jni"` == "false" ]; then
    105     LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
    106     export LD_LIBRARY_PATH
    107     DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
    108     export DYLD_LIBRARY_PATH
    109     echo "  - Adjusted LD_LIBRARY_PATH"
    110   else
    111     echo "  - LD_LIBRARY_PATH already correct"
    112   fi
    113 
    114   #ant
    115   which ant &> /dev/null
    116   if [ "$?" != "0" ]; then
    117       ANT_HOME=$GSDL3SRCHOME/packages/ant
    118       PATH=$ANT_HOME/bin:$PATH
    119     echo "  - Setup ant"
    120   else
    121     echo "  - Ant already setup"
    122   fi
    123 
    124   echo
    125117}
    126118
    127119function checkJava() {
    128   echo "Checking Java"
    129120
    130121  HINT="`pwd`/packages/jre"
    131122  FOUNDJAVAHOME="`bin/search4j -p $HINT -m $java_min_version`"
    132   if [ "$?" != "0" ]; then
    133 
    134     #java is not set up already
    135     if [ "$?" == "0" ]; then
     123  if [ "$?" == "0" ]; then
    136124      #bundled java exists, set up
    137125      export JAVA_HOME="$FOUNDJAVAHOME"
    138       echo "  - Set (exported) JAVA_HOME to $FOUNDJAVAHOME"
    139     else
    140       #no java exists
    141       echo "  - Failed to locate java ($java_min_version or greater)"
     126      echo "  - Exported JAVA_HOME to $FOUNDJAVAHOME"
     127  else
     128      #no suitible java exists
     129      echo "  NOTE: Failed to locate java \($java_min_version or greater\)"
    142130      bin/search4j &> /dev/null;
    143       if [ "$?" == "0" ]; then echo "  (It looks like you hava java but it's too old)"; fi
    144       echo "  - Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
    145       echo "    And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
    146     fi
    147 
    148   else
    149 
    150     #java is already set up
    151     echo "  - Found java at: $FOUNDJAVAHOME"
    152 
     131      if [ "$?" == "0" ]; then echo "  \(It looks like you hava java but it's too old\)"; fi
     132      echo "  Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
     133      echo "  And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
    153134  fi
    154   echo
    155135}
    156136
     
    170150}
    171151
     152function addtopath() {
     153  cmd="PV=\$$1"
     154  eval $cmd
     155  if [ `isinpath "$PV" "$2"` == "false" ]; then
     156    #echo "$1 += $2"
     157    if [ "$PV" == "" ]; then
     158      cmd="$1=\"$2\""
     159    else
     160      cmd="$1=\"$2:\$$1\""
     161    fi
     162    eval $cmd
     163    export PATH
     164  fi
     165}
    172166echo
    173167testSource
Note: See TracChangeset for help on using the changeset viewer.