source: gli/trunk/findjava.sh@ 20134

Last change on this file since 20134 was 19769, checked in by ak19, 15 years ago
  1. Search4j was previously given a hint that assumed that findjava was working with GLI instead of a more general case (such as gs2-server.sh). Now it is uses GSDLHOME to work out the hint. 2. PROGNAME needs to be passed in as a parameter for display. The scripts gli.sh and client-gli.sh are now updated to pass PROGNAME (or PROGABBR) as an additional argument to findjava.sh. 3. Instead of merely testing whether the search4j file exists, Oran suggested testing whether search4j file exists AND is executable.
  • Property svn:executable set to *
File size: 6.1 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 no_java "$MIN_DISPLAY_VERSION"
13 return $?
14 else
15 # There is a JAVA_HOME already set, we're going to try using that
16 javapath="$JAVA_HOME/bin/java"
17
18 # Print a warning that we're going to use whatever JAVA_HOME is set (fingers crossed)
19 echo
20 if [ "x$gslang" = "x" -o "$gslang" = "en" ]; then
21 echo "***************************************************************************"
22 echo "WARNING: "
23 echo "Found a JAVA_HOME at $JAVA_HOME. Attempting to use this."
24 echo "However, you need to have a Java $MIN_DISPLAY_VERSION or higher installed."
25 echo "***************************************************************************"
26 fi
27 echo
28 echo "Java:"
29 echo $javapath
30 echo
31 return 0
32 fi
33}
34
35function no_java {
36 MIN_DISPLAY_VERSION=${1};
37
38 echo
39 if [ "$gslang" = "es" ]; then
40 echo "No se pudo localizar una versión apropiada de Java. Usted deberá "
41 echo "instalar un Ambiente de Ejecución Java (versión $MINIMUM_DISPLAY_VERSION o superior) "
42 echo "antes de correr la Interfaz de la $PROGNAME."
43 elif [ "$gslang" = "fr" ]; then
44 echo "Une version adéquate de Java n'a pas pu être localisée."
45 echo "Vous devez installer un Java Runtime Environment (version $MINIMUM_DISPLAY_VERSION ou"
46 echo "supérieur) avant de démarrer $PROGNAME."
47 echo "Si vous avez Java installé sur votre ordinateur veuillez vérifier la variable"
48 echo "d'environnement JAVA_HOME."
49 elif [ "$gslang" = "ru" ]; then
50 echo "îÅ ÕÄÁÌÏÓØ ÏÐÒÅÄÅÌÉÔØ ÍÅÓÔÏÎÁÈÏÖÄÅÎÉÅ ÓÏÏÔ×ÅÔÓÔ×ÕÀÝÅÊ ×ÅÒÓÉÉ Java."
51 echo "÷Ù ÄÏÌÖÎÙ ÕÓÔÁÎÏ×ÉÔØ Java Runtime Environment (×ÅÒÓÉÀ $MINIMUM_DISPLAY_VERSION ÉÌÉ ×ÙÛÅ)"
52 echo "ÐÅÒÅÄ ××ÏÄÏÍ ÂÉÂÌÉÏÔÅÞÎÏÇÏ $PROGNAME."
53 else
54 echo "Failed to locate an appropriate version of Java. You must install a"
55 echo "Java Runtime Environment (version $MINIMUM_DISPLAY_VERSION or greater) before running the"
56 echo "$PROGNAME."
57 echo "If you have Java intalled on your machine please set the environment variable JAVA_HOME."
58 fi
59 return 1
60}
61
62function set_java_exec {
63 SEARCH4J_EXECUTABLE=${1};
64 MINIMUM_JAVA_VERSION=${2};
65 MIN_DISPLAY_VERSION=${3};
66
67 # Give search4j a hint to find Java depending on the platform
68 if [ $GSDLOS = linux ]; then
69 HINT=`cd $GSDLHOME;pwd`/packages/jre
70 elif [ $GSDLOS = darwin ]; then
71 HINT=/System/Library/Frameworks/JavaVM.framework/Home
72 fi
73
74 javapath="`"$SEARCH4J_EXECUTABLE" -e -p "$HINT" -m $MINIMUM_JAVA_VERSION`"
75
76 if [ "$?" != "0" ]; then
77
78 OLDVER="`"$SEARCH4J_EXECUTABLE" -v -p "$HINT"`"
79
80 if [ "$?" = "0" ]; then
81
82 if [ "$gslang" = "es" ]; then
83 echo "La versión del Ambiente de Ejecución Java (JRE por sus siglas en "
84 echo "inglés) que usted tiene instalada es demasiado vieja para ejecutar "
85 echo "la Interfaz de la $PROGNAME. Por favor instale "
86 echo "una nueva versión del Ambiente de Ejecución Java (versión $MIN_DISPLAY_VERSION o "
87 echo "posterior) y ejecute nuevamente este guión."
88 elif [ "$gslang" = "fr" ]; then
89 echo "La version de Java Runtime Environment que vous avez installée est"
90 echo "trop vielle pour faire fonctionner $PROGNAME."
91 echo "Veuillez installer une nouvelle version du JRE (version $MIN_DISPLAY_VERSION ou plus"
92 echo "récente) et redémarrez le script."
93 elif [ "$gslang" = "ru" ]; then
94 echo "÷ÅÒÓÉÑ Java Runtime Environment, ËÏÔÏÒÕÀ ÷Ù ÕÓÔÁÎÏ×ÉÌÉ, ÏÞÅÎØ ÓÔÁÒÁ,"
95 echo "ÞÔÏÂÙ ÕÐÒÁ×ÌÑÔØ ÂÉÂÌÉÏÔÅÞÎÙÍ $PROGNAME. ðÏÖÁÌÕÊÓÔÁ, "
96 echo "ÕÓÔÁÎÏ×ÉÔÅ ÎÏ×ÕÀ ×ÅÒÓÉÀ JRE (×ÅÒÓÉÀ $MIN_DISPLAY_VERSION ÉÌÉ ÂÏÌÅÅ ÎÏ×ÕÀ) É"
97 echo "ÐÅÒÅÕÓÔÁÎÏ×ÉÔÅ ÜÔÏÔ ÓËÒÉÐÔ"
98 else
99 echo "The version of the Java Runtime Environment you have installed ($OLDVER)"
100 echo "is too old to run the $PROGNAME. Please install a new"
101 echo "version of the JRE (version $MIN_DISPLAY_VERSION or newer) and rerun this script."
102 fi
103 return 1
104
105 else
106 no_java "$MIN_DISPLAY_VERSION"
107 return $?
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=
121gslang=$1
122PROGNAME=$2
123MINIMUM_JAVA_VERSION=1.4.0_00
124MIN_DISPLAY_VERSION=1.4
125
126# sus out search4j
127# first look for compiled search4j executable inside the current folder
128if [ -x search4j ]; then
129 SEARCH4J_EXECUTABLE=search4j
130elif [ -x "$GSDLHOME/bin/$GSDLOS/search4j" ]; then
131 SEARCH4J_EXECUTABLE=$GSDLHOME/bin/$GSDLOS/search4j
132elif [ -x "$GSDL3SRCHOME/bin/$GSDLOS/search4j" ]; then
133 SEARCH4J_EXECUTABLE=$GSDL3SRCHOME/bin/search4j
134elif [ -x "../bin/$GSDLOS/search4j" ]; then
135 SEARCH4J_EXECUTABLE=../bin/$GSDLOS/search4j
136elif [ -x "../bin/search4j" ]; then
137 SEARCH4J_EXECUTABLE=../bin/search4j
138else
139 echo "Couldn't determine the location of the search4j executable"
140 echo "If you are running Greenstone2"
141 echo " * check GSDLHOME is set"
142 echo " * check bin/$GSDLOS/search4j exists"
143 echo " * check bin/$GSDLOS/search4j is executable"
144 echo "If you are running Greenstone3"
145 echo " * check GSDL3SRCHOME is set"
146 echo " * check bin/search4j exists"
147 echo " * check bin/search4j is executable"
148 echo " * try running 'ant compile-search4j'"
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.