source: trunk/expeditee-setup.bash

Last change on this file was 772, checked in by davidb, 10 years ago

Files for being 'sourced' changed from .sh to .bash

  • Property svn:executable set to *
File size: 6.8 KB
Line 
1
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\.bash//`" ; then
83# if $0 contains "expeditee-setup.bash" 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.bash
97 o
98 $ . ./expeditee-setup.bash
99 no
100 $ ./expeditee-setup.bash
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.bash
107 ou
108 $ . ./expeditee-setup.bash
109 pas
110 $ ./expeditee-setup.bash
111EOF
112 ;;
113 "ru")
114eval $expiconv <<EOF
115 ïÛÉÂËÁ: õÄÏÓÔÏ×ÅÒØÔÅÓØ × ÉÓÔÏÞÎÉËÅ ÜÔÏÇÏ ÓËÒÉÐÔÁ. îÅ ÉÓÐÏÌÎÑÊÔÅ ÅÇÏ.
116 îÁÐÒÉÍÅÒ:
117 $ source expeditee-setup.bash
118 ÉÌÉ
119 $ . ./expeditee-setup.bash
120 ÎÅÔ
121 $ ./expeditee-setup.bash
122EOF
123 ;;
124 *)
125eval $expiconv <<EOF
126 Error: Make sure you source this script, not execute it. Eg:
127 $ source expeditee-setup.bash
128 or
129 $ . ./expeditee-setup.bash
130 not
131 $ ./expeditee-setup.bash
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.bash ; 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.bash
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 -f local-setup.bash ; then
249 echo "+ Sourcing local-setup.bash"
250 . ./local-setup.bash
251fi
252
253#which java >/dev/null 2>&1
254#
255#if [ $? != 0 ] ; then
256# echo "Unable to find a Java runtime" >2
257#else
258# echo "-----"
259# echo "To run the Expeditee Browser, type:"
260# echo " expeditee"
261# echo ""
262#fi
263
Note: See TracBrowser for help on using the repository browser.