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

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

modified these scripts so they don't polute the user's environment so much, to be more upfront about what their doing, and to make use of the search4j tool instead of searching and checking java with bash code

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
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
4#the purpose of this file is to check/set up the environment for greenstone3
5#sorts out
6# - gsdl3home
7# - java
8
9java_min_version=1.4.0_00
10
11
12function testSource(){
13
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
21 fi
22
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"
27 echo " $ . gs3-setup.sh"
28 echo " not"
29 echo " $ ./gs3-setup.sh"
30 unset gsdl_not_sourced
31 exit 1
32 fi
33
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
38
39}
40
41function setGS3ENV() {
42
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
49
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"
57
58 #change this if external tomcat
59 TOMCAT_HOME=$GSDL3SRCHOME/packages/tomcat
60
61
62 ## adjustments to users (existing) environment ##
63 if [ `isinpath "$PATH" "$GSDL3SRCHOME/bin"` == "false" ]; then
64 PATH=$GSDL3SRCHOME/bin/script:$GSDL3SRCHOME/bin:$PATH
65 export PATH
66 MANPATH=$MANPATH:$GSDL3SRCHOME/doc/man
67 export MANPATH
68 echo " - Adjusted PATH"
69 else
70 echo " - PATH already correct"
71 fi
72
73 if [ `isinpath "$CLASSPATH" "$GSDL3HOME/WEB-INF/classes"` == "false" ]; then
74 CLASSPATH=$GSDL3HOME/WEB-INF/classes:$GSDL3SRCHOME/resources/java:$CLASSPATH
75 for JARFILE in $GSDL3SRCHOME/*.jar; do
76 CLASSPATH=$CLASSPATH:$JARFILE
77 done
78 for JARFILE in $GSDL3SRCHOME/lib/jni/*.jar; do
79 CLASSPATH=$CLASSPATH:$JARFILE
80 done
81 for JARFILE in $GSDL3HOME/WEB-INF/lib/*.jar; do
82 CLASSPATH=$CLASSPATH:$JARFILE
83 done
84 for JARFILE in $TOMCAT_HOME/common/endorsed/*.jar; do
85 CLASSPATH=$CLASSPATH:$JARFILE
86 done
87 for JARFILE in $GSDL3SRCHOME/build/*.jar; do
88 CLASSPATH=$CLASSPATH:$JARFILE
89 done
90 export CLASSPATH
91 echo " - Adjusted CLASSPATH"
92 else
93 echo " - CLASSPATH already correct"
94 fi
95
96 if [ `isinpath "$LD_LIBRARY_PATH" "$GSDL3SRCHOME/lib/jni"` == "false" ]; then
97 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
98 export LD_LIBRARY_PATH
99 DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GSDL3SRCHOME/lib/jni
100 export DYLD_LIBRARY_PATH
101 echo " - Adjusted LD_LIBRARY_PATH"
102 else
103 echo " - LD_LIBRARY_PATH already correct"
104 fi
105 echo
106}
107
108function checkJava() {
109 echo "Checking Java"
110 #check java
111 bin/search4j -m $java_min_version &> /dev/null
112 if [ "$?" != "0" ]; then
113 echo " - Failed to locate java ($java_min_version or greater)"
114 bin/search4j &> /dev/null
115 if [ "$?" == "0" ]; then echo " (It looks like you hava java but it's too old)"; fi
116 echo " - Please set JAVA_HOME or JRE_HOME to point to an appropriate java"
117 echo " And add JAVA_HOME/bin or JRE_HOME/bin to your PATH"
118 else
119 echo " - Found java at: `bin/search4j -m $java_min_version`"
120 fi
121 echo
122}
123
124function pauseAndExit(){
125 echo -n "Please press any key to continue... "
126 read
127}
128
129function isinpath() {
130 for file in `echo $1 | sed 's/:/ /g'`; do
131 if [ "$file" == "$2" ]; then
132 echo true
133 return
134 fi
135 done
136 echo false
137}
138
139echo
140testSource
141setGS3ENV
142checkJava
Note: See TracBrowser for help on using the repository browser.