Changeset 14728 for greenstone3/branches/3.03/gs3-setup.sh
- Timestamp:
- 2007-10-24T09:27:36+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/branches/3.03/gs3-setup.sh
r13824 r14728 1 1 # if this file is executed, /bin/sh is used, as we don't start with #! 2 2 # this should work under ash, bash, zsh, ksh, sh style shells. 3 4 3 # make sure we are sourced, and not run 5 4 6 if test "$0" != "`echo $0 | sed s/gs3-setup\.sh//`" ; then 7 # if $0 contains "gs3-setup.sh" we've been run... $0 is shellname if sourced. 8 # One exception is zsh has an option to set it temporarily to the script name 9 if test -z "$ZSH_NAME" ; then 10 # we aren't using zsh 11 gsdl_not_sourced=true 5 export RUNJAVA= 6 JRE_HOME= 7 JAVA_HOME= 8 CLASSPATH=$CLASSPATH 9 10 function testSource(){ 11 if test "$0" != "`echo $0 | sed s/gs3-setup\.sh//`" ; then 12 # if $0 contains "gs3-setup.sh" we've been run... $0 is shellname if sourced. 13 # One exception is zsh has an option to set it temporarily to the script name 14 if test -z "$ZSH_NAME" ; then 15 # we aren't using zsh 16 gsdl_not_sourced=true 17 fi 12 18 fi 13 fi14 19 15 if test -n "$gsdl_not_sourced" ; then16 echo " Error: Make sure you source this script, not execute it. Eg:"17 echo " $ source gs3-setup.sh"18 echo " or"19 echo " $ . ./gs3-setup.sh"20 echo " not"21 echo " $ ./gs3-setup.sh"22 unset gsdl_not_sourced23 exit 124 fi20 if test -n "$gsdl_not_sourced" ; then 21 echo " Error: Make sure you source this script, not execute it. Eg:" 22 echo " $ source gs3-setup.sh" 23 echo " or" 24 echo " $ . ./gs3-setup.sh" 25 echo " not" 26 echo " $ ./gs3-setup.sh" 27 unset gsdl_not_sourced 28 exit 1 29 fi 25 30 26 if test ! -f gs3-setup.sh ; then 27 echo "You must source the script from within the Greenstone home directory" 28 exit 1 29 fi 31 if test ! -f gs3-setup.sh ; then 32 echo "You must source the script from within the Greenstone home directory" 33 exit 1 34 fi 35 } 30 36 31 GSDL3SRCHOME=`pwd` 32 GSDL3HOME=$GSDL3SRCHOME/web 33 export GSDL3HOME 34 export GSDL3SRCHOME 35 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 36 # check for running bash under cygwin 37 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then 38 GSDLOS=windows 39 fi 40 export GSDLOS 37 function setGS3ENV(){ 38 GSDL3SRCHOME=`pwd` 39 GSDL3HOME=$GSDL3SRCHOME/web 40 export GSDL3HOME 41 export GSDL3SRCHOME 42 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 43 # check for running bash under cygwin 44 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then 45 GSDLOS=windows 46 fi 47 export GSDLOS 41 48 42 #change this if external tomcat43 TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat49 #change this if external tomcat 50 TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat 44 51 45 PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH46 export PATH47 MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man48 export MANPATH52 PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH 53 export PATH 54 MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man 55 export MANPATH 49 56 50 CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH 51 for JARFILE in $GSDL3SRCHOME/*.jar; do 52 CLASSPATH=$CLASSPATH:$JARFILE 53 done 54 for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do 55 CLASSPATH=$CLASSPATH:$JARFILE 56 done 57 for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do 58 CLASSPATH=$CLASSPATH:$JARFILE 59 done 60 for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do 61 CLASSPATH=$CLASSPATH:$JARFILE 62 done 63 for JARFILE in $GSDL3SRCHOME/build/*.jar; do 64 CLASSPATH=$CLASSPATH:$JARFILE 65 done 57 CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH 58 for JARFILE in $GSDL3SRCHOME/*.jar; do 59 CLASSPATH=$CLASSPATH:$JARFILE 60 done 61 for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do 62 CLASSPATH=$CLASSPATH:$JARFILE 63 done 64 for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do 65 CLASSPATH=$CLASSPATH:$JARFILE 66 done 67 for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do 68 CLASSPATH=$CLASSPATH:$JARFILE 69 done 70 for JARFILE in $GSDL3SRCHOME/build/*.jar; do 71 CLASSPATH=$CLASSPATH:$JARFILE 72 done 73 export CLASSPATH 74 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni 75 export LD_LIBRARY_PATH 76 ## for mac 77 DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni 78 export DYLD_LIBRARY_PATH 79 } 66 80 67 export CLASSPATH 81 function setJAVAHOME(){ 82 # see if we can find java 83 java="java" 84 jfound=1 85 jok=1 86 # if JREHOME, JRE_HOME is set, we'll use it to determine where java lives 87 if [ "$JRE_HOME" != "" ]; then 88 java="$JRE_HOME/bin/java" 89 export JRE_HOME=$JRE_HOME 90 elif [ "$JREHOME" != "" ]; then 91 java="$JREHOME/bin/java" 92 export JRE_HOME=$JREHOME 93 # JAVAHOME or JAVA_HOME is set we'll use it to determine where java lives, otherwise 94 # we just hope it's on the search path 95 elif [ "$JAVA_HOME" != "" ] ; then 96 java="$JAVA_HOME/bin/java" 97 export JAVA_HOME=$JAVA_HOME 98 elif [ "$JAVAHOME" != "" ] ; then 99 java="$JAVAHOME/bin/java" 100 export JAVA_HOME=$JAVAHOME 101 else 102 java=`which java 2> /dev/null` 103 if [ ! -x "$java" ]; then 104 echo "Failed to locate Java. You must install a java runtime environment" 105 echo "(version 1.4 or greater) before installing Greenstone 3." 106 pauseAndExit 107 else 108 export JRE_HOME=`echo $java | sed -n 's/[\\\/]bin[\\\/]java$//p'` 109 fi 110 fi 111 checkJAVAHOME 112 } 68 113 69 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni 70 export LD_LIBRARY_PATH 71 ## for mac 72 DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni 73 export DYLD_LIBRARY_PATH 114 function checkJAVAHOME(){ 115 # Make sure prerequisite environment variables are set 116 if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]; then 117 echo "Neither the JAVA_HOME nor the JRE_HOME environment variable is defined" 118 echo "At least one of these environment variable is needed to run Greenstone3" 119 pauseAndExit 120 else # check JRE_HOME 121 if [ -n "$JRE_HOME" ]; then 122 if [ ! -x "$JRE_HOME"/bin/java ]; then 123 echo "JRE_HOME: $JRE_HOME" 124 echo "Couldn't find $JRE_HOME/bin/java" 125 echo "The JRE_HOME environment variable is not defined correctly" 126 echo "This environment variable is needed to run this program" 127 pauseAndExit 128 else 129 export RUNJAVA="$JRE_HOME"/bin/java 130 checkVersion 131 fi 132 else 133 # check JAVA_HOME if JRE_HOME is not set 134 if [ -n "$JAVA_HOME" ]; then 135 if [ ! -x "$JAVA_HOME"/bin/java -o ! -x "$JAVA_HOME"/bin/javac ]; then 136 echo "JAVA_HOME: $JAVA_HOME" 137 echo "Couldn't find $JAVA_HOME/bin/java or $JAVA_HOME/bin/javac" 138 echo "The JAVA_HOME environment variable is not defined correctly" 139 echo "This environment variable is needed to run this program" 140 echo "NB: JAVA_HOME should point to a JDK not a JRE" 141 pauseAndExit 142 else 143 export RUNJAVA="$JAVA_HOME"/bin/java 144 checkVersion 145 fi 146 fi 147 fi 148 fi 149 } 74 150 75 76 # see if we can find java 77 java="java" 78 jfound=1 79 jok=1 80 # if JAVAHOME or JAVA_HOME is set we'll use it to determine where java lives, otherwise 81 # we just hope it's on the search path 82 if [ "$JAVA_HOME" != "" ] ; then 83 java="$JAVA_HOME/bin/java" 84 elif [ "$JAVAHOME" != "" ] ; then 85 java="$JAVAHOME/bin/java" 86 export JAVA_HOME=$JAVAHOME 87 else 88 java=`which java 2> /dev/null` 89 if [ ! -x "$java" ]; then 90 echo "Failed to locate Java. You must install a java runtime environment" 91 echo "(version 1.4 or greater) before installing Greenstone 3." 92 jfound=0 93 jok=0 94 else 95 export JAVA_HOME=`echo $java | sed -n 's/[\\\/]bin[\\\/]java$//p'` 96 fi 97 fi 151 function checkVersion(){ 98 152 if [ $jfound -eq 1 ]; then 99 javaversion=`$ java-version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'`153 javaversion=`$RUNJAVA -version 2>&1 | sed -n 's/^java version \"\(.*\)\"/\1/p'` 100 154 jvmajor=`echo $javaversion | sed -n 's/^\([0-9]*\).*$/\1/p'` 101 155 jvminor=`echo $javaversion | sed -n 's/^[0-9]*\.\([0-9]*\).*$/\1/p'` … … 113 167 echo "old to run Greenstone 3. Please install a new version of the JRE (version" 114 168 echo "1.4 or newer) and rerun this installation." 169 export RUNJAVA= 170 pauseAndExit 115 171 else 172 if [ -n "$JRE_HOME" ]; then 173 echo "JRE_HOME: $JRE_HOME" 174 export PATH="$JRE_HOME"\bin:$PATH 175 fi 176 if [ -n "$JAVA_HOME" ]; then 177 echo "JAVA_HOME: $JAVA_HOME" 178 export PATH="$JAVA_HOME"\bin:$PATH 179 fi 116 180 echo "Your environment has successfully been set up to run Greenstone3" 117 181 fi 118 119 #do we need to check for perl??? 120 # make sure perl is ok 121 #perl=`which perl 2> /dev/null` 122 # echo "perl: $perl" 123 #if [ ! -x "$perl" ] ; then 124 # echo "Greenstone 3 requires perl in order to operate but this installation" 125 # echo "could not detect perl on your system. Please ensure that perl is installed" 126 # echo "and is on your search path then rerun this installation script." 127 # exit 1 128 #fi 182 } 129 183 130 184 185 function pauseAndExit(){ 186 echo -n "Please press any key to continue... " 187 read 188 } 189 190 testSource 191 setGS3ENV 192 setJAVAHOME 131 193 132 194
Note:
See TracChangeset
for help on using the changeset viewer.