root/gli/trunk/findjava.sh @ 19355

Revision 19355, 6.2 KB (checked in by ak19, 11 years ago)

Moved finding java and finding perl logic into findjava.sh and findperl.sh. Findjava.sh is called from gli.sh and client-gli.sh. Still need to call findperl.sh from client-gli.sh, and need to split findgsdl into its own file. Tested.

  • Property svn:executable set to *
Line 
1
2# We will already be in the correct folder (GLI folder), which would
3# contain a compiled up search4j if this GLI is part of an installation.
4# If a search4j executable is not there, then it means this is an SVN checkout.
5# In such a case, it's up to the user checking things out to ensure JAVA_HOME
6# is set and moreover points to the correct version of the Java.
7
8# Function to check if any JAVA_HOME is set and if so, try using that
9function try_java {
10    MIN_DISPLAY_VERSION=${1};
11
12    echo "JAVAHOME: $JAVA_HOME"
13    if [ "x$JAVA_HOME" = "x" -o ! -f "$JAVA_HOME/bin/java" ]; then
14    return no_java "$MIN_DISPLAY_VERSION"
15    else
16    # There is a JAVA_HOME already set, we're going to try using that
17    javapath="$JAVA_HOME/bin/java"
18
19    # Print a warning that we're going to use whatever JAVA_HOME is set (fingers crossed)
20    echo
21    if [ "x$glilang" = "x" -o "$glilang" = "en" ]; then
22        echo "***************************************************************************"
23        echo "WARNING: "
24        echo "Found a JAVA_HOME at $JAVA_HOME. Attempting to use this."
25        echo "However, you need to have a Java $MIN_DISPLAY_VERSION or higher installed."
26        echo "***************************************************************************"
27    fi
28    echo
29    echo "Java:"
30    echo $javapath
31    echo
32    return 0
33    fi
34}
35
36function no_java {
37    MIN_DISPLAY_VERSION=${1};
38
39    echo
40    if [ "$glilang" = "es" ]; then
41    echo "No se pudo localizar una versión apropiada de Java. Usted deberá "
42    echo "instalar un Ambiente de Ejecución Java (versión $MINIMUM_DISPLAY_VERSION o superior) "
43    echo "antes de correr la Interfaz de la $PROGNAME."
44    elif [ "$glilang" = "fr" ]; then
45    echo "Une version adéquate de Java n'a pas pu être localisée."
46    echo "Vous devez installer un Java Runtime Environment (version $MINIMUM_DISPLAY_VERSION ou"
47    echo "supérieur) avant de démarrer $PROGNAME."
48    echo "Si vous avez Java installé sur votre ordinateur veuillez vérifier la variable"
49    echo "d'environnement JAVA_HOME."
50    elif [ "$glilang" = "ru" ]; then
51    echo "îÅ ÕÄÁÌÏÓØ ÏÐÒÅÄÅÌÉÔØ ÍÅÓÔÏÎÁÈÏÖÄÅÎÉÅ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ×ÅÒÓÉÉ Java."
52    echo "÷Ù ÄÏÌÖÎÙ ÕÓÔÁÎÏ×ÉÔØ Java Runtime Environment (×ÅÒÓÉÀ $MINIMUM_DISPLAY_VERSION ÉÌÉ ×ÙÛÅ)"
53    echo "ÐÅÒÅÄ ××ÏÄÏÍ ÂÉÂÌÉÏÔÅÞÎÏÇÏ $PROGNAME."
54    else
55    echo "Failed to locate an appropriate version of Java. You must install a"
56    echo "Java Runtime Environment (version $MINIMUM_DISPLAY_VERSION or greater) before running the"
57    echo "$PROGNAME."
58    echo "If you have Java intalled on your machine please set the environment variable JAVA_HOME."
59    fi
60    return 1
61}
62
63function set_java_exec {   
64    SEARCH4J_EXECUTABLE=${1};
65    MINIMUM_JAVA_VERSION=${2};
66    MIN_DISPLAY_VERSION=${3};
67
68    # Give search4j a hint to find Java depending on the platform
69    if [ $GSDLOS = linux ]; then
70    HINT=`cd ..;pwd`/packages/jre
71    elif [ $GSDLOS = darwin ]; then
72    HINT=/System/Library/Frameworks/JavaVM.framework/Home
73    fi 
74   
75    javapath="`"$SEARCH4J_EXECUTABLE" -e -p "$HINT" -m $MINIMUM_JAVA_VERSION`"
76   
77    if [ "$?" != "0" ]; then
78   
79        OLDVER="`"$SEARCH4J_EXECUTABLE" -v -p "$HINT"`"
80   
81        if [ "$?" = "0" ]; then
82       
83            if [ "$glilang" = "es" ]; then
84                echo "La versión del Ambiente de Ejecución Java (JRE por sus siglas en "
85                echo "inglés) que usted tiene instalada es demasiado vieja para ejecutar "
86                echo "la Interfaz de la $PROGNAME. Por favor instale "
87                echo "una nueva versión del Ambiente de Ejecución Java (versión $MIN_DISPLAY_VERSION o "
88                echo "posterior) y ejecute nuevamente este guión."
89            elif [ "$glilang" = "fr" ]; then
90                echo "La version de Java Runtime Environment que vous avez installée est"
91                echo "trop vielle pour faire fonctionner $PROGNAME."
92                echo "Veuillez installer une nouvelle version du JRE (version $MIN_DISPLAY_VERSION ou plus"
93                echo "récente) et redémarrez le script."
94            elif [ "$glilang" = "ru" ]; then
95                echo "÷ÅÒÓÉÑ Java Runtime Environment, ËÏÔÏÒÕÀ ÷Ù ÕÓÔÁÎÏ×ÉÌÉ, ÏÞÅÎØ ÓÔÁÒÁ,"
96                echo "ÞÔÏÂÙ ÕÐÒÁ×ÌÑÔØ ÂÉÂÌÉÏÔÅÞÎÙÍ $PROGNAME. ðÏÖÁÌÕÊÓÔÁ, "
97                echo "ÕÓÔÁÎÏ×ÉÔÅ ÎÏ×ÕÀ ×ÅÒÓÉÀ JRE (×ÅÒÓÉÀ $MIN_DISPLAY_VERSION ÉÌÉ ÂÏÌÅÅ ÎÏ×ÕÀ) É"
98                echo "ÐÅÒÅÕÓÔÁÎÏ×ÉÔÅ ÜÔÏÔ ÓËÒÉÐÔ"
99            else
100                echo "The version of the Java Runtime Environment you have installed ($OLDVER)"
101                echo "is too old to run the $PROGNAME. Please install a new"
102                echo "version of the JRE (version $MIN_DISPLAY_VERSION or newer) and rerun this script."
103            fi
104            return 1
105       
106        else
107        return no_java "$MIN_DISPLAY_VERSION"
108        fi
109   
110    fi
111    echo "Java:"
112    echo $javapath
113    echo
114    return 0
115}
116
117
118## ---- Check Java ----
119# Some users may set this line manually
120#JAVA_HOME=
121
122MINIMUM_JAVA_VERSION=1.4.0_00
123MIN_DISPLAY_VERSION=1.4
124
125# sus out search4j
126# first look for compiled search4j executable inside GLI folder
127if [ -f search4j ]; then
128    SEARCH4J_EXECUTABLE=search4j   
129elif [ "x$_version" != "x" ]; then
130     # version known, look for a compiled search4j in a GS installation
131    if [ "$_version" -eq 2 -a -e "$GSDLHOME/bin/$GSDLOS/search4j" ]; then
132    SEARCH4J_EXECUTABLE=$GSDLHOME/bin/$GSDLOS/search4j
133    elif [ "$_version" -eq 3 -a -e "$GSDL3SRCHOME/bin/$GSDLOS/search4j" ]; then
134    SEARCH4J_EXECUTABLE=$GSDL3SRCHOME/bin/search4j
135    elif [ -e "../bin/$GSDLOS/search4j" ]; then
136    SEARCH4J_EXECUTABLE=../bin/$GSDLOS/search4j
137    elif [ -e "../bin/search4j" ]; then
138    SEARCH4J_EXECUTABLE=../bin/search4j
139    else
140    echo "Couldn't determine the location of the search4j executable"
141    echo "If you are running Greenstone2"
142    echo "   * check GSDLHOME is set"
143    echo "   * check bin/$GSDLOS/search4j exists"
144    echo "   * check bin/$GSDLOS/search4j is executable"
145    echo "If you are running Greenstone3"
146    echo "   * check GSDL3SRCHOME is set"
147    echo "   * check bin/search4j exists"
148    echo "   * check bin/search4j is executable"
149    echo "   * try running 'ant compile-search4j'"
150    fi
151fi
152
153# Now run set_java_exec with search4j if we found one, else try javahome
154if [ "x$SEARCH4J_EXECUTABLE" != "x" ]; then
155    set_java_exec "$SEARCH4J_EXECUTABLE" "$MINIMUM_JAVA_VERSION" "$MIN_DISPLAY_VERSION"
156    retval=$?
157else
158    try_java "$MIN_DISPLAY_VERSION"
159    retval=$?
160fi
161return $retval
Note: See TracBrowser for help on using the browser.