Index: /other-projects/ir-harvest/trunk/scripted-download/irharvest-setup.bash
===================================================================
--- /other-projects/ir-harvest/trunk/scripted-download/irharvest-setup.bash	(revision 30075)
+++ /other-projects/ir-harvest/trunk/scripted-download/irharvest-setup.bash	(revision 30075)
@@ -0,0 +1,261 @@
+
+# Script written to be compatible with a variety of 'sh' derived shells: 
+#   ash, bash, dash ...
+
+irhlang=""
+# encoding inputs and outputs
+irhtoenc=""
+irhfromenc=""
+
+# see if the shell has any language environment variables set
+# see locale(7) manpage for this ordering.
+if test ! -z "$LC_ALL" ; then
+  irhlang="$LC_ALL"
+elif test ! -z "$LANG"; then
+  irhlang="$LANG"
+fi
+
+
+# note... all our output strings have the charset hard-coded, but
+# people may be using a different encoding in their terminal. LANG
+# strings look like "en_NZ.UTF-8".
+
+# Determine the requested output encoding
+case $irhlang in
+  *.*)
+    irhtoenc=`echo $irhlang | sed 's/.*\.//'`
+    ;;
+esac
+
+# Our French and Spanish strings are in 'iso-8859-1' (Latin 1) encoding; 
+# Russian is the Cyrillic alphabet encoding, 'KOI8-R'
+case $irhlang in
+  fr*|FR*)
+    irhlang=fr
+    irhfromenc="iso-8859-1"
+  ;;
+  es*|ES*)
+    irhlang=es
+    irhfromenc="iso-8859-1"
+  ;;
+  ru*|RU*)
+    irhlang=ru
+    irhfromenc="koi8r"
+  ;;
+  *) # default
+    irhlang=en
+    irhfromenc="iso-8859-1"
+  ;;
+esac  
+
+# "iconv" is the program for converting text between encodings.
+irhiconv=`which iconv 2>/dev/null`
+if test $? -ne 0 || test ! -x "$irhiconv" || test -z "$irhfromenc" || test -z "$irhtoenc"; then
+# we can't convert encodings from some reason
+  irhiconv="cat"
+else
+# add the encodings
+  irhiconv="$irhiconv -f $irhfromenc -t $irhtoenc"
+fi
+
+
+# ASCII art generated at:
+#   http://patorjk.com/software/taag/
+# Font = Doom
+#
+echo " ___________       _   _                           _    "
+echo "|_   _| ___ \     | | | |                         | |   "
+echo "  | | | |_/ /_____| |_| | __ _ _ ____   _____  ___| |_  "
+echo "  | | |    /______|  _  |/ _\` | '__\ \ / / _ \/ __| __| "
+echo " _| |_| |\ \      | | | | (_| | |   \ V /  __/\__ \ |_  "
+echo " \___/\_| \_|     \_| |_/\__,_|_|    \_/ \___||___/\__| "
+echo
+echo "(C) 2015, University of Waikato, New Zealand"
+echo
+echo
+
+
+# make sure we are sourced, and not run
+
+if test "$0" != "`echo $0 | sed s/irharvest-setup\.bash//`" ; then
+# if $0 contains "irharvest-setup.bash" we've been run... $0 is shellname if sourced.
+# One exception is zsh has an option to set it temporarily to the script name
+  if test -z "$ZSH_NAME" ; then
+  # we aren't using zsh
+  irharvest_not_sourced=true
+  fi
+fi
+
+if test -n "$irharvest_not_sourced" ; then
+  case "$irhlang" in
+ "es")
+eval $irhiconv <<EOF
+      Error: Asegúrese de compilar este guión, no de ejecutarlo. P. ej.:
+         $ source irharvest-setup.bash
+      o
+         $ . ./irharvest-setup.bash
+      no
+         $ ./irharvest-setup.bash
+EOF
+  ;;
+  "fr")
+eval $irhiconv <<EOF
+      Erreur: Assurez-vous de "sourcer" le script, plutôt que de l'exécuter. Ex:
+         $ source irharvest-setup.bash
+      ou
+         $ . ./irharvest-setup.bash
+      pas
+         $ ./irharvest-setup.bash
+EOF
+  ;;
+  "ru")
+eval $irhiconv <<EOF
+      ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
+      îÁÐÒÉÍÅÒ:
+         $ source irharvest-setup.bash
+      ÉÌÉ
+         $ . ./irharvest-setup.bash
+      ÎÅÔ
+         $ ./irharvest-setup.bash
+EOF
+  ;;
+  *)
+eval $irhiconv <<EOF
+	Error: Make sure you source this script, not execute it. Eg:
+		$ source irharvest-setup.bash
+	or
+		$ . ./irharvest-setup.bash
+	not
+		$ ./irharvest-setup.bash
+EOF
+  ;;
+  esac
+elif test -n "$IRHARVEST_DOWNLOAD" ; then
+  case "$irhlang" in
+  "es")
+    echo '¡Su ambiente ya está listo para IR-Harvest!' | eval $irhiconv
+  ;;
+  "fr")
+    echo 'Votre environnement est déjà préparé pour IR-Harvest!' | eval $irhiconv
+ ;;
+  "ru")
+    echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÕÖÅ ÎÁÓÔÒÏÅÎÏ ÄÌÑ IR-Harvest!' | eval $irhiconv
+  ;;
+  *)
+    echo 'Your environment is already set up for IR-Harvest!'
+  ;;
+  esac
+elif test ! -f irharvest-setup.bash ; then
+  case "$irhlang" in
+    "es")
+      echo 'Usted debe compilar el guión desde el interior del directorio de inicio' | eval $irhiconv
+  ;;
+    "fr")
+      echo 'Vous devez trouver la source du script dans le répertoire de base de IR-Harvest' | eval $irhiconv
+  ;;
+    "ru")
+      echo '÷ÁÍ ÎÅÏÂÈÏÄÉÍ ÉÓÔÏÞÎÉË ÓËÒÉÐÔÁ ÉÚ ÂÁÚÏ×ÏÊ ÄÉÒÅËÔÏÒÉÉ IR-Harvest' | eval $irhiconv
+  ;;
+   *)
+      echo 'You must source the script from within the IR-Harvest home directory'
+  ;;
+  esac
+else
+  IRHARVEST_DOWNLOAD=`pwd`
+  export IRHARVEST_DOWNLOAD
+
+  if test "x$IRHOS" = "x" ; then
+    IRHOS=`uname -s | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+    # check for running sh/bash under cygwin
+    if test "`echo $IRHOS | sed 's/cygwin//'`" != "$IRHOS" ;
+    then
+      IRHOS=windows
+    fi
+  fi
+  export IRHOS
+
+  # check for running sh/bash under mingw
+  if test "`echo $IRHOS | sed 's/mingw//'`" != "$IRHOS" ;
+  then
+    IRHOS=windows
+  fi
+  export IRHOS
+
+  # Establish cpu architecture
+  # 32-bit or 64-bit?
+  UNAME_HW_MACH=`uname -m`
+
+  # Following test came from VirtualBox's Guest Additions autostart.bash
+  # (adapted for use in IR-Harvest)
+  case "$UNAME_HW_MACH" in
+    i[3456789]86|x86|i86pc)
+      IRHARCH='32bit'
+      ;;
+    x86_64|amd64|AMD64)
+      IRHARCH='64bit'
+      ;;
+    *)
+      echo "Unknown architecture: $UNAME_HW_MACH"
+      ;;
+  esac
+
+  # Only want non-trival IRHARCH value set if there is evidence of
+  # the installed bin (lib, ...) directories using linux32, linux64
+  # (otherwise probably looking at an SVN compiled up version for single OS)
+  if test ! -d "$IRHARVEST_DOWNLOAD/$IRHOS/$IRHARCH" ;
+  then 
+    IRHARCH=""
+  fi
+
+  export IRHARCH
+
+  PATH=$IRHARVEST_DOWNLOAD/script:$IRHARVEST_DOWNLOAD/$IRHOS/$IRHARCH:$PATH
+  export PATH
+  
+#  if test "$IRHOS" = "linux" ; then
+#      LD_LIBRARY_PATH="$IRHARVEST_DOWNLOAD/lib/$IRHOS$IRHARCH:$LD_LIBRARY_PATH"
+#	  export LD_LIBRARY_PATH
+#  elif test "$IRHOS" = "darwin" ; then
+#      DYLD_LIBRARY_PATH="$IRHARVEST_DOWNLOAD/lib/$IRHOS$IRHARCH:$DYLD_LIBRARY_PATH"
+#      export DYLD_LIBRARY_PATH
+#  fi
+ 
+#  MANPATH=$MANPATH:$IRHARVEST_DOWNLOAD/man
+#  export MANPATH
+
+  case "$irhlang" in
+    "es")
+      echo 'Su ambiente ha sido configurado para correr los programas IR-Harvest.' | eval $irhiconv
+    ;;
+    "fr")
+      echo 'Votre environnement a été configuére avec succès pour exécuter IR-Harvest' | eval $irhiconv
+    ;;
+    "ru")
+      echo '÷ÁÛÅ ÏËÒÕÖÅÎÉÅ ÂÙÌÏ ÕÓÐÅÛÎÏ ÎÁÓÔÒÏÅÎÏ, ÞÔÏÂÙ ÕÓÔÁÎÏ×ÉÔØ IR-Harvest' | eval $irhiconv
+    ;;
+    *)
+      echo 'Your environment has successfully been set up to run IR-Harvest'
+    ;;
+  esac
+fi
+unset irharvest_not_sourced
+unset irhiconv
+unset irhfromenc
+unset irhtoenc
+
+if test -f local-setup.bash ; then
+    echo "+ Sourcing local-setup.bash"
+    . ./local-setup.bash 
+fi
+
+#which java >/dev/null 2>&1 
+#
+#if [ $? != 0 ] ; then
+#  echo "Unable to find a Java runtime" >2
+#else 
+#  echo "-----"
+#  echo "To run the IR-Harvest Downloader, type:"
+#  echo "  irharvest-download"
+#  echo ""
+#fi
+
