source: gli/trunk/findjava.sh@ 19737

Last change on this file since 19737 was 19737, checked in by ak19, 12 years ago

Bugfix in branches that hadn't been executed so far: can't call return on a function that returns a value. Also made glilang a parameter, since findjava.sh is now almost duplicated for the GS2 installation folder as well, which can't be using glilang. Now the variable is called gslang inside the findjava.sh script.

  • 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 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 ..;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
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 repository browser.