source: main/tags/2.83/gsdl/setup.bash@ 33064

Last change on this file since 33064 was 20933, checked in by oranfry, 14 years ago

modifications to environment vars LD_LIBRARY_PATH and PATH relating to wvWare on linux to be done in a narrower scope. this also fixes a probable bug which would have stopped the newer wvWare being used

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1#!/bin/bash
2# if this file is executed, /bin/sh is used, as we don't start with #!
3# this should work under ash, bash, zsh, ksh, sh style shells.
4gsdllang=""
5# encoding inputs and outputs
6gsdltoenc=""
7gsdlfromenc=""
8
9# see if the shell has any language environment variables set
10# see locale(7) manpage for this ordering.
11if test ! -z "$LC_ALL" ; then
12 gsdllang="$LC_ALL"
13elif test ! -z "$LANG"; then
14 gsdllang="$LANG"
15fi
16
17
18# note... all our output strings have the charset hard-coded, but
19# people may be using a different encoding in their terminal. LANG
20# strings look like "en_NZ.UTF-8".
21
22# Determine the requested output encoding
23case $gsdllang in
24 *.*)
25 gsdltoenc=`echo $gsdllang | sed 's/.*\.//'`
26 ;;
27esac
28
29# Our french and spanish strings are currently in iso-8859-1 encoding.
30case $gsdllang in
31 fr*|FR*)
32 gsdllang=fr
33 gsdlfromenc="iso-8859-1"
34 ;;
35 es*|ES*)
36 gsdllang=es
37 gsdlfromenc="iso-8859-1"
38 ;;
39 ru*|RU*)
40 gsdllang=ru
41 gsdlfromenc="koi8r"
42 ;;
43 *) # default
44 gsdllang=en
45 gsdlfromenc="iso-8859-1"
46 ;;
47esac
48
49# "iconv" is the program for converting text between encodings.
50gsdliconv=`which iconv 2>/dev/null`
51if test $? -ne 0 || test ! -x "$gsdliconv" || test -z "$gsdlfromenc" || test -z "$gsdltoenc"; then
52# we can't convert encodings from some reason
53 gsdliconv="cat"
54else
55# add the encodings
56 gsdliconv="$gsdliconv -f $gsdlfromenc -t $gsdltoenc"
57fi
58
59# make sure we are sourced, and not run
60
61if test "$0" != "`echo $0 | sed s/setup\.bash//`" ; then
62# if $0 contains "setup.bash" we've been run... $0 is shellname if sourced.
63# One exception is zsh has an option to set it temporarily to the script name
64 if test -z "$ZSH_NAME" ; then
65 # we aren't using zsh
66 gsdl_not_sourced=true
67 fi
68fi
69
70if test -n "$gsdl_not_sourced" ; then
71 case "$gsdllang" in
72 "es")
73eval $gsdliconv <<EOF
74 Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:
75 $ source setup.bash
76 o
77 $ . ./setup.bash
78 no
79 $ ./setup.bash
80EOF
81 ;;
82 "fr")
83eval $gsdliconv <<EOF
84 Erreur: Assurez-vous de "sourcer" le script, plutôt que de l'exécuter. Ex:
85 $ source setup.bash
86 ou
87 $ . ./setup.bash
88 pas
89 $ ./setup.bash
90EOF
91 ;;
92 "ru")
93eval $gsdliconv <<EOF
94 ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
95 îÁÐÒÉÍÅÒ:
96 $ source setup.bash
97 ÉÌÉ
98 $ . ./setup.bash
99 ÎÅÔ
100 $ ./setup.bash
101EOF
102 ;;
103 *)
104eval $gsdliconv <<EOF
105 Error: Make sure you source this script, not execute it. Eg:
106 $ source setup.bash
107 or
108 $ . ./setup.bash
109 not
110 $ ./setup.bash
111EOF
112 ;;
113 esac
114elif test -n "$GSDLHOME" ; then
115 case "$gsdllang" in
116 "es")
117 echo '¡Su ambiente ya está listo para Greenstone!' | eval $gsdliconv
118 ;;
119 "fr")
120 echo 'Votre environnement est déjà préparé pour Greenstone!' | eval $gsdliconv
121 ;;
122 "ru")
123 echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!' | eval $gsdliconv
124 ;;
125 *)
126 echo 'Your environment is already set up for Greenstone!'
127 ;;
128 esac
129elif test ! -f setup.bash ; then
130 case "$gsdllang" in
131 "es")
132eval $gsdliconv <<EOF
133Usted debe compilar el guión desde el interior del directorio de inicio
134de Greenstone.
135EOF
136 ;;
137 "fr")
138echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone' | eval $gsdliconv
139 ;;
140 "ru")
141eval $gsdliconv <<EOF
142÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone
143EOF
144 ;;
145 *)
146 echo 'You must source the script from within the Greenstone home directory'
147 ;;
148 esac
149else
150 GSDLHOME=`pwd`
151 export GSDLHOME
152 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
153 # check for running bash under cygwin
154 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
155 then
156 GSDLOS=windows
157 fi
158 export GSDLOS
159
160 PATH=$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS:$PATH
161 export PATH
162
163
164 # Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
165
166if test -d "$GSDLHOME/bin/$GSDLOS/imagemagick" ; then
167 PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/bin:$PATH"
168 export PATH
169
170 MAGICK_HOME="$GSDLHOME/bin/$GSDLOS/imagemagick"
171 export MAGICK_HOME
172
173 if test "$GSDLOS" = "linux" ; then
174 LD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/lib:$LD_LIBRARY_PATH"
175 export LD_LIBRARY_PATH
176
177 elif test "$GSDLOS" = "darwin" ; then
178 DYLD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/lib:$DYLD_LIBRARY_PATH"
179 export DYLD_LIBRARY_PATH
180 fi
181fi
182
183
184 # Note: Ghostscript is only bundled with Greenstone on Mac and Windows, not on Linux. The code below should be used only for the Darwin platform
185 # for Windows please see setup.bat
186if test -d "$GSDLHOME/bin/$GSDLOS/ghostscript" ; then
187 PATH="$GSDLHOME/bin/$GSDLOS/ghostscript/bin":"$PATH"
188 export PATH
189
190 GS_LIB="$GSDLHOME/bin/$GSDLOS/ghostscript/share/ghostscript/8.63/lib"
191 export GS_LIB
192
193 GS_FONTPATH="$GSDLHOME/bin/$GSDLOS/ghostscript/share/ghostscript/8.63/Resource/Font"
194 export GS_FONTPATH
195fi
196
197
198
199 MANPATH=$MANPATH:$GSDLHOME/packages/mg/man
200 export MANPATH
201 case "$gsdllang" in
202 "es")
203 echo 'Su ambiente ha sido configurado para correr los programas Greenstone.' | eval $gsdliconv
204 ;;
205 "fr")
206 echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone' | eval $gsdliconv
207 ;;
208 "ru")
209eval $gsdliconv <<EOF
210÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone
211EOF
212 ;;
213 *)
214 echo 'Your environment has successfully been set up to run Greenstone'
215 ;;
216 esac
217fi
218unset gsdl_not_sourced
219unset gsdliconv
220unset gsdlfromenc
221unset gsdltoenc
222
223if test -e ext ; then
224 for gsdl_ext in ext/* ; do
225 cd $gsdl_ext > /dev/null
226 if test -e setup.bash ; then
227 source ./setup.bash
228 fi
229 cd ../..
230 done
231fi
232
233if test -e apache-httpd ; then
234 echo "Adding in executable path for apache-httpd"
235 PATH=$GSDLHOME/apache-httpd/$GSDLOS/bin:$PATH
236 export PATH
237
238 if test "$GSDLOS" = "linux" ; then
239 LD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$LD_LIBRARY_PATH"
240 export LD_LIBRARY_PATH
241
242 elif test "$GSDLOS" = "darwin" ; then
243 DYLD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$DYLD_LIBRARY_PATH"
244 export DYLD_LIBRARY_PATH
245 fi
246fi
247
248
249if test -e local ; then
250 if test -e local/setup.bash ; then
251 echo "Sourcing local/setup.bash"
252 cd local ; source setup.bash ; cd ..
253 fi
254
255 PATH=$GSDLHOME/local/bin:$PATH
256 export PATH
257 LD_LIBRARY_PATH=$GSDLHOME/local/lib:$LD_LIBRARY_PATH
258 export LD_LIBRARY_PATH
259fi
260
261
262# if the Perl-for-greenstone tarfile has been installed in the bin/linux
263# folder, then we set things up to use that, instead of a system perl
264if [ -d "$GSDLHOME/bin/$GSDLOS/perl" ] ; then
265 PATH=$GSDLHOME/bin/$GSDLOS/perl/bin:$PATH
266 export PATH
267 LD_LIBRARY_PATH=$GSDLHOME/bin/$GSDLOS/perl/lib/5.8.9/i686-linux-thread-multi/CORE:$LD_LIBRARY_PATH
268 export LD_LIBRARY_PATH
269 if [ "x$PERL5LIB" = "x" ] ; then
270 PERL5LIB=$GSDLHOME/bin/$GSDLOS/perl/lib
271 else
272 PERL5LIB=$GSDLHOME/bin/$GSDLOS/perl/lib:$PERL5LIB
273 fi
274 export PERL5LIB
275 echo ""
276 echo "***** Perl installation detected inside Greenstone."
277 echo "Command-line scripts need to be run with \"perl -S ...\""
278 echo " e.g. perl -S import.pl -removeold demo"
279 echo ""
280# else we may in future need to update PERL5LIB with some other (further) locations
281fi
Note: See TracBrowser for help on using the repository browser.