Changeset 551


Ignore:
Timestamp:
11/27/13 21:01:09 (10 years ago)
Author:
davidb
Message:

Greenstone inspired setup/devel scripting

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/expeditee-setup.sh

    r526 r551  
    11
    2 
    3 which >/dev/null java 2>&1
    4 
    5 if [ $? != 0 ] ; then
    6   echo "Unable to find a Java runtime"
    7 fi
    8 
    9 expeditee_home=`pwd`;
    10 
    11 if [ -z "$EXPEDITEE_HOME" ] ; then
    12   export EXPEDITEE_HOME="$expeditee_home"
    13   echo "Setting EXPEDITEE_HOME: "
    14   echo "  $EXPEDITEE_HOME"
    15 
    16   export PATH="$EXPEDITEE_HOME/script:$PATH"
    17   echo "Updating PATH to include Expeditee executables"
    18 fi
    19 
    20 
    21 echo "-----"
    22 echo "To run the Expeditee Browser, type:"
    23 echo "  expeditee"
    24 
    25 echo ""
    26 
     2# Script written to be compatible with a variety of 'sh' derived shells:
     3#   ash, bash, dash ...
     4
     5explang=""
     6# encoding inputs and outputs
     7exptoenc=""
     8expfromenc=""
     9
     10# see if the shell has any language environment variables set
     11# see locale(7) manpage for this ordering.
     12if test ! -z "$LC_ALL" ; then
     13  explang="$LC_ALL"
     14elif test ! -z "$LANG"; then
     15  explang="$LANG"
     16fi
     17
     18
     19# note... all our output strings have the charset hard-coded, but
     20# people may be using a different encoding in their terminal. LANG
     21# strings look like "en_NZ.UTF-8".
     22
     23# Determine the requested output encoding
     24case $explang in
     25  *.*)
     26    exptoenc=`echo $explang | sed 's/.*\.//'`
     27    ;;
     28esac
     29
     30# Our French and Spanish strings are in 'iso-8859-1' (Latin 1) encoding;
     31# Russian is the Cyrillic alphabet encoding, 'KOI8-R'
     32case $explang in
     33  fr*|FR*)
     34    explang=fr
     35    expfromenc="iso-8859-1"
     36  ;;
     37  es*|ES*)
     38    explang=es
     39    expfromenc="iso-8859-1"
     40  ;;
     41  ru*|RU*)
     42    explang=ru
     43    expfromenc="koi8r"
     44  ;;
     45  *) # default
     46    explang=en
     47    expfromenc="iso-8859-1"
     48  ;;
     49esac 
     50
     51# "iconv" is the program for converting text between encodings.
     52expiconv=`which iconv 2>/dev/null`
     53if test $? -ne 0 || test ! -x "$expiconv" || test -z "$expfromenc" || test -z "$exptoenc"; then
     54# we can't convert encodings from some reason
     55  expiconv="cat"
     56else
     57# add the encodings
     58  expiconv="$expiconv -f $expfromenc -t $exptoenc"
     59fi
     60
     61
     62# ASCII art generated at:
     63#   http://patorjk.com/software/taag/
     64# Font = Epic
     65#
     66echo " ______           ______  ______  ______  __________________ ______  ______ "
     67echo "(  ___ \|\     /|(  ___ )(  ___ \(  __  \ \__   __/\__   __/(  ___ \(  ___ \"
     68echo "| (   \/( \   / )| (   )|| (   \/| (  \  )   ) (      ) (   | (   \/| (   \/"
     69echo "| (_     \ (_) / | (___)|| (_    | |   ) |   | |      | |   | (_    | (_    "
     70echo "|  __)    ) _ (  |  ____)|  __)  | |   | |   | |      | |   |  __)  |  __)  "
     71echo "| (      / ( ) \ | (     | (     | |   ) |   | |      | |   | (     | (     "
     72echo "| (___/\( /   \ )| )     | (___/\| (__/  )___) (___   | |   | (___/\| (___/\"
     73echo "(______/|/     \||/      (______/(______/ \_______/   )_(   (______/(______/"
     74echo
     75echo (C) 2013, University of Waikato, New Zealand
     76echo
     77echo
     78echo
     79
     80# make sure we are sourced, and not run
     81
     82if test "$0" != "`echo $0 | sed s/expeditee-setup\.sh//`" ; then
     83# if $0 contains "expeditee-setup.sh" we've been run... $0 is shellname if sourced.
     84# One exception is zsh has an option to set it temporarily to the script name
     85  if test -z "$ZSH_NAME" ; then
     86  # we aren't using zsh
     87  expeditee_not_sourced=true
     88  fi
     89fi
     90
     91if test -n "$expeditee_not_sourced" ; then
     92  case "$explang" in
     93 "es")
     94eval $expiconv <<EOF
     95      Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:
     96         $ source expeditee-setup.sh
     97      o
     98         $ . ./expeditee-setup.sh
     99      no
     100         $ ./expeditee-setup.sh
     101EOF
     102  ;;
     103  "fr")
     104eval $expiconv <<EOF
     105      Erreur: Assurez-vous de "sourcer" le script, plutôt que de l'exécuter. Ex:
     106         $ source expeditee-setup.sh
     107      ou
     108         $ . ./expeditee-setup.sh
     109      pas
     110         $ ./expeditee-setup.sh
     111EOF
     112  ;;
     113  "ru")
     114eval $expiconv <<EOF
     115      ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
     116      îÁÐÒÉÍÅÒ:
     117         $ source expeditee-setup.sh
     118      ÉÌÉ
     119         $ . ./expeditee-setup.sh
     120      ÎÅÔ
     121         $ ./expeditee-setup.sh
     122EOF
     123  ;;
     124  *)
     125eval $expiconv <<EOF
     126        Error: Make sure you source this script, not execute it. Eg:
     127                $ source expeditee-setup.sh
     128        or
     129                $ . ./expeditee-setup.sh
     130        not
     131                $ ./expeditee-setup.sh
     132EOF
     133  ;;
     134  esac
     135elif test -n "$EXPEDITEE_HOME" ; then
     136  case "$explang" in
     137  "es")
     138    echo '¡Su ambiente ya está listo para Expeditee!' | eval $expiconv
     139  ;;
     140  "fr")
     141    echo 'Votre environnement est déjà préparé pour Expeditee!' | eval $expiconv
     142 ;;
     143  "ru")
     144    echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ Expeditee!' | eval $expiconv
     145  ;;
     146  *)
     147    echo 'Your environment is already set up for Expeditee!'
     148  ;;
     149  esac
     150elif test ! -f expeditee-setup.sh ; then
     151  case "$explang" in
     152    "es")
     153      echo 'Usted debe compilar el guión desde el interior del directorio de inicio' | eval $expiconv
     154  ;;
     155    "fr")
     156      echo 'Vous devez trouver la source du script dans le répertoire de base de Expeditee' | eval $expiconv
     157  ;;
     158    "ru")
     159      echo '÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ Expeditee' | eval $expiconv
     160  ;;
     161   *)
     162      echo 'You must source the script from within the Expeditee home directory'
     163  ;;
     164  esac
     165else
     166  EXPEDITEE_HOME=`pwd`
     167  export EXPEDITEE_HOME
     168
     169  if test "x$EXPOS" = "x" ; then
     170    EXPOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
     171    # check for running sh/bash under cygwin
     172    if test "`echo $EXPOS | sed 's/cygwin//'`" != "$EXPOS" ;
     173    then
     174      EXPOS=windows
     175    fi
     176  fi
     177  export EXPOS
     178
     179  # check for running sh/bash under mingw
     180  if test "`echo $EXPOS | sed 's/mingw//'`" != "$EXPOS" ;
     181  then
     182    EXPOS=windows
     183  fi
     184  export EXPOS
     185
     186  # Establish cpu architecture
     187  # 32-bit or 64-bit?
     188  UNAME_HW_MACH=`uname -m`
     189
     190  # Following test came from VirtualBox's Guest Additions autostart.sh
     191  # (adapted for use in Expeditee)
     192  case "$UNAME_HW_MACH" in
     193    i[3456789]86|x86|i86pc)
     194      EXPARCH='32bit'
     195      ;;
     196    x86_64|amd64|AMD64)
     197      EXPARCH='64bit'
     198      ;;
     199    *)
     200      echo "Unknown architecture: $UNAME_HW_MACH"
     201      ;;
     202  esac
     203
     204  # Only want non-trival EXPARCH value set if there is evidence of
     205  # the installed bin (lib, ...) directories using linux32, linux64
     206  # (otherwise probably looking at an SVN compiled up version for single OS)
     207  if test ! -d "$EXPEDITEE_HOME/$EXPOS/$EXPARCH" ;
     208  then
     209    EXPARCH=""
     210  fi
     211
     212  export EXPARCH
     213
     214  PATH=$EXPEDITEE_HOME/script:$EXPEDITEE_HOME/$EXPOS/$EXPARCH:$PATH
     215  export PATH
     216 
     217#  if test "$EXPOS" = "linux" ; then
     218#      LD_LIBRARY_PATH="$EXPEDITEE_HOME/lib/$EXPOS$EXPARCH:$LD_LIBRARY_PATH"
     219#         export LD_LIBRARY_PATH
     220#  elif test "$EXPOS" = "darwin" ; then
     221#      DYLD_LIBRARY_PATH="$EXPEDITEE_HOME/lib/$EXPOS$EXPARCH:$DYLD_LIBRARY_PATH"
     222#      export DYLD_LIBRARY_PATH
     223#  fi
     224 
     225#  MANPATH=$MANPATH:$EXPEDITEE_HOME/man
     226#  export MANPATH
     227
     228  case "$explang" in
     229    "es")
     230      echo 'Su ambiente ha sido configurado para correr los programas Expeditee.' | eval $expiconv
     231    ;;
     232    "fr")
     233      echo 'Votre environnement a été configuére avec succès pour exécuter Expeditee' | eval $expiconv
     234    ;;
     235    "ru")
     236      echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ Expeditee' | eval $expiconv
     237    ;;
     238    *)
     239      echo 'Your environment has successfully been set up to run Expeditee'
     240    ;;
     241  esac
     242fi
     243unset expeditee_not_sourced
     244unset expiconv
     245unset expfromenc
     246unset exptoenc
     247
     248if test -e local ; then
     249  if test -e local/setup.sh ; then
     250    echo "Sourcing local/setup.sh"
     251    cd local ; . ./setup.sh ; cd ..
     252  fi
     253fi
     254
     255#which >/dev/null java 2>&1
     256#
     257#if [ $? != 0 ] ; then
     258#  echo "Unable to find a Java runtime" >2
     259#else
     260#  echo "-----"
     261#  echo "To run the Expeditee Browser, type:"
     262#  echo "  expeditee"
     263#  echo ""
     264#fi
     265
Note: See TracChangeset for help on using the changeset viewer.