source: main/trunk/greenstone2/setup.bash@ 24363

Last change on this file since 24363 was 24363, checked in by ak19, 13 years ago

The method of locating perl has changed once more: util.pm now defines the fuction get_perl_exec which is used by other scripts to obtain the path to the perl executable they should use. On Windows, setup.bat sets up the PERLPATH env var to the perl included with Greenstone when working with binaries. The same is done for Linux for symmetry, although perl is not included with GS in a linux GS binary at present.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
RevLine 
[19156]1#!/bin/bash
[2719]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.
[6774]4gsdllang=""
[6892]5# encoding inputs and outputs
6gsdltoenc=""
7gsdlfromenc=""
[2719]8
[6774]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
[6892]12 gsdllang="$LC_ALL"
[6774]13elif test ! -z "$LANG"; then
[6892]14 gsdllang="$LANG"
[6774]15fi
16
[6892]17
[6774]18# note... all our output strings have the charset hard-coded, but
19# people may be using a different encoding in their terminal. LANG
[6892]20# strings look like "en_NZ.UTF-8".
[6774]21
[6892]22# Determine the requested output encoding
23case $gsdllang in
24 *.*)
25 gsdltoenc=`echo $gsdllang | sed 's/.*\.//'`
26 ;;
27esac
28
[6774]29# Our french and spanish strings are currently in iso-8859-1 encoding.
30case $gsdllang in
31 fr*|FR*)
32 gsdllang=fr
[6892]33 gsdlfromenc="iso-8859-1"
[6774]34 ;;
35 es*|ES*)
36 gsdllang=es
[6892]37 gsdlfromenc="iso-8859-1"
[6774]38 ;;
39 ru*|RU*)
40 gsdllang=ru
[6892]41 gsdlfromenc="koi8r"
[6774]42 ;;
43 *) # default
44 gsdllang=en
[6892]45 gsdlfromenc="iso-8859-1"
[6774]46 ;;
47esac
48
[6892]49# "iconv" is the program for converting text between encodings.
50gsdliconv=`which iconv 2>/dev/null`
[8734]51if test $? -ne 0 || test ! -x "$gsdliconv" || test -z "$gsdlfromenc" || test -z "$gsdltoenc"; then
[6892]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
[2719]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
[2709]68fi
[2719]69
70if test -n "$gsdl_not_sourced" ; then
[6774]71 case "$gsdllang" in
72 "es")
[6892]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
[6774]81 ;;
82 "fr")
[6892]83eval $gsdliconv <<EOF
[7029]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
[6892]90EOF
[6774]91 ;;
92 "ru")
[6892]93eval $gsdliconv <<EOF
94 ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
95 îÁÐÒÉÍÅÒ:
96 $ source setup.bash
97 ÉÌÉ
98 $ . ./setup.bash
99 ÎÅÔ
100 $ ./setup.bash
101EOF
[6774]102 ;;
103 *)
[6892]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
[6774]112 ;;
113 esac
[2719]114elif test -n "$GSDLHOME" ; then
[6774]115 case "$gsdllang" in
116 "es")
[6892]117 echo '¡Su ambiente ya está listo para Greenstone!' | eval $gsdliconv
[6774]118 ;;
119 "fr")
[6892]120 echo 'Votre environnement est déjà préparé pour Greenstone!' | eval $gsdliconv
[6774]121 ;;
122 "ru")
[6892]123 echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Greenstone!' | eval $gsdliconv
[6774]124 ;;
125 *)
[6820]126 echo 'Your environment is already set up for Greenstone!'
[6774]127 ;;
128 esac
[2719]129elif test ! -f setup.bash ; then
[6774]130 case "$gsdllang" in
131 "es")
[6892]132eval $gsdliconv <<EOF
133Usted debe compilar el guión desde el interior del directorio de inicio
134de Greenstone.
135EOF
[6774]136 ;;
137 "fr")
[6892]138echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone' | eval $gsdliconv
[6774]139 ;;
140 "ru")
[6892]141eval $gsdliconv <<EOF
142÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone
143EOF
[6774]144 ;;
145 *)
[6820]146 echo 'You must source the script from within the Greenstone home directory'
[6774]147 ;;
148 esac
[2719]149else
[2906]150 GSDLHOME=`pwd`
151 export GSDLHOME
[2943]152 GSDLOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
[2749]153 # check for running bash under cygwin
[2719]154 if test "`echo $GSDLOS | sed 's/cygwin//'`" != "$GSDLOS" ;
155 then
156 GSDLOS=windows
157 fi
[2906]158 export GSDLOS
159
[23878]160 # check for running bash under mingw
161 if test "`echo $GSDLOS | sed 's/mingw//'`" != "$GSDLOS" ;
162 then
163 GSDLOS=windows
164 fi
165 export GSDLOS
166
[23947]167 # Establish cpu architecture
168 # 32-bit or 64-bit?
169 UNAME_HW_MACH=`uname -m`
170
171# Original test
172# if test "`echo x$UNAME_HW_MACH | sed 's/^x.*_64$/x/'`" == "x" ;
173# then
174# GSDLARCH=64
175# else
176# GSDLARCH=32
177# fi
178
179 # Following test came from VirtualBox's Guest Additions autostart.sh
180 # (adapted for use in Greenstone)
181 case "$UNAME_HW_MACH" in
182 i[3456789]86|x86|i86pc)
183 GSDLARCH='32'
184 ;;
185 x86_64|amd64|AMD64)
186 GSDLARCH='64'
187 ;;
188 *)
189 echo "Unknown architecture: $UNAME_HW_MACH"
190 ;;
191 esac
192
193 # Only want non-trival GSDLARCH value set if there is evidence of
194 # the installed bin (lib, ...) directories using linux32, linux64
195 # (otherwise probably looking at an SVN compiled up version for single OS)
196 if test ! -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH" ;
197 then
198 GSDLARCH=""
199 fi
200
201 export GSDLARCH
202
203 PATH=$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS$GSDLARCH:$PATH
[2906]204 export PATH
[18188]205
[23588]206 if test "$GSDLOS" = "linux" ; then
[23947]207 LD_LIBRARY_PATH="$GSDLHOME/lib/$GSDLOS$GSDLARCH:$LD_LIBRARY_PATH"
[23588]208 export LD_LIBRARY_PATH
209 elif test "$GSDLOS" = "darwin" ; then
[23947]210 DYLD_LIBRARY_PATH="$GSDLHOME/lib/$GSDLOS$GSDLARCH:$DYLD_LIBRARY_PATH"
[23588]211 export DYLD_LIBRARY_PATH
212 fi
[20933]213
[17667]214 # Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
215
[23947]216if test -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH/imagemagick" ; then
217 PATH="$GSDLHOME/bin/$GSDLOS$GSDLARCH/imagemagick/bin:$PATH"
[17673]218 export PATH
[17667]219
[23947]220 MAGICK_HOME="$GSDLHOME/bin/$GSDLOS$GSDLARCH/imagemagick"
[17673]221 export MAGICK_HOME
[17667]222
[17673]223 if test "$GSDLOS" = "linux" ; then
[23947]224 LD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS$GSDLARCH/imagemagick/lib:$LD_LIBRARY_PATH"
[17667]225 export LD_LIBRARY_PATH
226
227 elif test "$GSDLOS" = "darwin" ; then
[23947]228 DYLD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS$GSDLARCH/imagemagick/lib:$DYLD_LIBRARY_PATH"
[17667]229 export DYLD_LIBRARY_PATH
[17673]230 fi
[17667]231fi
232
[17673]233
234 # 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
235 # for Windows please see setup.bat
[23947]236if test -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH/ghostscript" ; then
237 PATH="$GSDLHOME/bin/$GSDLOS$GSDLARCH/ghostscript/bin":"$PATH"
[17673]238 export PATH
[17667]239
[23947]240 GS_LIB="$GSDLHOME/bin/$GSDLOS$GSDLARCH/ghostscript/share/ghostscript/8.63/lib"
[17673]241 export GS_LIB
[17667]242
[23947]243 GS_FONTPATH="$GSDLHOME/bin/$GSDLOS$GSDLARCH/ghostscript/share/ghostscript/8.63/Resource/Font"
[17673]244 export GS_FONTPATH
[17667]245fi
246
[23588]247
[17667]248
[2906]249 MANPATH=$MANPATH:$GSDLHOME/packages/mg/man
250 export MANPATH
[6774]251 case "$gsdllang" in
252 "es")
[6892]253 echo 'Su ambiente ha sido configurado para correr los programas Greenstone.' | eval $gsdliconv
[6774]254 ;;
255 "fr")
[6892]256 echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone' | eval $gsdliconv
[6774]257 ;;
258 "ru")
[6892]259eval $gsdliconv <<EOF
260÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone
261EOF
[6774]262 ;;
263 *)
[6820]264 echo 'Your environment has successfully been set up to run Greenstone'
[6774]265 ;;
266 esac
[2719]267fi
268unset gsdl_not_sourced
[6892]269unset gsdliconv
270unset gsdlfromenc
271unset gsdltoenc
[14980]272
[23893]273if test "x$gsopt_noexts" != "x1" ; then
274 if test -e ext; then
275 for gsdl_ext in ext/*; do
276 if test -d $gsdl_ext; then
277 cd $gsdl_ext > /dev/null
278 if test -e setup.bash ; then
279 source ./setup.bash
280 fi
281 cd ../..
282 fi
283 done
[21603]284 fi
[14980]285fi
286
[23726]287if test -e apache-httpd ; then
288 echo "+Adding in executable path for apache-httpd"
[23947]289 PATH=$GSDLHOME/apache-httpd/$GSDLOS$GSDLARCH/bin:$PATH
[23726]290 export PATH
291
292 if test "$GSDLOS" = "linux" ; then
[23947]293 LD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS$GSDLARCH/lib:$LD_LIBRARY_PATH"
[23726]294 export LD_LIBRARY_PATH
295
296 elif test "$GSDLOS" = "darwin" ; then
[23947]297 DYLD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS$GSDLARCH/lib:$DYLD_LIBRARY_PATH"
[23726]298 export DYLD_LIBRARY_PATH
299 fi
300fi
301
[17667]302if test -e local ; then
[18488]303 if test -e local/setup.bash ; then
304 echo "Sourcing local/setup.bash"
305 cd local ; source setup.bash ; cd ..
306 fi
307
[17667]308 PATH=$GSDLHOME/local/bin:$PATH
309 export PATH
310 LD_LIBRARY_PATH=$GSDLHOME/local/lib:$LD_LIBRARY_PATH
311 export LD_LIBRARY_PATH
[14980]312fi
313
314
[20923]315# if the Perl-for-greenstone tarfile has been installed in the bin/linux
316# folder, then we set things up to use that, instead of a system perl
[23947]317if [ -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl" ] ; then
[21805]318
[24363]319 if [ -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/bin" ] ; then
320 PERLPATH=$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/bin
321 export PERLPATH
322 PATH=$PERLPATH:$PATH
323 export PATH
324 fi
[21805]325
326 if test "$GSDLOS" = "linux" ; then
[23947]327 LD_LIBRARY_PATH=$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/lib/5.8.9/i686-linux-thread-multi/CORE:$LD_LIBRARY_PATH
[21805]328 export LD_LIBRARY_PATH
329 elif test "$GSDLOS" = "darwin" ; then
[23947]330 DYLD_LIBRARY_PATH=$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/lib/5.8.9/darwin-thread-multi-2level/CORE:$DYLD_LIBRARY_PATH
[21805]331 export DYLD_LIBRARY_PATH
332 fi
333
[20923]334 if [ "x$PERL5LIB" = "x" ] ; then
[23947]335 PERL5LIB=$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/lib
[20923]336 else
[23947]337 PERL5LIB=$GSDLHOME/bin/$GSDLOS$GSDLARCH/perl/lib:$PERL5LIB
[20923]338 fi
339 export PERL5LIB
[21805]340
[20923]341 echo ""
342 echo "***** Perl installation detected inside Greenstone."
343 echo "Command-line scripts need to be run with \"perl -S ...\""
344 echo " e.g. perl -S import.pl -removeold demo"
345 echo ""
346# else we may in future need to update PERL5LIB with some other (further) locations
347fi
Note: See TracBrowser for help on using the repository browser.