- Timestamp:
- 2008-05-21T12:28:36+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/gli.sh
r14977 r15610 1 1 #!/bin/sh 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 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 check_installation() { 25 # Check that the Greenstone installation looks OK 26 if [ "$3" = "es" ]; then 27 echo "Revisando GSDL: $1" 28 elif [ "$3" = "fr" ]; then 29 echo "Vérification de GSDL: $1" 30 elif [ "$3" = "ru" ]; then 31 echo "ðÒÏ×ÅÒËÁ GSDL: $1" 32 else 33 echo "Checking GSDL: $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 2 57 glilang=en 3 58 … … 66 121 67 122 ## ---- Determine GSDLHOME ---- 123 ## gsdlpath can be either Greenstone 3 or Greenstone 2 68 124 gsdlpath= 69 70 125 # Some users may set the above line manually 71 if [ "x$gsdlpath" = "x" ]; then 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 72 135 # Check the environment variable first 73 if [ "x$GSDLHOME" != "x" ]; then 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 74 153 gsdlpath=$GSDLHOME 75 154 _version=2 76 155 # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone 77 156 else 78 157 gsdlpath=`(cd .. && pwd)` 79 fi 80 fi 81 82 # Check that the Greenstone installation looks OK 83 if [ "$glilang" = "es" ]; then 84 echo "Revisando GSDL: $gsdlpath" 85 elif [ "$glilang" = "fr" ]; then 86 echo "Vérification de GSDL: $gsdlpath" 87 elif [ "$glilang" = "ru" ]; then 88 echo "ðÒÏ×ÅÒËÁ GSDL: $gsdlpath" 89 else 90 echo "Checking GSDL: $gsdlpath" 91 fi 92 if [ ! -f "${gsdlpath}/setup.bash" ] ; then 93 echo 94 if [ "$glilang" = "es" ]; then 95 echo "No se pudo encontrar la instalación de Greenstone o está incompleta." 96 echo "Trate de reinstalar Greenstone y a continuación ejecute nuevamente" 97 echo "este guión." 98 elif [ "$glilang" = "fr" ]; then 99 echo "L'installation de Greenstone est introuvable ou incomplète." 100 echo "Essayez de réinstaller Greenstone et exécutez ce script à nouveau." 101 elif [ "$glilang" = "ru" ]; then 102 echo "éÎÓÔÁÌÌÑÃÉÑ Greenstone ÎÅ ÂÙÌÁ ÎÁÊÄÅÎÁ ÉÌÉ ÏÎÁ ÎÅÐÏÌÎÁ." 103 echo "ðÏÐÒÏÂÕÊÔÅ ÐÏ×ÔÏÒÎÏ ÕÓÔÁÎÏ×ÉÔØ Greenstone, Á ÚÁÔÅÍ ××ÅÓÔÉ ÜÔÏÔ ÓËÒÉÐÔ ÓÎÏ×Á." 104 else 105 echo "The Greenstone installation could not be found, or is incomplete." 106 echo "Try reinstalling Greenstone then running this script again." 107 fi 108 exit 1 109 fi 110 111 # Setup Greenstone, unless it has already been done 112 if [ "x$GSDLHOME" = "x" ]; then 113 cd "$gsdlpath" 114 . setup.bash 115 cd "$thisdir" 116 fi 117 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 echo 167 168 # Check that the main Greenstone installation for the version we're running looks OK 169 check_installation $gsdlpath $_version $glilang 170 171 172 # Need to source the correct setup file depending on whether we are running 173 # gs3 or gs2 174 # If we're running version GS2 175 if [ "$_version" -eq 2 ]; then 176 echo "Version is 2" 177 # Setup Greenstone 2, unless it has already been done 178 if [ "x$GSDLHOME" = "x" ]; then 179 cd "$gsdlpath" 180 . setup.bash 181 cd "$thisdir" 182 fi 183 # else, if we're running GS3 184 elif [ "$_version" -eq 3 ]; then 185 # Setup Greenstone 3, unless it has already been done 186 if [ "x$GSDL3HOME" = "x" -o "x$GSDL3SRCHOME" = "x" ]; then 187 cd "$gsdlpath" 188 . gs3-setup.sh 189 cd "$thisdir" 190 fi 191 192 ## if Greenstone version 3 is running, we want to set gsdl2path 193 ## ---- Determine GSDLHOME ---- 194 ## may be already set, or manually entered here. 195 gsdl2path= 196 197 # Some users may set the above line manually 198 if [ "x$gsdl2path" = "x" ]; then 199 # Check the environment variable first 200 if [ "x$GSDLHOME" != "x" ]; then 201 echo "GSDLHOME environment variable is set to $GSDLHOME." 202 echo "Will use this to find build scripts." 203 gsdl2path=$GSDLHOME 204 # If it is not set, assume that the gs2build subdirectory of Greenstone 3 exists 205 else 206 gsdl2path=$GSDL3SRCHOME/gs2build 207 fi 208 fi 209 # Check that Greenstone 3's Greenstone 2 stuff looks OK (in gs2build) 210 check_installation $gsdl2path "" $glilang 211 212 # Setup Greenstone 3's gs2build, unless it has already been done 213 if [ "x$GSDLHOME" = "x" ]; then 214 cd "$gsdl2path" 215 . setup.bash 216 cd "$thisdir" 217 fi 218 219 else 220 echo "Greenstone version unknown." 221 exit 1 222 fi 223 224 echo 225 echo "***GSDLHOME is: $GSDLHOME" 226 echo "***GSDL3SRCHOME is: $GSDL3SRCHOME" 227 echo "***GSDL3HOME is: $GSDL3HOME" 228 echo 118 229 119 230 ## ---- Check Perl exists ---- … … 270 381 fi 271 382 383 # basic_command is the cmd string common to both Greenstone 3 and Greenstone 2 execution 384 basic_command="$javapath -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg" 272 385 stop_gli=0 273 386 while [ "$stop_gli" = "0" ] ; do 274 387 275 388 # Other arguments you can provide to GLI to work around memory limitations, or debug 276 389 # -Xms<number>M To set minimum memory (by default 32MB) … … 280 393 # -Xprof Function call profiling 281 394 # -Xloggc:<file> Write garbage collection log 282 283 284 285 $javapath -Xmx128M -classpath classes/:GLI.jar:lib/apache.jar:lib/qfslib.jar org.greenstone.gatherer.GathererProg -gsdl $GSDLHOME -gsdlos $GSDLOS $* 286 exit_status=$? 287 288 if [ "$exit_status" != "2" ] ; then 289 stop_gli=1 290 else 291 echo 292 if [ "$glilang" = "es" ]; then 293 echo "Restarting/Ejecutando la Interfaz de la $PROGNAME..." 294 elif [ "$glilang" = "fr" ]; then 295 echo "Restarting/Exécution de $PROGNAME..." 296 elif [ "$glilang" = "ru" ]; then 297 echo "Restarting/ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..." 298 else 299 echo "Restarting the $PROGNAME..." 300 fi 301 302 fi 395 396 exit_status=0 397 if [ "$_version" -eq 2 ]; then 398 `$basic_command -gsdl $GSDLHOME -gsdlos $GSDLOS $*` 399 exit_status=$? 400 elif [ "$_version" -eq 3 ]; then 401 `$basic_command -gsdl $GSDLHOME -gsdlos $GSDLOS -gsdl3 $GSDL3HOME -gsdl3src $GSDL3SRCHOME $*` 402 exit_status=$? 403 fi 404 405 if [ "$exit_status" != "2" ] ; then 406 stop_gli=1 407 else 408 echo 409 if [ "$glilang" = "es" ]; then 410 echo "Restarting/Ejecutando la Interfaz de la $PROGNAME..." 411 elif [ "$glilang" = "fr" ]; then 412 echo "Restarting/Exécution de $PROGNAME..." 413 elif [ "$glilang" = "ru" ]; then 414 echo "Restarting/ôÅËÕÝÉÊ ÂÉÂÌÉÏÔÅÞÎÙÊ $PROGNAME..." 415 else 416 echo "Restarting the $PROGNAME..." 417 fi 418 419 fi 303 420 done 304 421
Note:
See TracChangeset
for help on using the changeset viewer.