source: other-projects/ir-harvest/trunk/scripted-download/irharvest-setup.bash@ 30075

Last change on this file since 30075 was 30075, checked in by davidb, 5 years ago

Initial cut at a setup file

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