source: gli/stable/findjava.sh@ 19562

Last change on this file since 19562 was 19403, checked in by ak19, 15 years ago

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.

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