[18634] | 1 | #!/bin/bash
|
---|
[15610] | 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.
|
---|
[18850] | 6 | function get_version {
|
---|
[15610] | 7 | # first parameter is value of gsdlpath
|
---|
| 8 | if [ -f "${1}/gs3-setup.sh" ]; then
|
---|
[17493] | 9 | return 3
|
---|
[15610] | 10 | elif [ -f "${1}/setup.bash" ]; then
|
---|
[17493] | 11 | return 2
|
---|
[15610] | 12 | else
|
---|
[17493] | 13 | echo "Error: can't determine which Greenstone version is being run."
|
---|
| 14 | exit 1
|
---|
[15610] | 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.
|
---|
[18850] | 24 | function check_installation {
|
---|
[15610] | 25 | # Check that the Greenstone installation looks OK
|
---|
| 26 | if [ "$3" = "es" ]; then
|
---|
[17493] | 27 | echo "Revisando GSDL$2: $1"
|
---|
[15610] | 28 | elif [ "$3" = "fr" ]; then
|
---|
[17493] | 29 | echo "Vérification de GSDL$2: $1"
|
---|
[15610] | 30 | elif [ "$3" = "ru" ]; then
|
---|
[17493] | 31 | echo "ðÒÏ×ÅÒËÁ GSDL$2: $1"
|
---|
[15610] | 32 | else
|
---|
[17493] | 33 | echo "Checking GSDL$2: $1"
|
---|
[15610] | 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
|
---|
[17493] | 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."
|
---|
[15610] | 52 | fi
|
---|
[17493] | 53 | exit 1
|
---|
| 54 | fi
|
---|
[15610] | 55 | }
|
---|
| 56 |
|
---|
[6752] | 57 | glilang=en
|
---|
[13251] | 58 |
|
---|
[14977] | 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 |
|
---|
[6262] | 79 | echo
|
---|
[12286] | 80 | if [ "$glilang" = "es" ]; then
|
---|
[14977] | 81 | echo "Interfaz de la $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
[12453] | 82 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
[14977] | 83 | echo "La Interfaz de la $PROGNAME NO INCLUYE ABSOLUTAMENTE NINGUNA GARANTÍA."
|
---|
[6959] | 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"
|
---|
[12286] | 86 | elif [ "$glilang" = "fr" ]; then
|
---|
[14977] | 87 | echo "Interface du $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
[12453] | 88 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
[14977] | 89 | echo "$PROGABBR est fourni sans AUCUNE GARANTIE; pour des détails, voir LICENSE.txt"
|
---|
[6955] | 90 | echo "Ceci est un logiciel libre, et vous êtes invité à le redistribuer"
|
---|
[12286] | 91 | elif [ "$glilang" = "ru" ]; then
|
---|
[14977] | 92 | echo "âÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME ($PROGNAME_EN - $PROGABBR)"
|
---|
[12453] | 93 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
[7041] | 94 | echo "âéç ÎÅ ÄÁÅÔ áâóïìàôîï îéëáëéè çáòáîôéê; ÄÅÔÁÌÉ ÓÍ. × ÔÅËÓÔÅ LICENSE.TXT"
|
---|
| 95 | echo "üÔÏ - Ó×ÏÂÏÄÎÏ ÒÁÓÐÒÏÓÔÒÁÎÑÅÍÏÅ ÐÒÏÇÒÁÍÍÎÏÅ ÏÂÅÓÐÅÞÅÎÉÅ É ÷Ù ÍÏÖÅÔÅ ÒÁÓÐÒÏÓÔÒÁÎÑÔØ ÅÇÏ"
|
---|
[6702] | 96 | else
|
---|
[14977] | 97 | echo "$PROGNAME ($PROGABBR)"
|
---|
[12453] | 98 | echo "Copyright (C) 2006, New Zealand Digital Library Project, University Of Waikato"
|
---|
[14977] | 99 | echo "$PROGABBR comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt"
|
---|
[6955] | 100 | echo "This is free software, and you are welcome to redistribute it"
|
---|
[6702] | 101 | fi
|
---|
[6223] | 102 | echo
|
---|
[4952] | 103 |
|
---|
[5003] | 104 | ## -------- Run the Greenstone Librarian Interface --------
|
---|
[19392] | 105 | # Need to run this script from its own directory instead of whichever directory it may be called from
|
---|
| 106 | #currentdir=$(cd `dirname "$0"` && pwd)
|
---|
| 107 | thisdir="`dirname \"$0\"`"
|
---|
| 108 | thisdir="`cd \"$thisdir\" && pwd`"
|
---|
| 109 | cd "$thisdir"
|
---|
[4952] | 110 |
|
---|
[4914] | 111 |
|
---|
[5003] | 112 | ## ---- Determine GSDLHOME ----
|
---|
[15610] | 113 | ## gsdlpath can be either Greenstone 3 or Greenstone 2
|
---|
[6624] | 114 | gsdlpath=
|
---|
[15610] | 115 | # Some users may set the above line manually
|
---|
[4952] | 116 |
|
---|
[15610] | 117 |
|
---|
| 118 | # This variable is set automatically:
|
---|
| 119 | _version=
|
---|
| 120 | if [ "x$gsdlpath" != "x" ]; then
|
---|
[19155] | 121 | get_version "$gsdlpath"
|
---|
[15610] | 122 | _version=$?
|
---|
| 123 | # otherwise $gsdlpath is not yet set
|
---|
| 124 | else
|
---|
[4952] | 125 | # Check the environment variable first
|
---|
[15610] | 126 | # Check whether environment variables for both GS2 and GS3 are set
|
---|
| 127 | # and if so, warn the user that we have defaulted to GS3
|
---|
| 128 | if [ "x$GSDLHOME" != "x" -a "x$GSDL3SRCHOME" != "x" ]; then
|
---|
| 129 | # _version not set, but both env vars set, so default to 3
|
---|
[17493] | 130 | _version=3
|
---|
| 131 | gsdlpath=$GSDL3SRCHOME
|
---|
| 132 | echo "Both Greenstone 2 and Greenstone 3 environments are set."
|
---|
| 133 | echo "It is assumed you want to run Greenstone 3."
|
---|
| 134 | echo "If you want to run Greenstone 2, please unset the"
|
---|
| 135 | echo "environment variable GSDL3SRCHOME before running GLI."
|
---|
| 136 | echo ""
|
---|
[15610] | 137 | elif [ "x$GSDL3SRCHOME" != "x" ]; then
|
---|
[17493] | 138 | echo "Only gsdl3srchome set"
|
---|
| 139 | gsdlpath=$GSDL3SRCHOME
|
---|
| 140 | _version=3
|
---|
| 141 | echo "$gsdlpath"
|
---|
[15610] | 142 | elif [ "x$GSDLHOME" != "x" ]; then
|
---|
[17493] | 143 | gsdlpath=$GSDLHOME
|
---|
| 144 | _version=2
|
---|
[4952] | 145 | # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone
|
---|
| 146 | else
|
---|
[17493] | 147 | gsdlpath=`(cd .. && pwd)`
|
---|
| 148 | # Still need to find what version we are running:
|
---|
| 149 | # GS3 main directory contains file gs3-setup.sh, GS2 only setup.bash
|
---|
[19155] | 150 | get_version "$gsdlpath"
|
---|
[17493] | 151 | _version=$?
|
---|
[4952] | 152 | fi
|
---|
| 153 | fi
|
---|
| 154 |
|
---|
[15626] | 155 | echo "Greenstone version found: $_version"
|
---|
[15610] | 156 |
|
---|
| 157 | # Check that the main Greenstone installation for the version we're running looks OK
|
---|
[19155] | 158 | check_installation "$gsdlpath" "$_version" "$glilang"
|
---|
[15610] | 159 |
|
---|
| 160 |
|
---|
| 161 | # Need to source the correct setup file depending on whether we are running
|
---|
| 162 | # gs3 or gs2
|
---|
| 163 | # If we're running version GS2
|
---|
| 164 | if [ "$_version" -eq 2 ]; then
|
---|
| 165 | # Setup Greenstone 2, unless it has already been done
|
---|
| 166 | if [ "x$GSDLHOME" = "x" ]; then
|
---|
[17493] | 167 | cd "$gsdlpath"
|
---|
[17670] | 168 | . ./setup.bash
|
---|
[17493] | 169 | cd "$thisdir"
|
---|
[6702] | 170 | fi
|
---|
[15610] | 171 | # else, if we're running GS3
|
---|
| 172 | elif [ "$_version" -eq 3 ]; then
|
---|
| 173 | # Setup Greenstone 3, unless it has already been done
|
---|
| 174 | if [ "x$GSDL3HOME" = "x" -o "x$GSDL3SRCHOME" = "x" ]; then
|
---|
[17493] | 175 | cd "$gsdlpath"
|
---|
[17670] | 176 | . ./gs3-setup.sh
|
---|
[17493] | 177 | cd "$thisdir"
|
---|
[15610] | 178 | fi
|
---|
| 179 |
|
---|
| 180 | ## if Greenstone version 3 is running, we want to set gsdl2path
|
---|
| 181 | ## ---- Determine GSDLHOME ----
|
---|
| 182 | ## may be already set, or manually entered here.
|
---|
| 183 | gsdl2path=
|
---|
| 184 |
|
---|
| 185 | # Some users may set the above line manually
|
---|
| 186 | if [ "x$gsdl2path" = "x" ]; then
|
---|
| 187 | # Check the environment variable first
|
---|
[17493] | 188 | if [ "x$GSDLHOME" != "x" ]; then
|
---|
| 189 | echo "GSDLHOME environment variable is set to $GSDLHOME."
|
---|
| 190 | echo "Will use this to find build scripts."
|
---|
| 191 | gsdl2path=$GSDLHOME
|
---|
[15610] | 192 | # If it is not set, assume that the gs2build subdirectory of Greenstone 3 exists
|
---|
[17493] | 193 | else
|
---|
| 194 | gsdl2path=$GSDL3SRCHOME/gs2build
|
---|
[15610] | 195 | fi
|
---|
[17493] | 196 | fi
|
---|
[15610] | 197 | # Check that Greenstone 3's Greenstone 2 stuff looks OK (in gs2build)
|
---|
[19155] | 198 | check_installation "$gsdl2path" "" "$glilang"
|
---|
[15610] | 199 |
|
---|
| 200 | # Setup Greenstone 3's gs2build, unless it has already been done
|
---|
| 201 | if [ "x$GSDLHOME" = "x" ]; then
|
---|
[17493] | 202 | cd "$gsdl2path"
|
---|
[17670] | 203 | . ./setup.bash
|
---|
[17493] | 204 | cd "$thisdir"
|
---|
[15610] | 205 | fi
|
---|
| 206 |
|
---|
| 207 | else
|
---|
| 208 | echo "Greenstone version unknown."
|
---|
[4952] | 209 | exit 1
|
---|
| 210 | fi
|
---|
| 211 |
|
---|
[15610] | 212 | echo
|
---|
[15626] | 213 | if [ "x$GSDL3SRCHOME" != "x" ]; then
|
---|
| 214 | echo "GSDL3SRCHOME is: $GSDL3SRCHOME"
|
---|
| 215 | fi
|
---|
| 216 | if [ "x$GSDL3HOME" != "x" ]; then
|
---|
| 217 | echo "GSDL3HOME is: $GSDL3HOME"
|
---|
| 218 | fi
|
---|
| 219 | if [ "x$GSDLHOME" != "x" ]; then
|
---|
| 220 | echo "GSDLHOME is: $GSDLHOME"
|
---|
| 221 | fi
|
---|
[15610] | 222 | echo
|
---|
[4952] | 223 |
|
---|
[19355] | 224 | ## ---- find perl ----
|
---|
| 225 | exit_status=0
|
---|
| 226 | ./findperl.sh
|
---|
| 227 | exit_status=$?
|
---|
| 228 | if [ "$exit_status" -eq 1 ]; then
|
---|
| 229 | exit 1;
|
---|
[4952] | 230 | fi
|
---|
| 231 |
|
---|
[17493] | 232 | ## ---- Check Java ----
|
---|
[19355] | 233 | # call the script with source, so that we have the variables it sets ($javapath)
|
---|
| 234 | exit_status=0
|
---|
| 235 | source ./findjava.sh
|
---|
| 236 | exit_status=$?
|
---|
| 237 | if [ "$exit_status" -eq 1 ]; then
|
---|
| 238 | exit 1;
|
---|
[6702] | 239 | fi
|
---|
[4952] | 240 |
|
---|
[5003] | 241 | ## ---- Check that the GLI has been compiled ----
|
---|
[7748] | 242 | if [ ! -f "classes/org/greenstone/gatherer/GathererProg.class" ] && [ ! -f "GLI.jar" ]; then
|
---|
[8901] | 243 | echo
|
---|
[12286] | 244 | if [ "$glilang" = "es" ]; then
|
---|
[17493] | 245 | echo "Usted necesita compilar la Interfaz de la Biblioteca Digital Greenstone"
|
---|
| 246 | echo "(por medio de makegli.sh) antes de ejecutar este guión."
|
---|
[12286] | 247 | elif [ "$glilang" = "fr" ]; then
|
---|
[17493] | 248 | echo "Vous devez compiler le Greenstone Interface (en utilisant makegli.sh)"
|
---|
| 249 | echo "avant d'exécuter ce script."
|
---|
[12286] | 250 | elif [ "$glilang" = "ru" ]; then
|
---|
[17493] | 251 | echo "÷Ù ÄÏÌÖÎÙ ËÏÍÐÉÌÉÒÏ×ÁÔØ ÂÉÂÌÉÏÔÅÞÎÙÊ ÉÎÔÅÒÆÅÊÓ Greenstone"
|
---|
| 252 | echo "(ÉÓÐÏÌØÚÕÑ makegli.sh) ÐÅÒÅÄ ××ÏÄÏÍ ÜÔÏÇÏ ÓËÒÉÐÔÁ"
|
---|
[6702] | 253 | else
|
---|
[17493] | 254 | echo "You need to compile the Greenstone Librarian Interface (using makegli.sh)"
|
---|
| 255 | echo "before running this script."
|
---|
[6702] | 256 | fi
|
---|
[4952] | 257 | exit 1
|
---|
| 258 | fi
|
---|
| 259 |
|
---|
[17672] | 260 | ## ---- Explain how to bypass Imagemagick and Ghostscript bundled with Greenstone if needed ----
|
---|
| 261 | if [ -e "$GSDLHOME/bin/$GSDLOS/ghostscript" ] ; then
|
---|
| 262 | 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."
|
---|
| 263 | fi
|
---|
| 264 | echo
|
---|
| 265 | echo
|
---|
| 266 | if [ -e "$GSDLHOME/bin/$GSDLOS/imagemagick" ] ; then
|
---|
| 267 | 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."
|
---|
| 268 | echo
|
---|
| 269 | echo
|
---|
| 270 | fi
|
---|
| 271 |
|
---|
| 272 |
|
---|
[5003] | 273 | ## ---- Finally, run the GLI ----
|
---|
[12286] | 274 | if [ "$glilang" = "es" ]; then
|
---|
[14977] | 275 | echo "Ejecutando la Interfaz de la $PROGNAME..."
|
---|
[12286] | 276 | elif [ "$glilang" = "fr" ]; then
|
---|
[14977] | 277 | echo "Exécution de $PROGNAME..."
|
---|
[12286] | 278 | elif [ "$glilang" = "ru" ]; then
|
---|
[14977] | 279 | echo "ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..."
|
---|
[6702] | 280 | else
|
---|
[14977] | 281 | echo "Running the $PROGNAME..."
|
---|
[6702] | 282 | fi
|
---|
[4952] | 283 |
|
---|
[15610] | 284 | # basic_command is the cmd string common to both Greenstone 3 and Greenstone 2 execution
|
---|
[19171] | 285 | #basic_command="$javapath -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg"
|
---|
[12225] | 286 | stop_gli=0
|
---|
| 287 | while [ "$stop_gli" = "0" ] ; do
|
---|
[15610] | 288 |
|
---|
[17534] | 289 | # Other arguments you can provide to GLI to work around memory limitations, or debug
|
---|
| 290 | # -Xms<number>M To set minimum memory (by default 32MB)
|
---|
| 291 | # -Xmx<number>M To set maximum memory (by default the nearest 2^n to the total remaining physical memory)
|
---|
| 292 | # -verbose:gc To set garbage collection messages
|
---|
| 293 | # -Xincgc For incremental garbage collection (significantly slows performance)
|
---|
| 294 | # -Xprof Function call profiling
|
---|
| 295 | # -Xloggc:<file> Write garbage collection log
|
---|
[15610] | 296 |
|
---|
| 297 | exit_status=0
|
---|
| 298 | if [ "$_version" -eq 2 ]; then
|
---|
[18988] | 299 | # GS2 webLib
|
---|
| 300 | if [ "$PROGABBR" = "FLI" -o ! -f "$GSDLHOME/gs2-server.sh" ]; then
|
---|
[19171] | 301 | "$javapath" -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl "$GSDLHOME" -gsdlos $GSDLOS $*
|
---|
[18988] | 302 | exit_status=$?
|
---|
| 303 | # GS2 localLib
|
---|
| 304 | else
|
---|
[19171] | 305 | "$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" $*
|
---|
[18988] | 306 | exit_status=$?
|
---|
| 307 | fi
|
---|
| 308 | # GS3
|
---|
[15610] | 309 | elif [ "$_version" -eq 3 ]; then
|
---|
[19171] | 310 | "$javapath" -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl "$GSDLHOME" -gsdlos $GSDLOS -gsdl3 "$GSDL3HOME" -gsdl3src "$GSDL3SRCHOME" $*
|
---|
[17534] | 311 | exit_status=$?
|
---|
[15610] | 312 | fi
|
---|
| 313 |
|
---|
| 314 | if [ "$exit_status" != "2" ] ; then
|
---|
[17534] | 315 | stop_gli=1
|
---|
[12225] | 316 | else
|
---|
[17534] | 317 | echo
|
---|
| 318 | if [ "$glilang" = "es" ]; then
|
---|
| 319 | echo "Restarting/Ejecutando la Interfaz de la $PROGNAME..."
|
---|
| 320 | elif [ "$glilang" = "fr" ]; then
|
---|
| 321 | echo "Restarting/Exécution de $PROGNAME..."
|
---|
| 322 | elif [ "$glilang" = "ru" ]; then
|
---|
| 323 | echo "Restarting/ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..."
|
---|
| 324 | else
|
---|
| 325 | echo "Restarting the $PROGNAME..."
|
---|
| 326 | fi
|
---|
[12225] | 327 | fi
|
---|
| 328 | done
|
---|
| 329 |
|
---|
[12286] | 330 | if [ "$glilang" = "es" ]; then
|
---|
[6745] | 331 | echo "¡Hecho!"
|
---|
[12286] | 332 | elif [ "$glilang" = "fr" ]; then
|
---|
[6712] | 333 | echo "Terminé!"
|
---|
[12286] | 334 | elif [ "$glilang" = "ru" ]; then
|
---|
[6702] | 335 | echo "÷ÙÐÏÌÎÅÎÏ!"
|
---|
| 336 | else
|
---|
| 337 | echo "Done!"
|
---|
[19392] | 338 | fi |
---|