Changeset 19403 for gli/trunk/gli.sh


Ignore:
Timestamp:
2009-05-12T13:25:00+12:00 (15 years ago)
Author:
ak19
Message:

3 changes. 1. Moved gli.sh's logic for finding and setting GSDLHOME (and GSDL3SRCHOME and GSDL3HOME) into a separate bashfile: findgsdl.sh. 2. This script is now called by both gli.sh and client-gli.sh, since client-gli can from now on use the same logic to locate a local GS installation. The only difference is that if GSDLHOME is not found, then client-gli runs as before: no Download panel. 3. client-gli.sh will no longer be looking for a gs2build directory located inside a client-gli checkout, but instead search for a local GSDLHOME (including in the directory directly above, in case client-gli.sh is run from a normal GS checkout. IF a GSDLHOME is found (and perl too), then client-gli will enable the Download panel, and use the local GSDLHOME to do any downloading.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gli/trunk/gli.sh

    r19392 r19403  
    11#!/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 }
    562
    573glilang=en
     
    7521if [ "x$PROGNAME_EN" = "x" ] ; then
    7622    PROGNAME_EN="Greenstone Librarian Interface"
     23fi
     24
     25if [ "x$GLIMODE" = "x" ] ; then
     26    GLIMODE="local"
    7727fi
    7828
     
    11161
    11262##  ---- Determine GSDLHOME ----
    113 ## gsdlpath can be either Greenstone 3 or Greenstone 2
    114 gsdlpath=
    115 # Some users may set the above line manually
    116 
    117 
    118 # This variable is set automatically:
    119 _version=
    120 if [ "x$gsdlpath" != "x" ]; then
    121     get_version "$gsdlpath"
    122     _version=$?
    123 # otherwise $gsdlpath is not yet set
    124 else
    125     # Check the environment variable first
    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
    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 ""
    137     elif [ "x$GSDL3SRCHOME" != "x" ]; then
    138     echo "Only gsdl3srchome set"
    139     gsdlpath=$GSDL3SRCHOME
    140     _version=3
    141     echo "$gsdlpath"
    142     elif [ "x$GSDLHOME" != "x" ]; then
    143     gsdlpath=$GSDLHOME
    144     _version=2
    145     # If it is not set, assume that the GLI is installed as a subdirectory of Greenstone
    146     else
    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
    150     get_version "$gsdlpath"
    151     _version=$?
    152     fi
     63# need to source a script in order to inherit the env vars it has set
     64# Exit on error code (non-zero)
     65exit_status=0
     66source ./findgsdl.sh
     67exit_status=$?
     68if [ "$exit_status" -eq 1 ]; then
     69    exit 1;
    15370fi
    15471
    155 echo "Greenstone version found: $_version"
    156 
    157 # Check that the main Greenstone installation for the version we're running looks OK
    158 check_installation "$gsdlpath" "$_version" "$glilang"
    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
    167     cd "$gsdlpath"
    168     . ./setup.bash
    169     cd "$thisdir"
    170     fi
    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
    175     cd "$gsdlpath"
    176     . ./gs3-setup.sh
    177     cd "$thisdir"
    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
    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
    192         # If it is not set, assume that the gs2build subdirectory of Greenstone 3 exists
    193     else
    194         gsdl2path=$GSDL3SRCHOME/gs2build
    195     fi
    196     fi
    197     # Check that Greenstone 3's Greenstone 2 stuff looks OK (in gs2build)
    198     check_installation "$gsdl2path" "" "$glilang"
    199  
    200     # Setup Greenstone 3's gs2build, unless it has already been done
    201     if [ "x$GSDLHOME" = "x" ]; then
    202     cd "$gsdl2path"
    203     . ./setup.bash
    204     cd "$thisdir"
    205     fi
    206 
    207 else
    208     echo "Greenstone version unknown."   
    209     exit 1
    210 fi
    211 
    212 echo
    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
    222 echo
    223 
    22472## ---- find perl ----
     73# no need to source the findperl script since it does not set env vars
    22574exit_status=0
    22675./findperl.sh
Note: See TracChangeset for help on using the changeset viewer.