source: greenstone3/trunk/gs3-setup.sh@ 15141

Last change on this file since 15141 was 15141, checked in by oranfry, 16 years ago

installer now puts bundled java in packages directory, updating this file to reflect that

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
RevLine 
[6433]1# if this file is executed, /bin/sh is used, as we don't start with #!
2# this should work under ash, bash, zsh, ksh, sh style shells.
3
[15131]4#the purpose of this file is to check/set up the environment for greenstone3
5#sorts out
6# - gsdl3home
7# - java
[14726]8
[15138]9java_min_version=1.5.0_00
[15131]10
11
[14726]12function testSource(){
[15131]13
[14726]14 if test "$0" != "`echo $0 | sed s/gs3-setup\.sh//`" ; then
15 # if $0 contains "gs3-setup.sh" we've been run... $0 is shellname if sourced.
16 # One exception is zsh has an option to set it temporarily to the script name
17 if test -z "$ZSH_NAME" ; then
18 # we aren't using zsh
19 gsdl_not_sourced=true
20 fi
[6433]21 fi
22
[14726]23 if test -n "$gsdl_not_sourced" ; then
24 echo " Error: Make sure you source this script, not execute it. Eg:"
25 echo " $ source gs3-setup.sh"
26 echo " or"
[15131]27 echo " $ . gs3-setup.sh"
[14726]28 echo " not"
29 echo " $ ./gs3-setup.sh"
30 unset gsdl_not_sourced
31 exit 1
32 fi
[6433]33
[14726]34 if test ! -f gs3-setup.sh ; then
35 echo "You must source the script from within the Greenstone home directory"
36 exit 1
37 fi
[15131]38
[14726]39}
[6433]40
[15131]41function setGS3ENV() {
[6433]42
[15131]43 echo "Setting up your environment for Greenstone3"
44 ## main greenstone environment variables ##
45 GSDL3SRCHOME=`pwd`
46 GSDL3HOME=$GSDL3SRCHOME/web
47 export GSDL3HOME
48 export GSDL3SRCHOME
[10645]49
[15131]50 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
51 # check for running bash under cygwin
52 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ; then
53 GSDLOS=windows
54 fi
55 export GSDLOS
56 echo " - Exported GSDL3HOME, GSDL3SRCHOME and GSDLOS"
[8060]57
[15131]58 #change this if external tomcat
59 TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
[10303]60
[6433]61
[15131]62 ## adjustments to users (existing) environment ##
[15134]63
64 #PATH
[15131]65 if [ `isinpath "$PATH" "$GSDL3SRCHOME/bin"` == "false" ]; then
66 PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
67 export PATH
68 MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
69 export MANPATH
70 echo " - Adjusted PATH"
71 else
72 echo " - PATH already correct"
73 fi
[6433]74
[15134]75 #CLASSPATH
[15131]76 if [ `isinpath "$CLASSPATH" "$GSDL3HOME/WEB-INF/classes"` == "false" ]; then
77 CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
78 for JARFILE in $GSDL3SRCHOME/*.jar; do
79 CLASSPATH=$CLASSPATH:$JARFILE
80 done
81 for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
82 CLASSPATH=$CLASSPATH:$JARFILE
83 done
84 for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
85 CLASSPATH=$CLASSPATH:$JARFILE
86 done
87 for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
88 CLASSPATH=$CLASSPATH:$JARFILE
89 done
90 for JARFILE in $GSDL3SRCHOME/build/*.jar; do
91 CLASSPATH=$CLASSPATH:$JARFILE
92 done
93 export CLASSPATH
94 echo " - Adjusted CLASSPATH"
95 else
96 echo " - CLASSPATH already correct"
97 fi
[8060]98
[15134]99 #LD_LIBRARY_PATH
[15131]100 if [ `isinpath "$LD_LIBRARY_PATH" "$GSDL3SRCHOME/lib/jni"` == "false" ]; then
101 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
102 export LD_LIBRARY_PATH
103 DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
104 export DYLD_LIBRARY_PATH
105 echo " - Adjusted LD_LIBRARY_PATH"
106 else
107 echo " - LD_LIBRARY_PATH already correct"
108 fi
[15134]109
110 #ant
111 which ant &> /dev/null
112 if [ "$?" != "0" ]; then
[15138]113 ANT_HOME=$GSDL3SRCHOME/packages/ant
[15134]114 PATH=$ANT_HOME/bin:$PATH
115 echo " - Setup ant"
116 else
117 echo " - Ant already setup"
118 fi
119
[15131]120 echo
[14726]121}
[6433]122
[15131]123function checkJava() {
124 echo "Checking Java"
[15138]125
[15131]126 bin/search4j -m $java_min_version &> /dev/null
127 if [ "$?" != "0" ]; then
[15138]128
129 #java is not set up already
[15141]130 bin/search4j -m $java_min_version -h packages/jre &> /dev/null
[15138]131 if [ "$?" == "0" ]; then
132 #bundled java exists, set up
[15141]133 export JAVA_HOME=`pwd`/packages/jre
[15138]134 echo " - Exported JAVA_HOME to point to bundled java"
135 else
136 #no java exists
137 echo " - Failed to locate java ($java_min_version or greater)"
138 bin/search4j &> /dev/null; if [ "$?" == "0" ]; then echo " (It looks like you hava java but it's too old)"; fi
139 echo " - Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
140 echo " And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
141 fi
142
[15131]143 else
[15138]144
145 #java is already set up
[15131]146 echo " - Found java at: `bin/search4j -m $java_min_version`"
[15138]147
[15131]148 fi
149 echo
150}
[6433]151
[14726]152function pauseAndExit(){
153 echo -n "Please press any key to continue... "
154 read
155}
[6433]156
[15131]157function isinpath() {
158 for file in `echo $1 | sed 's/:/ /g'`; do
159 if [ "$file" == "$2" ]; then
160 echo true
161 return
162 fi
163 done
164 echo false
165}
166
167echo
[14726]168testSource
169setGS3ENV
[15131]170checkJava
Note: See TracBrowser for help on using the repository browser.