[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] | 4 | gsdllang=""
|
---|
[6892] | 5 | # encoding inputs and outputs
|
---|
| 6 | gsdltoenc=""
|
---|
| 7 | gsdlfromenc=""
|
---|
[2719] | 8 |
|
---|
[6774] | 9 | # see if the shell has any language environment variables set
|
---|
| 10 | # see locale(7) manpage for this ordering.
|
---|
| 11 | if test ! -z "$LC_ALL" ; then
|
---|
[6892] | 12 | gsdllang="$LC_ALL"
|
---|
[6774] | 13 | elif test ! -z "$LANG"; then
|
---|
[6892] | 14 | gsdllang="$LANG"
|
---|
[6774] | 15 | fi
|
---|
| 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
|
---|
| 23 | case $gsdllang in
|
---|
| 24 | *.*)
|
---|
| 25 | gsdltoenc=`echo $gsdllang | sed 's/.*\.//'`
|
---|
| 26 | ;;
|
---|
| 27 | esac
|
---|
| 28 |
|
---|
[6774] | 29 | # Our french and spanish strings are currently in iso-8859-1 encoding.
|
---|
| 30 | case $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 | ;;
|
---|
| 47 | esac
|
---|
| 48 |
|
---|
[6892] | 49 | # "iconv" is the program for converting text between encodings.
|
---|
| 50 | gsdliconv=`which iconv 2>/dev/null`
|
---|
[8734] | 51 | if 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"
|
---|
| 54 | else
|
---|
| 55 | # add the encodings
|
---|
| 56 | gsdliconv="$gsdliconv -f $gsdlfromenc -t $gsdltoenc"
|
---|
| 57 | fi
|
---|
| 58 |
|
---|
[2719] | 59 | # make sure we are sourced, and not run
|
---|
| 60 |
|
---|
| 61 | if 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] | 68 | fi
|
---|
[2719] | 69 |
|
---|
| 70 | if test -n "$gsdl_not_sourced" ; then
|
---|
[6774] | 71 | case "$gsdllang" in
|
---|
| 72 | "es")
|
---|
[6892] | 73 | eval $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
|
---|
| 80 | EOF
|
---|
[6774] | 81 | ;;
|
---|
| 82 | "fr")
|
---|
[6892] | 83 | eval $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] | 90 | EOF
|
---|
[6774] | 91 | ;;
|
---|
| 92 | "ru")
|
---|
[6892] | 93 | eval $gsdliconv <<EOF
|
---|
| 94 | ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
|
---|
| 95 | îÁÐÒÉÍÅÒ:
|
---|
| 96 | $ source setup.bash
|
---|
| 97 | ÉÌÉ
|
---|
| 98 | $ . ./setup.bash
|
---|
| 99 | ÎÅÔ
|
---|
| 100 | $ ./setup.bash
|
---|
| 101 | EOF
|
---|
[6774] | 102 | ;;
|
---|
| 103 | *)
|
---|
[6892] | 104 | eval $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
|
---|
| 111 | EOF
|
---|
[6774] | 112 | ;;
|
---|
| 113 | esac
|
---|
[2719] | 114 | elif 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] | 129 | elif test ! -f setup.bash ; then
|
---|
[6774] | 130 | case "$gsdllang" in
|
---|
| 131 | "es")
|
---|
[6892] | 132 | eval $gsdliconv <<EOF
|
---|
| 133 | Usted debe compilar el guión desde el interior del directorio de inicio
|
---|
| 134 | de Greenstone.
|
---|
| 135 | EOF
|
---|
[6774] | 136 | ;;
|
---|
| 137 | "fr")
|
---|
[6892] | 138 | echo 'Vous devez trouver la source du script dans le répertoire de base de Greenstone' | eval $gsdliconv
|
---|
[6774] | 139 | ;;
|
---|
| 140 | "ru")
|
---|
[6892] | 141 | eval $gsdliconv <<EOF
|
---|
| 142 | ÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Greenstone
|
---|
| 143 | EOF
|
---|
[6774] | 144 | ;;
|
---|
| 145 | *)
|
---|
[6820] | 146 | echo 'You must source the script from within the Greenstone home directory'
|
---|
[6774] | 147 | ;;
|
---|
| 148 | esac
|
---|
[2719] | 149 | else
|
---|
[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 |
|
---|
[18198] | 160 | PATH=$GSDLHOME/bin/$GSDLOS/wv/bin:$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS:$PATH
|
---|
[2906] | 161 | export PATH
|
---|
[18188] | 162 |
|
---|
| 163 | # Allow wvWare binary to find the required libraries.
|
---|
| 164 | if test "$GSDLOS" = "linux" ; then
|
---|
[18192] | 165 | LD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/wv/lib:$LD_LIBRARY_PATH"
|
---|
[18188] | 166 | export LD_LIBRARY_PATH
|
---|
| 167 |
|
---|
| 168 | elif test "$GSDLOS" = "darwin" ; then
|
---|
[18192] | 169 | DYLD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/wv/lib:$DYLD_LIBRARY_PATH"
|
---|
[18188] | 170 | export DYLD_LIBRARY_PATH
|
---|
| 171 | fi
|
---|
[17667] | 172 |
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | # Override Imagemagick and Ghostscript paths to the bundled applications shipped with greenstone if they exists otherwise use default environment variables.
|
---|
| 176 |
|
---|
[19156] | 177 | if test -d "$GSDLHOME/bin/$GSDLOS/imagemagick" ; then
|
---|
[17673] | 178 | PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/bin:$PATH"
|
---|
| 179 | export PATH
|
---|
[17667] | 180 |
|
---|
[17673] | 181 | MAGICK_HOME="$GSDLHOME/bin/$GSDLOS/imagemagick"
|
---|
| 182 | export MAGICK_HOME
|
---|
[17667] | 183 |
|
---|
[17673] | 184 | if test "$GSDLOS" = "linux" ; then
|
---|
[17667] | 185 | LD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/lib:$LD_LIBRARY_PATH"
|
---|
| 186 | export LD_LIBRARY_PATH
|
---|
| 187 |
|
---|
| 188 | elif test "$GSDLOS" = "darwin" ; then
|
---|
[17673] | 189 | DYLD_LIBRARY_PATH="$GSDLHOME/bin/$GSDLOS/imagemagick/lib:$DYLD_LIBRARY_PATH"
|
---|
[17667] | 190 | export DYLD_LIBRARY_PATH
|
---|
[17673] | 191 | fi
|
---|
[17667] | 192 | fi
|
---|
| 193 |
|
---|
[17673] | 194 |
|
---|
| 195 | # 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
|
---|
| 196 | # for Windows please see setup.bat
|
---|
[19156] | 197 | if test -d "$GSDLHOME/bin/$GSDLOS/ghostscript" ; then
|
---|
[17673] | 198 | PATH="$GSDLHOME/bin/$GSDLOS/ghostscript/bin":"$PATH"
|
---|
| 199 | export PATH
|
---|
[17667] | 200 |
|
---|
[17673] | 201 | GS_LIB="$GSDLHOME/bin/$GSDLOS/ghostscript/share/ghostscript/8.63/lib"
|
---|
| 202 | export GS_LIB
|
---|
[17667] | 203 |
|
---|
[17673] | 204 | GS_FONTPATH="$GSDLHOME/bin/$GSDLOS/ghostscript/share/ghostscript/8.63/Resource/Font"
|
---|
| 205 | export GS_FONTPATH
|
---|
[17667] | 206 | fi
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 |
|
---|
[2906] | 210 | MANPATH=$MANPATH:$GSDLHOME/packages/mg/man
|
---|
| 211 | export MANPATH
|
---|
[6774] | 212 | case "$gsdllang" in
|
---|
| 213 | "es")
|
---|
[6892] | 214 | echo 'Su ambiente ha sido configurado para correr los programas Greenstone.' | eval $gsdliconv
|
---|
[6774] | 215 | ;;
|
---|
| 216 | "fr")
|
---|
[6892] | 217 | echo 'Votre environnement a été configuére avec succès pour exécuter Greenstone' | eval $gsdliconv
|
---|
[6774] | 218 | ;;
|
---|
| 219 | "ru")
|
---|
[6892] | 220 | eval $gsdliconv <<EOF
|
---|
| 221 | ÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Greenstone
|
---|
| 222 | EOF
|
---|
[6774] | 223 | ;;
|
---|
| 224 | *)
|
---|
[6820] | 225 | echo 'Your environment has successfully been set up to run Greenstone'
|
---|
[6774] | 226 | ;;
|
---|
| 227 | esac
|
---|
[2719] | 228 | fi
|
---|
| 229 | unset gsdl_not_sourced
|
---|
[6892] | 230 | unset gsdliconv
|
---|
| 231 | unset gsdlfromenc
|
---|
| 232 | unset gsdltoenc
|
---|
[14980] | 233 |
|
---|
[17667] | 234 | if test -e ext ; then
|
---|
[14980] | 235 | for gsdl_ext in ext/* ; do
|
---|
[16795] | 236 | cd $gsdl_ext > /dev/null
|
---|
[17667] | 237 | if test -e setup.bash ; then
|
---|
[18985] | 238 | source ./setup.bash
|
---|
[14980] | 239 | fi
|
---|
| 240 | cd ../..
|
---|
| 241 | done
|
---|
| 242 | fi
|
---|
| 243 |
|
---|
[18488] | 244 | if test -e apache-httpd ; then
|
---|
| 245 | echo "Adding in executable path for apache-httpd"
|
---|
| 246 | PATH=$GSDLHOME/apache-httpd/$GSDLOS/bin:$PATH
|
---|
| 247 | export PATH
|
---|
[20342] | 248 |
|
---|
| 249 | if test "$GSDLOS" = "linux" ; then
|
---|
[20855] | 250 | LD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$LD_LIBRARY_PATH"
|
---|
[20342] | 251 | export LD_LIBRARY_PATH
|
---|
| 252 |
|
---|
| 253 | elif test "$GSDLOS" = "darwin" ; then
|
---|
[20855] | 254 | DYLD_LIBRARY_PATH="$GSDLHOME/apache-httpd/$GSDLOS/lib:$DYLD_LIBRARY_PATH"
|
---|
[20342] | 255 | export DYLD_LIBRARY_PATH
|
---|
| 256 | fi
|
---|
[18488] | 257 | fi
|
---|
| 258 |
|
---|
| 259 |
|
---|
[17667] | 260 | if test -e local ; then
|
---|
[18488] | 261 | if test -e local/setup.bash ; then
|
---|
| 262 | echo "Sourcing local/setup.bash"
|
---|
| 263 | cd local ; source setup.bash ; cd ..
|
---|
| 264 | fi
|
---|
| 265 |
|
---|
[17667] | 266 | PATH=$GSDLHOME/local/bin:$PATH
|
---|
| 267 | export PATH
|
---|
| 268 | LD_LIBRARY_PATH=$GSDLHOME/local/lib:$LD_LIBRARY_PATH
|
---|
| 269 | export LD_LIBRARY_PATH
|
---|
[14980] | 270 | fi
|
---|
| 271 |
|
---|
| 272 |
|
---|
[20923] | 273 | # if the Perl-for-greenstone tarfile has been installed in the bin/linux
|
---|
| 274 | # folder, then we set things up to use that, instead of a system perl
|
---|
| 275 | if [ -d "$GSDLHOME/bin/$GSDLOS/perl" ] ; then
|
---|
| 276 | PATH=$GSDLHOME/bin/$GSDLOS/perl/bin:$PATH
|
---|
| 277 | export PATH
|
---|
| 278 | LD_LIBRARY_PATH=$GSDLHOME/bin/$GSDLOS/perl/lib/5.8.9/i686-linux-thread-multi/CORE:$LD_LIBRARY_PATH
|
---|
| 279 | export LD_LIBRARY_PATH
|
---|
| 280 | if [ "x$PERL5LIB" = "x" ] ; then
|
---|
| 281 | PERL5LIB=$GSDLHOME/bin/$GSDLOS/perl/lib
|
---|
| 282 | else
|
---|
| 283 | PERL5LIB=$GSDLHOME/bin/$GSDLOS/perl/lib:$PERL5LIB
|
---|
| 284 | fi
|
---|
| 285 | export PERL5LIB
|
---|
| 286 | echo ""
|
---|
| 287 | echo "***** Perl installation detected inside Greenstone."
|
---|
| 288 | echo "Command-line scripts need to be run with \"perl -S ...\""
|
---|
| 289 | echo " e.g. perl -S import.pl -removeold demo"
|
---|
| 290 | echo ""
|
---|
| 291 | # else we may in future need to update PERL5LIB with some other (further) locations
|
---|
| 292 | fi
|
---|