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

Last change on this file since 20138 was 20138, checked in by oranfry, 15 years ago

removed brackets causing display errors

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