1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # Function that, when given gsdlpath as parameter, will return the
|
---|
4 | # version of greenstone that is to run (2 or 3). If things are not,
|
---|
5 | # this program will exit here.
|
---|
6 | function get_version {
|
---|
7 | # first parameter is value of gsdlpath
|
---|
8 | if [ -f "${1}/gs3-setup.sh" ]; then
|
---|
9 | return 3
|
---|
10 | elif [ -f "${1}/setup.bash" ]; then
|
---|
11 | return 2
|
---|
12 | else
|
---|
13 | echo "Error: can't determine which Greenstone version is being run."
|
---|
14 | exit 1
|
---|
15 | fi
|
---|
16 | }
|
---|
17 |
|
---|
18 | # Function that is passed the following paramters (in order):
|
---|
19 | # - the gsdlpath (GS3 home, GS2 home or gs2build for GS3),
|
---|
20 | # - the version of greenstone that's running, and
|
---|
21 | # - the language GLI is set to
|
---|
22 | # and checks the installation.
|
---|
23 | # If things are not right, this program will exit here.
|
---|
24 | function check_installation {
|
---|
25 | # Check that the Greenstone installation looks OK
|
---|
26 | if [ "$3" = "es" ]; then
|
---|
27 | echo "Revisando GSDL$2: $1"
|
---|
28 | elif [ "$3" = "fr" ]; then
|
---|
29 | echo "Vérification de GSDL$2: $1"
|
---|
30 | elif [ "$3" = "ru" ]; then
|
---|
31 | echo "ðÒÏ×ÅÒËÁ GSDL$2: $1"
|
---|
32 | else
|
---|
33 | echo "Checking GSDL$2: $1"
|
---|
34 | fi
|
---|
35 | # even if we are only checking for gs2build (gsdl2path), we still
|
---|
36 | # need the file setup.bash to exist in the following condition:
|
---|
37 | if [ ! -f "${1}/gs3-setup.sh" -a ! -f "${1}/setup.bash" ] ; then
|
---|
38 | echo
|
---|
39 | if [ "$3" = "es" ]; then
|
---|
40 | echo "No se pudo encontrar la instalación de Greenstone $2 o está incompleta."
|
---|
41 | echo "Trate de reinstalar Greenstone $2 y a continuación ejecute nuevamente"
|
---|
42 | echo "este guión."
|
---|
43 | elif [ "$3" = "fr" ]; then
|
---|
44 | echo "L'installation de Greenstone $2 est introuvable ou incomplète."
|
---|
45 | echo "Essayez de réinstaller Greenstone $2 et exécutez ce script à nouveau."
|
---|
46 | elif [ "$3" = "ru" ]; then
|
---|
47 | echo "éÎÓÔÁÌÌÑÃÉÑ Greenstone $_version ÎÅ ÂÙÌÁ ÎÁÊÄÅÎÁ ÉÌÉ ÏÎÁ ÎÅÐÏÌÎÁ."
|
---|
48 | echo "ðÏÐÒÏÂÕÊÔÅ ÐÏ×ÔÏÒÎÏ ÕÓÔÁÎÏ×ÉÔØ Greenstone $2, Á ÚÁÔÅÍ ××ÅÓÔÉ ÜÔÏÔ ÓËÒÉÐÔ ÓÎÏ×Á."
|
---|
49 | else
|
---|
50 | echo "The Greenstone $2 installation could not be found, or is incomplete."
|
---|
51 | echo "Try reinstalling Greenstone $2 then running this script again."
|
---|
52 | fi
|
---|
53 | exit 1
|
---|
54 | fi
|
---|
55 | }
|
---|
56 |
|
---|
57 | glilang=en
|
---|
58 |
|
---|
59 | if [ "x$PROGNAME" = "x" ] ; then
|
---|
60 | if [ "$glilang" = "es" ]; then
|
---|
61 | PROGNAME="Biblioteca Digital Greenstone"
|
---|
62 | elif [ "$glilang" = "fr" ]; then
|
---|
63 | PROGNAME="Bibliothécaire Greenstone"
|
---|
64 | elif [ "$glilang" = "ru" ]; then
|
---|
65 | PROGNAME="ÉÎÔÅÒÆÅÊÓ Greenstone"
|
---|
66 | else
|
---|
67 | PROGNAME="Greenstone Librarian Interface"
|
---|
68 | fi
|
---|
69 | fi
|
---|
70 |
|
---|
71 | if [ "x$PROGABBR" = "x" ] ; then
|
---|
72 | PROGABBR="GLI"
|
---|
73 | fi
|
---|
74 |
|
---|
75 | if [ "x$PROGNAME_EN" = "x" ] ; then
|
---|
76 | PROGNAME_EN="Greenstone Librarian Interface"
|
---|
77 | fi
|
---|
78 |
|
---|
79 | echo
|
---|
80 | if [ "$glilang" = "es" ]; then
|
---|
81 | echo "Interfaz de la $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
82 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
83 | echo "La Interfaz de la $PROGNAME NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÍA."
|
---|
84 | echo "Para mayor información vea los términos de la licencia en LICENSE.txt"
|
---|
85 | echo "Este es un software abierto, por lo que lo invitamos a que lo distribuya de forma gratuita"
|
---|
86 | elif [ "$glilang" = "fr" ]; then
|
---|
87 | echo "Interface du $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
88 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
89 | echo "$PROGABBR est fourni sans AUCUNE GARANTIE; pour des détails, voir LICENSE.txt"
|
---|
90 | echo "Ceci est un logiciel libre, et vous êtes invité à le redistribuer"
|
---|
91 | elif [ "$glilang" = "ru" ]; then
|
---|
92 | echo "âÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
93 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
94 | echo "âéç ÎÅ ÄÁÅÔ áâóïìàôîï îéëáëéè çáòáîôéê; ÄÅÔÁÌÉ ÓÍ. × ÔÅËÓÔÅ LICENSE.TXT"
|
---|
95 | echo "üÔÏ - Ó×ÏÂÏÄÎÏ ÒÁÓÐÒÏÓÔÒÁÎÑÅÍÏÅ ÐÒÏÇÒÁÍÍÎÏÅ ÏÂÅÓÐÅÞÅÎÉÅ É ÷Ù ÍÏÖÅÔÅ ÒÁÓÐÒÏÓÔÒÁÎÑÔØ ÅÇÏ"
|
---|
96 | else
|
---|
97 | echo "$PROGNAME ($PROGABBR)"
|
---|
98 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
99 | echo "$PROGABBR comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
100 | echo "This is free software, and you are welcome to redistribute it"
|
---|
101 | fi
|
---|
102 | echo
|
---|
103 |
|
---|
104 | ## -------- Run the Greenstone Librarian Interface --------
|
---|
105 |
|
---|
106 | # This script must be run from within the directory in which it lives
|
---|
107 | thisdir=`pwd`
|
---|
108 | if [ ! -f "${thisdir}/gli.sh" ]; then
|
---|
109 | if [ "$glilang" = "es" ]; then
|
---|
110 | echo "Este guión deberá ejecutarse desde el directorio en el que reside."
|
---|
111 | elif [ "$glilang" = "fr" ]; then
|
---|
112 | echo "Ce script doit être exécuté à partir du répertoire dans lequel il se trouve."
|
---|
113 | elif [ "$glilang" = "ru" ]; then
|
---|
114 | echo "üÔÏÔ ÓËÒÉÐÔ ÄÏÌÖÅÎ ÂÙÔØ ×ÚÑÔ ÉÚ ÄÉÒÅËÔÏÒÉÉ, × ËÏÔÏÒÏÊ ÏÎ ÒÁÓÐÏÌÏÖÅÎ"
|
---|
115 | else
|
---|
116 | echo "This script must be run from the directory in which it resides."
|
---|
117 | fi
|
---|
118 | exit 1
|
---|
119 | fi
|
---|
120 |
|
---|
121 |
|
---|
122 | ## ---- Determine GSDLHOME ----
|
---|
123 | ## gsdlpath can be either Greenstone 3 or Greenstone 2
|
---|
124 | gsdlpath=
|
---|
125 | # Some users may set the above line manually
|
---|
126 |
|
---|
127 |
|
---|
128 | # This variable is set automatically:
|
---|
129 | _version=
|
---|
130 | if [ "x$gsdlpath" != "x" ]; then
|
---|
131 | get_version "$gsdlpath"
|
---|
132 | _version=$?
|
---|
133 | # otherwise $gsdlpath is not yet set
|
---|
134 | else
|
---|
135 | # Check the environment variable first
|
---|
136 | # Check whether environment variables for both GS2 and GS3 are set
|
---|
137 | # and if so, warn the user that we have defaulted to GS3
|
---|
138 | if [ "x$GSDLHOME" != "x" -a "x$GSDL3SRCHOME" != "x" ]; then
|
---|
139 | # _version not set, but both env vars set, so default to 3
|
---|
140 | _version=3
|
---|
141 | gsdlpath=$GSDL3SRCHOME
|
---|
142 | echo "Both Greenstone 2 and Greenstone 3 environments are set."
|
---|
143 | echo "It is assumed you want to run Greenstone 3."
|
---|
144 | echo "If you want to run Greenstone 2, please unset the"
|
---|
145 | echo "environment variable GSDL3SRCHOME before running GLI."
|
---|
146 | echo ""
|
---|
147 | elif [ "x$GSDL3SRCHOME" != "x" ]; then
|
---|
148 | echo "Only gsdl3srchome set"
|
---|
149 | gsdlpath=$GSDL3SRCHOME
|
---|
150 | _version=3
|
---|
151 | echo "$gsdlpath"
|
---|
152 | elif [ "x$GSDLHOME" != "x" ]; then
|
---|
153 | gsdlpath=$GSDLHOME
|
---|
154 | _version=2
|
---|
155 | # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone
|
---|
156 | else
|
---|
157 | gsdlpath=`(cd .. && pwd)`
|
---|
158 | # Still need to find what version we are running:
|
---|
159 | # GS3 main directory contains file gs3-setup.sh, GS2 only setup.bash
|
---|
160 | get_version "$gsdlpath"
|
---|
161 | _version=$?
|
---|
162 | fi
|
---|
163 | fi
|
---|
164 |
|
---|
165 | echo "Greenstone version found: $_version"
|
---|
166 |
|
---|
167 | # Check that the main Greenstone installation for the version we're running looks OK
|
---|
168 | check_installation "$gsdlpath" "$_version" "$glilang"
|
---|
169 |
|
---|
170 |
|
---|
171 | # Need to source the correct setup file depending on whether we are running
|
---|
172 | # gs3 or gs2
|
---|
173 | # If we're running version GS2
|
---|
174 | if [ "$_version" -eq 2 ]; then
|
---|
175 | # Setup Greenstone 2, unless it has already been done
|
---|
176 | if [ "x$GSDLHOME" = "x" ]; then
|
---|
177 | cd "$gsdlpath"
|
---|
178 | . ./setup.bash
|
---|
179 | cd "$thisdir"
|
---|
180 | fi
|
---|
181 | # else, if we're running GS3
|
---|
182 | elif [ "$_version" -eq 3 ]; then
|
---|
183 | # Setup Greenstone 3, unless it has already been done
|
---|
184 | if [ "x$GSDL3HOME" = "x" -o "x$GSDL3SRCHOME" = "x" ]; then
|
---|
185 | cd "$gsdlpath"
|
---|
186 | . ./gs3-setup.sh
|
---|
187 | cd "$thisdir"
|
---|
188 | fi
|
---|
189 |
|
---|
190 | ## if Greenstone version 3 is running, we want to set gsdl2path
|
---|
191 | ## ---- Determine GSDLHOME ----
|
---|
192 | ## may be already set, or manually entered here.
|
---|
193 | gsdl2path=
|
---|
194 |
|
---|
195 | # Some users may set the above line manually
|
---|
196 | if [ "x$gsdl2path" = "x" ]; then
|
---|
197 | # Check the environment variable first
|
---|
198 | if [ "x$GSDLHOME" != "x" ]; then
|
---|
199 | echo "GSDLHOME environment variable is set to $GSDLHOME."
|
---|
200 | echo "Will use this to find build scripts."
|
---|
201 | gsdl2path=$GSDLHOME
|
---|
202 | # If it is not set, assume that the gs2build subdirectory of Greenstone 3 exists
|
---|
203 | else
|
---|
204 | gsdl2path=$GSDL3SRCHOME/gs2build
|
---|
205 | fi
|
---|
206 | fi
|
---|
207 | # Check that Greenstone 3's Greenstone 2 stuff looks OK (in gs2build)
|
---|
208 | check_installation "$gsdl2path" "" "$glilang"
|
---|
209 |
|
---|
210 | # Setup Greenstone 3's gs2build, unless it has already been done
|
---|
211 | if [ "x$GSDLHOME" = "x" ]; then
|
---|
212 | cd "$gsdl2path"
|
---|
213 | . ./setup.bash
|
---|
214 | cd "$thisdir"
|
---|
215 | fi
|
---|
216 |
|
---|
217 | else
|
---|
218 | echo "Greenstone version unknown."
|
---|
219 | exit 1
|
---|
220 | fi
|
---|
221 |
|
---|
222 | echo
|
---|
223 | if [ "x$GSDL3SRCHOME" != "x" ]; then
|
---|
224 | echo "GSDL3SRCHOME is: $GSDL3SRCHOME"
|
---|
225 | fi
|
---|
226 | if [ "x$GSDL3HOME" != "x" ]; then
|
---|
227 | echo "GSDL3HOME is: $GSDL3HOME"
|
---|
228 | fi
|
---|
229 | if [ "x$GSDLHOME" != "x" ]; then
|
---|
230 | echo "GSDLHOME is: $GSDLHOME"
|
---|
231 | fi
|
---|
232 | echo
|
---|
233 |
|
---|
234 | ## ---- find perl ----
|
---|
235 | exit_status=0
|
---|
236 | ./findperl.sh
|
---|
237 | exit_status=$?
|
---|
238 | if [ "$exit_status" -eq 1 ]; then
|
---|
239 | exit 1;
|
---|
240 | fi
|
---|
241 |
|
---|
242 | ## ---- Check Java ----
|
---|
243 | # call the script with source, so that we have the variables it sets ($javapath)
|
---|
244 | exit_status=0
|
---|
245 | source ./findjava.sh
|
---|
246 | exit_status=$?
|
---|
247 | if [ "$exit_status" -eq 1 ]; then
|
---|
248 | exit 1;
|
---|
249 | fi
|
---|
250 |
|
---|
251 | ## ---- Check that the GLI has been compiled ----
|
---|
252 | if [ ! -f "classes/org/greenstone/gatherer/GathererProg.class" ] && [ ! -f "GLI.jar" ]; then
|
---|
253 | echo
|
---|
254 | if [ "$glilang" = "es" ]; then
|
---|
255 | echo "Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone"
|
---|
256 | echo "(por medio de makegli.sh) antes de ejecutar este guión."
|
---|
257 | elif [ "$glilang" = "fr" ]; then
|
---|
258 | echo "Vous devez compiler le Greenstone Interface (en utilisant makegli.sh)"
|
---|
259 | echo "avant d'exécuter ce script."
|
---|
260 | elif [ "$glilang" = "ru" ]; then
|
---|
261 | echo "÷Ù ÄÏÌÖÎÙ ËÏÍÐÉÌÉÒÏ×ÁÔØ ÂÉÂÌÉÏÔÅÞÎÙÊ ÉÎÔÅÒÆÅÊÓ Greenstone"
|
---|
262 | echo "(ÉÓÐÏÌØÚÕÑ makegli.sh) ÐÅÒÅÄ ××ÏÄÏÍ ÜÔÏÇÏ ÓËÒÉÐÔÁ"
|
---|
263 | else
|
---|
264 | echo "You need to compile the Greenstone Librarian Interface (using makegli.sh)"
|
---|
265 | echo "before running this script."
|
---|
266 | fi
|
---|
267 | exit 1
|
---|
268 | fi
|
---|
269 |
|
---|
270 | ## ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
|
---|
271 | if [ -e "$GSDLHOME/bin/$GSDLOS/ghostscript" ] ; then
|
---|
272 | echo "GhostScript bundled with Greenstone will be used, if you wish to use the version installed on your system (if any) please go to $GSDLHOME/bin/$GSDLOS and rename the folder called ghostscript to something else."
|
---|
273 | fi
|
---|
274 | echo
|
---|
275 | echo
|
---|
276 | if [ -e "$GSDLHOME/bin/$GSDLOS/imagemagick" ] ; then
|
---|
277 | echo "ImageMagick bundled with Greenstone will be used, if you wish to use the version installed on your system (if any) please go to $GSDLHOME/bin/$GSDLOS and rename the folder called imagemagick to something else."
|
---|
278 | echo
|
---|
279 | echo
|
---|
280 | fi
|
---|
281 |
|
---|
282 |
|
---|
283 | ## ---- Finally, run the GLI ----
|
---|
284 | if [ "$glilang" = "es" ]; then
|
---|
285 | echo "Ejecutando la Interfaz de la $PROGNAME..."
|
---|
286 | elif [ "$glilang" = "fr" ]; then
|
---|
287 | echo "Exécution de $PROGNAME..."
|
---|
288 | elif [ "$glilang" = "ru" ]; then
|
---|
289 | echo "ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..."
|
---|
290 | else
|
---|
291 | echo "Running the $PROGNAME..."
|
---|
292 | fi
|
---|
293 |
|
---|
294 | # basic_command is the cmd string common to both Greenstone 3 and Greenstone 2 execution
|
---|
295 | #basic_command="$javapath -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg"
|
---|
296 | stop_gli=0
|
---|
297 | while [ "$stop_gli" = "0" ] ; do
|
---|
298 |
|
---|
299 | # Other arguments you can provide to GLI to work around memory limitations, or debug
|
---|
300 | # -Xms<number>M To set minimum memory (by default 32MB)
|
---|
301 | # -Xmx<number>M To set maximum memory (by default the nearest 2^n to the total remaining physical memory)
|
---|
302 | # -verbose:gc To set garbage collection messages
|
---|
303 | # -Xincgc For incremental garbage collection (significantly slows performance)
|
---|
304 | # -Xprof Function call profiling
|
---|
305 | # -Xloggc:<file> Write garbage collection log
|
---|
306 |
|
---|
307 | exit_status=0
|
---|
308 | if [ "$_version" -eq 2 ]; then
|
---|
309 | # GS2 webLib
|
---|
310 | if [ "$PROGABBR" = "FLI" -o ! -f "$GSDLHOME/gs2-server.sh" ]; then
|
---|
311 | "$javapath" -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl "$GSDLHOME" -gsdlos $GSDLOS $*
|
---|
312 | exit_status=$?
|
---|
313 | # GS2 localLib
|
---|
314 | else
|
---|
315 | "$javapath" -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl "$GSDLHOME" -gsdlos $GSDLOS -local_library "$GSDLHOME/gs2-server.sh" $*
|
---|
316 | exit_status=$?
|
---|
317 | fi
|
---|
318 | # GS3
|
---|
319 | elif [ "$_version" -eq 3 ]; then
|
---|
320 | "$javapath" -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl "$GSDLHOME" -gsdlos $GSDLOS -gsdl3 "$GSDL3HOME" -gsdl3src "$GSDL3SRCHOME" $*
|
---|
321 | exit_status=$?
|
---|
322 | fi
|
---|
323 |
|
---|
324 | if [ "$exit_status" != "2" ] ; then
|
---|
325 | stop_gli=1
|
---|
326 | else
|
---|
327 | echo
|
---|
328 | if [ "$glilang" = "es" ]; then
|
---|
329 | echo "Restarting/Ejecutando la Interfaz de la $PROGNAME..."
|
---|
330 | elif [ "$glilang" = "fr" ]; then
|
---|
331 | echo "Restarting/Exécution de $PROGNAME..."
|
---|
332 | elif [ "$glilang" = "ru" ]; then
|
---|
333 | echo "Restarting/ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..."
|
---|
334 | else
|
---|
335 | echo "Restarting the $PROGNAME..."
|
---|
336 | fi
|
---|
337 | fi
|
---|
338 | done
|
---|
339 |
|
---|
340 | if [ "$glilang" = "es" ]; then
|
---|
341 | echo "¡Hecho!"
|
---|
342 | elif [ "$glilang" = "fr" ]; then
|
---|
343 | echo "Terminé!"
|
---|
344 | elif [ "$glilang" = "ru" ]; then
|
---|
345 | echo "÷ÙÐÏÌÎÅÎÏ!"
|
---|
346 | else
|
---|
347 | echo "Done!"
|
---|
348 | fi
|
---|