Changeset 22336 for main/trunk/gli
- Timestamp:
- 2010-07-01T11:25:53+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/gems.sh
r20968 r22336 1 1 #!/bin/bash 2 3 # Function that, when given gsdlpath as parameter, will return the4 # 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 gsdlpath8 if [ -f "${1}/gs3-setup.sh" ]; then9 return 310 elif [ -f "${1}/setup.bash" ]; then11 return 212 else13 echo "Error: can't determine which Greenstone version is being run."14 exit 115 fi16 }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, and21 # - the language GLI is set to22 # 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 OK26 if [ "$3" = "es" ]; then27 echo "Revisando GSDL$2: $1"28 elif [ "$3" = "fr" ]; then29 echo "Vérification de GSDL$2: $1"30 elif [ "$3" = "ru" ]; then31 echo "ðÒÏ×ÅÒËÁ GSDL$2: $1"32 else33 echo "Checking GSDL$2: $1"34 fi35 # even if we are only checking for gs2build (gsdl2path), we still36 # need the file setup.bash to exist in the following condition:37 if [ ! -f "${1}/gs3-setup.sh" -a ! -f "${1}/setup.bash" ] ; then38 echo39 if [ "$3" = "es" ]; then40 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" ]; then44 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" ]; then47 echo "éÎÓÔÁÌÌÑÃÉÑ Greenstone $_version ÎÅ ÂÙÌÁ ÎÁÊÄÅÎÁ ÉÌÉ ÏÎÁ ÎÅÐÏÌÎÁ."48 echo "ðÏÐÒÏÂÕÊÔÅ ÐÏ×ÔÏÒÎÏ ÕÓÔÁÎÏ×ÉÔØ Greenstone $2, Á ÚÁÔÅÍ ××ÅÓÔÉ ÜÔÏÔ ÓËÒÉÐÔ ÓÎÏ×Á."49 else50 echo "The Greenstone $2 installation could not be found, or is incomplete."51 echo "Try reinstalling Greenstone $2 then running this script again."52 fi53 exit 154 fi55 }56 2 57 3 glilang=en … … 70 16 71 17 PROGNAME_EN="Greenstone Editor for Metadata Sets" 72 73 18 74 19 echo … … 98 43 99 44 ## -------- Run the Greenstone Editor for Metadata Sets -------- 100 101 45 # This script must be run from within the directory in which it lives 102 thisdir=`pwd` 103 if [ ! -f "${thisdir}/gems.sh" ]; then 104 if [ "$glilang" = "es" ]; then 105 echo "Este guión deberá ejecutarse desde el directorio en el que reside." 106 elif [ "$glilang" = "fr" ]; then 107 echo "Ce script doit être exécuté à partir du répertoire dans lequel il se trouve." 108 elif [ "$glilang" = "ru" ]; then 109 echo "üÔÏÔ ÓËÒÉÐÔ ÄÏÌÖÅÎ ÂÙÔØ ×ÚÑÔ ÉÚ ÄÉÒÅËÔÏÒÉÉ, × ËÏÔÏÒÏÊ ÏÎ ÒÁÓÐÏÌÏÖÅÎ" 110 else 111 echo "This script must be run from the directory in which it resides." 112 fi 113 exit 1 114 fi 115 46 thisdir="`dirname \"$0\"`" 47 thisdir="`cd \"$thisdir\" && pwd`" 48 cd "$thisdir" 116 49 117 50 ## ---- Determine GSDLHOME ---- 118 51 ## gsdlpath can be either Greenstone 3 or Greenstone 2 119 gsdlpath= 120 # Some users may set the above line manually 121 122 123 # This variable is set automatically: 124 _version= 125 if [ "x$gsdlpath" != "x" ]; then 126 get_version $gsdlpath 127 _version=$? 128 # otherwise $gsdlpath is not yet set 129 else 130 # Check the environment variable first 131 # Check whether environment variables for both GS2 and GS3 are set 132 # and if so, warn the user that we have defaulted to GS3 133 if [ "x$GSDLHOME" != "x" -a "x$GSDL3SRCHOME" != "x" ]; then 134 # _version not set, but both env vars set, so default to 3 135 _version=3 136 gsdlpath=$GSDL3SRCHOME 137 echo "Both Greenstone 2 and Greenstone 3 environments are set." 138 echo "It is assumed you want to run Greenstone 3." 139 echo "If you want to run Greenstone 2, please unset the" 140 echo "environment variable GSDL3SRCHOME before running GLI." 141 echo "" 142 elif [ "x$GSDL3SRCHOME" != "x" ]; then 143 echo "Only gsdl3srchome set" 144 gsdlpath=$GSDL3SRCHOME 145 _version=3 146 echo "$gsdlpath" 147 elif [ "x$GSDLHOME" != "x" ]; then 148 gsdlpath=$GSDLHOME 149 _version=2 150 # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone 151 else 152 gsdlpath=`(cd .. && pwd)` 153 # Still need to find what version we are running: 154 # GS3 main directory contains file gs3-setup.sh, GS2 only setup.bash 155 get_version $gsdlpath 156 _version=$? 157 fi 52 exit_status=0 53 source ./findgsdl.sh 54 exit_status=$? 55 if [ "$exit_status" -eq 1 ]; then 56 exit 1; 158 57 fi 159 58 160 echo "Greenstone version found: $_version" 161 162 # Check that the main Greenstone installation for the version we're running looks OK 163 check_installation $gsdlpath $_version $glilang 164 165 166 # Need to source the correct setup file depending on whether we are running 167 # gs3 or gs2 168 # If we're running version GS2 169 if [ "$_version" -eq 2 ]; then 170 # Setup Greenstone 2, unless it has already been done 171 if [ "x$GSDLHOME" = "x" ]; then 172 cd "$gsdlpath" 173 . setup.bash 174 cd "$thisdir" 175 fi 176 # else, if we're running GS3 177 elif [ "$_version" -eq 3 ]; then 178 # Setup Greenstone 3, unless it has already been done 179 if [ "x$GSDL3HOME" = "x" -o "x$GSDL3SRCHOME" = "x" ]; then 180 cd "$gsdlpath" 181 . gs3-setup.sh 182 cd "$thisdir" 183 fi 184 185 ## if Greenstone version 3 is running, we want to set gsdl2path 186 ## ---- Determine GSDLHOME ---- 187 ## may be already set, or manually entered here. 188 gsdl2path= 189 190 # Some users may set the above line manually 191 if [ "x$gsdl2path" = "x" ]; then 192 # Check the environment variable first 193 if [ "x$GSDLHOME" != "x" ]; then 194 echo "GSDLHOME environment variable is set to $GSDLHOME." 195 echo "Will use this to find build scripts." 196 gsdl2path=$GSDLHOME 197 # If it is not set, assume that the gs2build subdirectory of Greenstone 3 exists 198 else 199 gsdl2path=$GSDL3SRCHOME/gs2build 200 fi 201 fi 202 # Check that Greenstone 3's Greenstone 2 stuff looks OK (in gs2build) 203 check_installation $gsdl2path "" $glilang 204 205 # Setup Greenstone 3's gs2build, unless it has already been done 206 if [ "x$GSDLHOME" = "x" ]; then 207 cd "$gsdl2path" 208 . setup.bash 209 cd "$thisdir" 210 fi 211 212 else 213 echo "Greenstone version unknown." 214 exit 1 59 ## ---- Check Java ---- 60 # call the script with source, so that we have the variables it sets ($javapath 61 exit_status=0 62 source ./findjava.sh "$glilang" "$PROGNAME" 63 exit_status=$? 64 if [ "$exit_status" -eq 1 ]; then 65 exit 1; 215 66 fi 216 217 echo218 if [ "x$GSDL3SRCHOME" != "x" ]; then219 echo "GSDL3SRCHOME is: $GSDL3SRCHOME"220 fi221 if [ "x$GSDL3HOME" != "x" ]; then222 echo "GSDL3HOME is: $GSDL3HOME"223 fi224 if [ "x$GSDLHOME" != "x" ]; then225 echo "GSDLHOME is: $GSDLHOME"226 fi227 echo228 229 230 231 ## ---- Check Java ----232 echo "Java:"233 MINIMUM_JAVA_VERSION=1.4.0_00234 235 # Some users may set this line manually236 #JAVA_HOME=237 238 if [ -z $javapath ]; then239 240 # sus out search4j241 if [ "$_version" -eq 2 -a -e "$GSDLHOME/bin/$GSDLOS/search4j" ]; then242 SEARCH4J_EXECUTABLE=$GSDLHOME/bin/$GSDLOS/search4j243 elif [ "$_version" -eq 3 -a -e "$GSDL3SRCHOME/bin/$GSDLOS/search4j" ]; then244 SEARCH4J_EXECUTABLE=$GSDL3SRCHOME/bin/search4j245 elif [ -e "../bin/$GSDLOS/search4j" ]; then246 SEARCH4J_EXECUTABLE=../bin/$GSDLOS/search4j247 elif [ -e "../bin/search4j" ]; then248 SEARCH4J_EXECUTABLE=../bin/search4j249 else250 echo "Couldn't determine the location of the search4j executable"251 echo "If you are running Greenstone2"252 echo " * check GSDLHOME is set"253 echo " * check bin/$GSDLOS/search4j exists"254 echo " * check bin/$GSDLOS/search4j is executable"255 echo "If you are running Greenstone3"256 echo " * check GSDL3SRCHOME is set"257 echo " * check bin/search4j exists"258 echo " * check bin/search4j is executable"259 echo " * try running 'ant compile-search4j'"260 fi261 262 # Give search4j a hint to find Java depending on the platform263 if [ $GSDLOS = linux ]; then264 HINT=`cd ..;pwd`/packages/jre265 elif [ $GSDLOS = darwin ]; then266 HINT=/System/Library/Frameworks/JavaVM.framework/Home267 fi268 269 javapath=`$SEARCH4J_EXECUTABLE -e -p $HINT -m $MINIMUM_JAVA_VERSION`270 271 if [ "$?" != "0" ]; then272 273 OLDVER=`"$SEARCH4J_EXECUTABLE" -v -p "$HINT"`274 275 if [ "$?" = "0" ]; then276 277 if [ "$glilang" = "es" ]; then278 echo "La versión del Ambiente de Ejecución Java (JRE por sus siglas en "279 echo "inglés) que usted tiene instalada es demasiado vieja para ejecutar "280 echo "la Interfaz de la $PROGNAME. Por favor instale "281 echo "una nueva versión del Ambiente de Ejecución Java (versión $MINIMUM_JAVA_VERSION o "282 echo "posterior) y ejecute nuevamente este guión."283 elif [ "$glilang" = "fr" ]; then284 echo "La version de Java Runtime Environment que vous avez installée est"285 echo "trop vielle pour faire fonctionner $PROGNAME."286 echo "Veuillez installer une nouvelle version du JRE (version $MINIMUM_JAVA_VERSION ou plus"287 echo "récente) et redémarrez le script."288 elif [ "$glilang" = "ru" ]; then289 echo "÷ÅÒÓÉÑ Java Runtime Environment, ËÏÔÏÒÕÀ ÷Ù ÕÓÔÁÎÏ×ÉÌÉ, ÏÞÅÎØ ÓÔÁÒÁ,"290 echo "ÞÔÏÂÙ ÕÐÒÁ×ÌÑÔØ ÂÉÂÌÉÏÔÅÞÎÙÍ $PROGNAME. ðÏÖÁÌÕÊÓÔÁ, "291 echo "ÕÓÔÁÎÏ×ÉÔÅ ÎÏ×ÕÀ ×ÅÒÓÉÀ JRE (×ÅÒÓÉÀ $MINIMUM_JAVA_VERSION ÉÌÉ ÂÏÌÅÅ ÎÏ×ÕÀ) É"292 echo "ÐÅÒÅÕÓÔÁÎÏ×ÉÔÅ ÜÔÏÔ ÓËÒÉÐÔ"293 else294 echo "The version of the Java Runtime Environment you have installed ($OLDVER)"295 echo "is too old to run the $PROGNAME. Please install a new"296 echo "version of the JRE (version $MINIMUM_JAVA_VERSION or newer) and rerun this script."297 fi298 exit 1299 300 else301 302 echo303 if [ "$glilang" = "es" ]; then304 echo "No se pudo localizar una versión apropiada de Java. Usted deberá "305 echo "instalar un Ambiente de Ejecución Java (versión $MINIMUM_JAVA_VERSION o superior) "306 echo "antes de correr la Interfaz de la $PROGNAME."307 elif [ "$glilang" = "fr" ]; then308 echo "Une version adéquate de Java n'a pas pu être localisée."309 echo "Vous devez installer un Java Runtime Environment (version $MINIMUM_JAVA_VERSION ou"310 echo "supérieur) avant de démarrer $PROGNAME."311 echo "Si vous avez Java installé sur votre ordinateur veuillez vérifier la variable"312 echo "d'environnement JAVA_HOME."313 elif [ "$glilang" = "ru" ]; then314 echo "îÅ ÕÄÁÌÏÓØ ÏÐÒÅÄÅÌÉÔØ ÍÅÓÔÏÎÁÈÏÖÄÅÎÉÅ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ×ÅÒÓÉÉ Java."315 echo "÷Ù ÄÏÌÖÎÙ ÕÓÔÁÎÏ×ÉÔØ Java Runtime Environment (×ÅÒÓÉÀ $MINIMUM_JAVA_VERSION ÉÌÉ ×ÙÛÅ)"316 echo "ÐÅÒÅÄ ××ÏÄÏÍ ÂÉÂÌÉÏÔÅÞÎÏÇÏ $PROGNAME."317 else318 echo "Failed to locate an appropriate version of Java. You must install a"319 echo "Java Runtime Environment (version $MINIMUM_JAVA_VERSION or greater) before running the"320 echo "$PROGNAME."321 echo "If you have Java intalled on your machine please set the environment variable JAVA_HOME."322 fi323 fi324 325 fi326 327 fi328 echo $javapath329 echo330 331 332 67 333 68 ## ---- Check that the GEMS has been compiled ----
Note:
See TracChangeset
for help on using the changeset viewer.