1*cdf0e10cSrcweir#!/bin/sh
2*cdf0e10cSrcweir
3*cdf0e10cSrcweirjarfilename="JavaSetup.jar"
4*cdf0e10cSrcweirtempdir=/var/tmp/install_$$
5*cdf0e10cSrcweirjava_runtime="java"
6*cdf0e10cSrcweirjava_runtime_set="no"
7*cdf0e10cSrcweirjava_runtime_found="no"
8*cdf0e10cSrcweirjava_runtime_sufficient="no"
9*cdf0e10cSrcweirjava_versions_supported="1.4 1.5 1.6"
10*cdf0e10cSrcweirrpm2cpio_found="no"
11*cdf0e10cSrcweirrpm_found="no"
12*cdf0e10cSrcweirsunjavahotspot="HotSpot"
13*cdf0e10cSrcweirerrortext=""
14*cdf0e10cSrcweirerrorcode=""
15*cdf0e10cSrcweir
16*cdf0e10cSrcweirstart_java()
17*cdf0e10cSrcweir{
18*cdf0e10cSrcweir    umask 022
19*cdf0e10cSrcweir
20*cdf0e10cSrcweir    echo "Using $java_runtime"
21*cdf0e10cSrcweir    echo `$java_runtime -version`
22*cdf0e10cSrcweir    echo "Running installer"
23*cdf0e10cSrcweir
24*cdf0e10cSrcweir    # looking for environment variables
25*cdf0e10cSrcweir
26*cdf0e10cSrcweir    home=""
27*cdf0e10cSrcweir    if [ "x" != "x$HOME" ]; then
28*cdf0e10cSrcweir        home=-DHOME=$HOME
29*cdf0e10cSrcweir    fi
30*cdf0e10cSrcweir
31*cdf0e10cSrcweir    log_module_states=""
32*cdf0e10cSrcweir    if [ "x" != "x$LOG_MODULE_STATES" ]; then
33*cdf0e10cSrcweir        log_module_states=-DLOG_MODULE_STATES=$LOG_MODULE_STATES
34*cdf0e10cSrcweir    fi
35*cdf0e10cSrcweir
36*cdf0e10cSrcweir    getuid_path=""
37*cdf0e10cSrcweir    if [ "x" != "x$GETUID_PATH" ]; then
38*cdf0e10cSrcweir        getuid_path=-DGETUID_PATH=$GETUID_PATH
39*cdf0e10cSrcweir    fi
40*cdf0e10cSrcweir
41*cdf0e10cSrcweir    if [ "x" != "x$jrefile" ]; then
42*cdf0e10cSrcweir        jrecopy=-DJRE_FILE=$jrefile
43*cdf0e10cSrcweir    fi
44*cdf0e10cSrcweir
45*cdf0e10cSrcweir    # run the installer class file
46*cdf0e10cSrcweir    echo $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename
47*cdf0e10cSrcweir    $java_runtime $home $log_module_states $getuid_path $jrecopy -jar $jarfilename
48*cdf0e10cSrcweir}
49*cdf0e10cSrcweir
50*cdf0e10cSrcweircleanup()
51*cdf0e10cSrcweir{
52*cdf0e10cSrcweir    if [ "x$tempdir" != "x" -a -d "$tempdir" ]; then
53*cdf0e10cSrcweir        rm -rf $tempdir
54*cdf0e10cSrcweir    fi
55*cdf0e10cSrcweir}
56*cdf0e10cSrcweir
57*cdf0e10cSrcweirdo_exit()
58*cdf0e10cSrcweir{
59*cdf0e10cSrcweir    exitstring=$errortext
60*cdf0e10cSrcweir    if [ "x" != "x$errorcode" ]; then
61*cdf0e10cSrcweir        exitstring="$exitstring (exit code $errorcode)"
62*cdf0e10cSrcweir    fi
63*cdf0e10cSrcweir
64*cdf0e10cSrcweir    # simply echo the exitstring or open a xterm
65*cdf0e10cSrcweir    # -> dependent from tty
66*cdf0e10cSrcweir
67*cdf0e10cSrcweir    if tty ; then
68*cdf0e10cSrcweir        echo $exitstring
69*cdf0e10cSrcweir    else
70*cdf0e10cSrcweir        mkdir $tempdir
71*cdf0e10cSrcweir
72*cdf0e10cSrcweir        # creating error file
73*cdf0e10cSrcweir        errorfile=$tempdir/error
74*cdf0e10cSrcweir
75*cdf0e10cSrcweir        cat > $errorfile << EOF
76*cdf0e10cSrcweirecho "$exitstring"
77*cdf0e10cSrcweirecho "Press return to continue ..."
78*cdf0e10cSrcweirread a
79*cdf0e10cSrcweirEOF
80*cdf0e10cSrcweir
81*cdf0e10cSrcweir        chmod 755 $errorfile
82*cdf0e10cSrcweir
83*cdf0e10cSrcweir        # searching for xterm in path
84*cdf0e10cSrcweir        xtermname="xterm"
85*cdf0e10cSrcweir        xtermfound="no";
86*cdf0e10cSrcweir        for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
87*cdf0e10cSrcweir            if [ -x "$i/$xtermname" -a ! -d "$i/$xtermname" ]; then
88*cdf0e10cSrcweir                xtermname="$i/$xtermname"
89*cdf0e10cSrcweir                xtermfound="yes"
90*cdf0e10cSrcweir                break
91*cdf0e10cSrcweir            fi
92*cdf0e10cSrcweir        done
93*cdf0e10cSrcweir
94*cdf0e10cSrcweir        if [ $xtermfound = "no" -a "`uname -s`" = "SunOS" ]; then
95*cdf0e10cSrcweir            if [ -x /usr/openwin/bin/xterm ]; then
96*cdf0e10cSrcweir                xtermname=/usr/openwin/bin/xterm
97*cdf0e10cSrcweir                xtermfound="yes"
98*cdf0e10cSrcweir            fi
99*cdf0e10cSrcweir        fi
100*cdf0e10cSrcweir
101*cdf0e10cSrcweir        if [ $xtermfound = "yes" ]; then
102*cdf0e10cSrcweir            $xtermname -e $errorfile
103*cdf0e10cSrcweir        fi
104*cdf0e10cSrcweir    fi
105*cdf0e10cSrcweir
106*cdf0e10cSrcweir    cleanup
107*cdf0e10cSrcweir
108*cdf0e10cSrcweir    exit $errorcode
109*cdf0e10cSrcweir}
110*cdf0e10cSrcweir
111*cdf0e10cSrcweirset_jre_for_uninstall()
112*cdf0e10cSrcweir{
113*cdf0e10cSrcweir    # if "uninstalldata" exists, this is not required
114*cdf0e10cSrcweir    if [ ! -d "uninstalldata" ]; then
115*cdf0e10cSrcweir        packagepath="RPMS"
116*cdf0e10cSrcweir        jrefile=`find $packagepath -type f -name "jre*.rpm" -print`
117*cdf0e10cSrcweir        jrefile=`basename $jrefile`
118*cdf0e10cSrcweir        if [ -z "$jrefile" ]; then
119*cdf0e10cSrcweir            jrefile="notfound"
120*cdf0e10cSrcweir        fi
121*cdf0e10cSrcweir
122*cdf0e10cSrcweir        # check existence of jre rpm
123*cdf0e10cSrcweir        if [ ! -f $packagepath/$jrefile ]; then
124*cdf0e10cSrcweir            errortext="Error: Java Runtime Environment (JRE) not found in directory: $packagepath"
125*cdf0e10cSrcweir            errorcode="4"
126*cdf0e10cSrcweir            do_exit
127*cdf0e10cSrcweir        fi
128*cdf0e10cSrcweir    fi
129*cdf0e10cSrcweir}
130*cdf0e10cSrcweir
131*cdf0e10cSrcweirinstall_linux_rpm()
132*cdf0e10cSrcweir{
133*cdf0e10cSrcweir    # Linux requires usage of rpm2cpio to install JRE with user privileges
134*cdf0e10cSrcweir    # 1. --relocate /usr/java=/var/tmp does not work, because not all files are
135*cdf0e10cSrcweir    #    relocatable. Some are always installed into /etc
136*cdf0e10cSrcweir    # 2. --root only works with root privileges. With user privileges only the
137*cdf0e10cSrcweir    #    database is shifted, but not the files.
138*cdf0e10cSrcweir
139*cdf0e10cSrcweir    # On Linux currently rpm2cpio is required (and rpm anyhow)
140*cdf0e10cSrcweir
141*cdf0e10cSrcweir    find_rpm2cpio()
142*cdf0e10cSrcweir
143*cdf0e10cSrcweir    if [ ! "$rpm2cpio_found" = "yes" ]; then
144*cdf0e10cSrcweir        errortext="Error: Did not find rpm2cpio. rpm2cpio is currently required for installations on Linux."
145*cdf0e10cSrcweir        errorcode="11"
146*cdf0e10cSrcweir        do_exit
147*cdf0e10cSrcweir    fi
148*cdf0e10cSrcweir
149*cdf0e10cSrcweir    find_rpm()
150*cdf0e10cSrcweir
151*cdf0e10cSrcweir    if [ ! "$rpm_found" = "yes" ]; then
152*cdf0e10cSrcweir        errortext="Error: Did not find rpm. rpm is currently required for installations on Linux."
153*cdf0e10cSrcweir        errorcode="12"
154*cdf0e10cSrcweir        do_exit
155*cdf0e10cSrcweir    fi
156*cdf0e10cSrcweir
157*cdf0e10cSrcweir    # jrefile=jre-6-linux-i586.rpm
158*cdf0e10cSrcweir    # javahome=usr/java/jre1.6.0
159*cdf0e10cSrcweir
160*cdf0e10cSrcweir    packagepath="RPMS"
161*cdf0e10cSrcweir
162*cdf0e10cSrcweir    # using "uninstalldata" for uninstallation
163*cdf0e10cSrcweir    if [ -d "uninstalldata" ]; then
164*cdf0e10cSrcweir        packagepath="uninstalldata/jre"
165*cdf0e10cSrcweir    fi
166*cdf0e10cSrcweir
167*cdf0e10cSrcweir    jrefile=`find $packagepath -type f -name "jre*.rpm" -print`
168*cdf0e10cSrcweir    jrefile=`basename $jrefile`
169*cdf0e10cSrcweir    if [ -z "$jrefile" ]; then
170*cdf0e10cSrcweir        jrefile="notfound"
171*cdf0e10cSrcweir    fi
172*cdf0e10cSrcweir
173*cdf0e10cSrcweir    # check existence of jre rpm
174*cdf0e10cSrcweir    if [ ! -f $packagepath/$jrefile ]; then
175*cdf0e10cSrcweir        errortext="Error: Java Runtime Environment (JRE) not found in directory: $packagepath"
176*cdf0e10cSrcweir        errorcode="4"
177*cdf0e10cSrcweir        do_exit
178*cdf0e10cSrcweir    fi
179*cdf0e10cSrcweir
180*cdf0e10cSrcweir    PACKED_JARS="lib/rt.jar lib/jsse.jar lib/charsets.jar  lib/ext/localedata.jar lib/plugin.jar lib/javaws.jar lib/deploy.jar"
181*cdf0e10cSrcweir
182*cdf0e10cSrcweir    mkdir $tempdir
183*cdf0e10cSrcweir
184*cdf0e10cSrcweir    trap 'rm -rf $tempdir; exit 1' HUP INT QUIT TERM
185*cdf0e10cSrcweir
186*cdf0e10cSrcweir    tempjrefile=$tempdir/$jrefile
187*cdf0e10cSrcweir    cp $packagepath/$jrefile $tempjrefile
188*cdf0e10cSrcweir
189*cdf0e10cSrcweir    if [ ! -f "$tempjrefile" ]; then
190*cdf0e10cSrcweir        errortext="Error: Failed to copy Java Runtime Environment (JRE) temporarily."
191*cdf0e10cSrcweir        errorcode="5"
192*cdf0e10cSrcweir        do_exit
193*cdf0e10cSrcweir    fi
194*cdf0e10cSrcweir
195*cdf0e10cSrcweir    # check if copy was successful
196*cdf0e10cSrcweir    if [ -x /usr/bin/sum ]; then
197*cdf0e10cSrcweir
198*cdf0e10cSrcweir        echo "Checksumming..."
199*cdf0e10cSrcweir
200*cdf0e10cSrcweir        sumA=`/usr/bin/sum $packagepath/$jrefile`
201*cdf0e10cSrcweir        index=1
202*cdf0e10cSrcweir        for s in $sumA; do
203*cdf0e10cSrcweir            case $index in
204*cdf0e10cSrcweir                1)
205*cdf0e10cSrcweir                    sumA1=$s;
206*cdf0e10cSrcweir                    index=2;
207*cdf0e10cSrcweir                    ;;
208*cdf0e10cSrcweir                2)
209*cdf0e10cSrcweir                    sumA2=$s;
210*cdf0e10cSrcweir                    index=3;
211*cdf0e10cSrcweir                    ;;
212*cdf0e10cSrcweir            esac
213*cdf0e10cSrcweir        done
214*cdf0e10cSrcweir
215*cdf0e10cSrcweir        sumB=`/usr/bin/sum $tempjrefile`
216*cdf0e10cSrcweir        index=1
217*cdf0e10cSrcweir        for s in $sumB; do
218*cdf0e10cSrcweir            case $index in
219*cdf0e10cSrcweir                1)
220*cdf0e10cSrcweir                    sumB1=$s;
221*cdf0e10cSrcweir                    index=2;
222*cdf0e10cSrcweir                    ;;
223*cdf0e10cSrcweir                2)
224*cdf0e10cSrcweir                    sumB2=$s;
225*cdf0e10cSrcweir                    index=3;
226*cdf0e10cSrcweir                    ;;
227*cdf0e10cSrcweir            esac
228*cdf0e10cSrcweir        done
229*cdf0e10cSrcweir
230*cdf0e10cSrcweir        # echo "Checksum 1: A1: $sumA1 B1: $sumB1"
231*cdf0e10cSrcweir        # echo "Checksum 2: A2: $sumA2 B2: $sumB2"
232*cdf0e10cSrcweir
233*cdf0e10cSrcweir        if [ $sumA1 -ne $sumB1 ] || [ $sumA2 -ne $sumB2 ]; then
234*cdf0e10cSrcweir            errortext="Error: Failed to install Java Runtime Environment (JRE) temporarily."
235*cdf0e10cSrcweir            errorcode="6"
236*cdf0e10cSrcweir            do_exit
237*cdf0e10cSrcweir        fi
238*cdf0e10cSrcweir    else
239*cdf0e10cSrcweir        echo "Can't find /usr/bin/sum to do checksum. Continuing anyway."
240*cdf0e10cSrcweir    fi
241*cdf0e10cSrcweir
242*cdf0e10cSrcweir    # start to install jre
243*cdf0e10cSrcweir    echo "Extracting ..."
244*cdf0e10cSrcweir    olddir=`pwd`
245*cdf0e10cSrcweir    cd "$tempdir"
246*cdf0e10cSrcweir    rpm2cpio $tempjrefile | cpio -i --make-directories
247*cdf0e10cSrcweir    rm -f $tempjrefile # we do not need it anymore, so conserve discspace
248*cdf0e10cSrcweir
249*cdf0e10cSrcweir    javahomeparent=usr/java
250*cdf0e10cSrcweir    javahomedir=`find $javahomeparent -maxdepth 1 -type d -name "jre*" -print`
251*cdf0e10cSrcweir    javahomedir=`basename $javahomedir`
252*cdf0e10cSrcweir    if [ -z "$javahomedir" ]; then
253*cdf0e10cSrcweir        javahomedir="notfound"
254*cdf0e10cSrcweir    fi
255*cdf0e10cSrcweir
256*cdf0e10cSrcweir    javahome=$javahomeparent/$javahomedir
257*cdf0e10cSrcweir
258*cdf0e10cSrcweir    if [ ! -d ${javahome} ]; then
259*cdf0e10cSrcweir        errortext="Error: Failed to extract the Java Runtime Environment (JRE) files."
260*cdf0e10cSrcweir        errorcode="7"
261*cdf0e10cSrcweir        do_exit
262*cdf0e10cSrcweir    fi
263*cdf0e10cSrcweir
264*cdf0e10cSrcweir    UNPACK_EXE=$javahome/bin/unpack200
265*cdf0e10cSrcweir    if [ -f $UNPACK_EXE ]; then
266*cdf0e10cSrcweir        chmod +x $UNPACK_EXE
267*cdf0e10cSrcweir        packerror=""
268*cdf0e10cSrcweir        for i in $PACKED_JARS; do
269*cdf0e10cSrcweir            if [ -f $javahome/`dirname $i`/`basename $i .jar`.pack ]; then
270*cdf0e10cSrcweir                # printf "Creating %s\n" $javahome/$i
271*cdf0e10cSrcweir                $UNPACK_EXE $javahome/`dirname $i`/`basename $i .jar`.pack $javahome/$i
272*cdf0e10cSrcweir                if [ $? -ne 0 ] || [ ! -f $javahome/$i ]; then
273*cdf0e10cSrcweir                    printf "ERROR: Failed to unpack JAR file:\n\n\t%s\n\n" $i
274*cdf0e10cSrcweir                    printf "Installation failed. Please refer to the Troubleshooting Section of\n"
275*cdf0e10cSrcweir                    printf "the Installation Instructions on the download page.\n"
276*cdf0e10cSrcweir                    packerror="1"
277*cdf0e10cSrcweir                    break
278*cdf0e10cSrcweir                fi
279*cdf0e10cSrcweir
280*cdf0e10cSrcweir                # remove the old pack file
281*cdf0e10cSrcweir                rm -f $javahome/`dirname $i`/`basename $i .jar`.pack
282*cdf0e10cSrcweir            fi
283*cdf0e10cSrcweir        done
284*cdf0e10cSrcweir        if [  "$packerror" = "1" ]; then
285*cdf0e10cSrcweir            if [ -d $javahome ]; then
286*cdf0e10cSrcweir                /bin/rm -rf $javahome
287*cdf0e10cSrcweir            fi
288*cdf0e10cSrcweir
289*cdf0e10cSrcweir            errortext="Error: Failed to extract the Java Runtime Environment (JRE) files."
290*cdf0e10cSrcweir            errorcode="8"
291*cdf0e10cSrcweir            do_exit
292*cdf0e10cSrcweir        fi
293*cdf0e10cSrcweir    fi
294*cdf0e10cSrcweir
295*cdf0e10cSrcweir    PREFS_LOCATION="`echo \"${javahome}\" | sed -e 's/^jdk.*/&\/jre/'`/.systemPrefs"
296*cdf0e10cSrcweir
297*cdf0e10cSrcweir    if [ ! -d "${PREFS_LOCATION}" ]; then
298*cdf0e10cSrcweir        mkdir -m 755 "${PREFS_LOCATION}"
299*cdf0e10cSrcweir    fi
300*cdf0e10cSrcweir    if [ ! -f "${PREFS_LOCATION}/.system.lock" ]; then
301*cdf0e10cSrcweir        touch "${PREFS_LOCATION}/.system.lock"
302*cdf0e10cSrcweir        chmod 644 "${PREFS_LOCATION}/.system.lock"
303*cdf0e10cSrcweir    fi
304*cdf0e10cSrcweir    if [ ! -f "${PREFS_LOCATION}/.systemRootModFile" ]; then
305*cdf0e10cSrcweir        touch "${PREFS_LOCATION}/.systemRootModFile"
306*cdf0e10cSrcweir        chmod 644 "${PREFS_LOCATION}/.systemRootModFile"
307*cdf0e10cSrcweir    fi
308*cdf0e10cSrcweir
309*cdf0e10cSrcweir    if [ x$ARCH = "x32" ] && [ -f "$javahome/bin/java" ]; then
310*cdf0e10cSrcweir        "$javahome/bin/java" -client -Xshare:dump > /dev/null 2>&1
311*cdf0e10cSrcweir    fi
312*cdf0e10cSrcweir
313*cdf0e10cSrcweir    java_runtime=$tempdir/$javahome/bin/java
314*cdf0e10cSrcweir
315*cdf0e10cSrcweir    # Make symbolic links to all TrueType font files installed in the system
316*cdf0e10cSrcweir    # to avoid garbles for Japanese, Korean or Chinese
317*cdf0e10cSrcweir    language=`printenv LANG | cut -c 1-3`
318*cdf0e10cSrcweir    if [ x$language = "xja_" -o x$language = "xko_" -o x$language = "xzh_" ]; then
319*cdf0e10cSrcweir	    font_fallback_dir=$javahome/lib/fonts/fallback
320*cdf0e10cSrcweir	    echo "Making symbolic links to TrueType font files into $font_fallback_dir."
321*cdf0e10cSrcweir	    mkdir -p $font_fallback_dir
322*cdf0e10cSrcweir	    ttf_files=`locate "*.ttf" | xargs`
323*cdf0e10cSrcweir        if [ x$ttf_files = "x" ]; then
324*cdf0e10cSrcweir            ttf_files=`find /usr/share/fonts/ -name "*ttf"`
325*cdf0e10cSrcweir            if [ x$ttf_files = "x" ]; then
326*cdf0e10cSrcweir                ttf_files=`find /usr/X11R6/lib/ -name "*ttf"`
327*cdf0e10cSrcweir            fi
328*cdf0e10cSrcweir        fi
329*cdf0e10cSrcweir	    ln -s $ttf_files $font_fallback_dir
330*cdf0e10cSrcweir    fi
331*cdf0e10cSrcweir
332*cdf0e10cSrcweir    echo "Done."
333*cdf0e10cSrcweir    cd "$olddir"
334*cdf0e10cSrcweir}
335*cdf0e10cSrcweir
336*cdf0e10cSrcweirfind_rpm2cpio()
337*cdf0e10cSrcweir{
338*cdf0e10cSrcweir    # searching for rpm2cpio in path
339*cdf0e10cSrcweir    for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
340*cdf0e10cSrcweir        if [ -x "$i/rpm2cpio" -a ! -d "$i/$rpm2cpio" ]; then
341*cdf0e10cSrcweir            rpm2cpio_found="yes"
342*cdf0e10cSrcweir            break
343*cdf0e10cSrcweir        fi
344*cdf0e10cSrcweir    done
345*cdf0e10cSrcweir}
346*cdf0e10cSrcweir
347*cdf0e10cSrcweirfind_rpm()
348*cdf0e10cSrcweir{
349*cdf0e10cSrcweir    # searching for rpm in path
350*cdf0e10cSrcweir    for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
351*cdf0e10cSrcweir        if [ -x "$i/rpm" -a ! -d "$i/$rpm" ]; then
352*cdf0e10cSrcweir            rpm_found="yes"
353*cdf0e10cSrcweir            break
354*cdf0e10cSrcweir        fi
355*cdf0e10cSrcweir    done
356*cdf0e10cSrcweir}
357*cdf0e10cSrcweir
358*cdf0e10cSrcweircheck_architecture()
359*cdf0e10cSrcweir{
360*cdf0e10cSrcweir    # Check, if system and installation set fit together (x86 and sparc).
361*cdf0e10cSrcweir    # If not, throw a warning.
362*cdf0e10cSrcweir    # Architecture of the installation set is saved in file "installdata/xpd/setup.xpd"
363*cdf0e10cSrcweir    # <architecture>sparc</architecture> or <architecture>i386</architecture>
364*cdf0e10cSrcweir    # Architecture of system is determined with "uname -p"
365*cdf0e10cSrcweir
366*cdf0e10cSrcweir    setupxpdfile="installdata/xpd/setup.xpd"
367*cdf0e10cSrcweir
368*cdf0e10cSrcweir    if [ -f $setupxpdfile ]; then
369*cdf0e10cSrcweir        platform=`uname -p`	# valid values are "sparc" or "i386"
370*cdf0e10cSrcweir        searchstring="<architecture>$platform</architecture>"
371*cdf0e10cSrcweir        match=`cat $setupxpdfile | grep $searchstring`
372*cdf0e10cSrcweir
373*cdf0e10cSrcweir        if [ -z "$match" ]; then
374*cdf0e10cSrcweir            # architecture does not fit, warning required
375*cdf0e10cSrcweir            if [ "$platform" = "sparc" ]; then
376*cdf0e10cSrcweir                echo "Warning: This is an attempt to install Solaris x86 packages on Solaris Sparc."
377*cdf0e10cSrcweir            else
378*cdf0e10cSrcweir                echo "Warning: This is an attempt to install Solaris Sparc packages on Solaris x86."
379*cdf0e10cSrcweir            fi
380*cdf0e10cSrcweir        fi
381*cdf0e10cSrcweir    fi
382*cdf0e10cSrcweir}
383*cdf0e10cSrcweir
384*cdf0e10cSrcweirfind_solaris_jre()
385*cdf0e10cSrcweir{
386*cdf0e10cSrcweir    # searching for java runtime in path
387*cdf0e10cSrcweir    for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
388*cdf0e10cSrcweir        if [ -x "$i/$java_runtime" -a ! -d "$i/$java_runtime" ]; then
389*cdf0e10cSrcweir            java_runtime="$i/$java_runtime"
390*cdf0e10cSrcweir            java_runtime_found="yes"
391*cdf0e10cSrcweir            break
392*cdf0e10cSrcweir        fi
393*cdf0e10cSrcweir    done
394*cdf0e10cSrcweir}
395*cdf0e10cSrcweir
396*cdf0e10cSrcweircheck_jre_version()
397*cdf0e10cSrcweir{
398*cdf0e10cSrcweir    # check version of an installed JRE
399*cdf0e10cSrcweir    javaoutput=`$java_runtime -version 2>&1 | tail ${tail_args} -1`
400*cdf0e10cSrcweir    hotspot=`echo $javaoutput | grep $sunjavahotspot`
401*cdf0e10cSrcweir    if [ ! -z "$hotspot" ]; then
402*cdf0e10cSrcweir        for i in $java_versions_supported; do
403*cdf0e10cSrcweir            versionmatch=`echo $javaoutput | grep $i`
404*cdf0e10cSrcweir            if [ ! -z "$versionmatch" ]; then
405*cdf0e10cSrcweir                java_runtime_sufficient="yes"
406*cdf0e10cSrcweir                break
407*cdf0e10cSrcweir            fi
408*cdf0e10cSrcweir        done
409*cdf0e10cSrcweir
410*cdf0e10cSrcweir        # check new version format, where version number is not part of line 3 (1.6)
411*cdf0e10cSrcweir        if [ ! "$java_runtime_sufficient" = "yes" ]; then
412*cdf0e10cSrcweir            javaoutput=`$java_runtime -version 2>&1 | head ${tail_args} -3`
413*cdf0e10cSrcweir            for i in $java_versions_supported; do
414*cdf0e10cSrcweir                versionmatch=`echo $javaoutput | grep $i`
415*cdf0e10cSrcweir                if [ ! -z "$versionmatch" ]; then
416*cdf0e10cSrcweir                    java_runtime_sufficient="yes"
417*cdf0e10cSrcweir                    break
418*cdf0e10cSrcweir                fi
419*cdf0e10cSrcweir            done
420*cdf0e10cSrcweir        fi
421*cdf0e10cSrcweir    fi
422*cdf0e10cSrcweir}
423*cdf0e10cSrcweir
424*cdf0e10cSrcweir# the user might want to specify java runtime on the commandline
425*cdf0e10cSrcweirUSAGE="Usage: $0 [ -j <java_runtime> ]"
426*cdf0e10cSrcweirwhile getopts hj: opt; do
427*cdf0e10cSrcweir    echo "Parameter: $opt"
428*cdf0e10cSrcweir    case $opt in
429*cdf0e10cSrcweir        j)  java_runtime_set="yes";
430*cdf0e10cSrcweir            java_runtime="${OPTARG}"
431*cdf0e10cSrcweir            if [ ! -f "$java_runtime" ]; then
432*cdf0e10cSrcweir                errortext="Error: Invalid java runtime $java_runtime, file does not exist."
433*cdf0e10cSrcweir                errorcode="2"
434*cdf0e10cSrcweir                do_exit
435*cdf0e10cSrcweir            fi
436*cdf0e10cSrcweir            if [ ! -x "$java_runtime" ]; then
437*cdf0e10cSrcweir                errortext="Error: Invalid java runtime $java_runtime, not an executable file."
438*cdf0e10cSrcweir                errorcode="3"
439*cdf0e10cSrcweir                do_exit
440*cdf0e10cSrcweir            fi
441*cdf0e10cSrcweir            java_runtime_found="yes";
442*cdf0e10cSrcweir            ;;
443*cdf0e10cSrcweir        h)  echo ${USAGE}
444*cdf0e10cSrcweir            errortext=""
445*cdf0e10cSrcweir            errorcode=""
446*cdf0e10cSrcweir            do_exit
447*cdf0e10cSrcweir            ;;
448*cdf0e10cSrcweir        \?) echo ${USAGE}
449*cdf0e10cSrcweir            errortext=""
450*cdf0e10cSrcweir            errorcode=""
451*cdf0e10cSrcweir            do_exit
452*cdf0e10cSrcweir            ;;
453*cdf0e10cSrcweir    esac
454*cdf0e10cSrcweirdone
455*cdf0e10cSrcweir
456*cdf0e10cSrcweir# changing into setup directory
457*cdf0e10cSrcweircd "`dirname "$0"`"
458*cdf0e10cSrcweir
459*cdf0e10cSrcweir# prepare jre, if not set on command line
460*cdf0e10cSrcweirif [ "$java_runtime_set" != "yes" ]; then
461*cdf0e10cSrcweir    platform=`uname -s`
462*cdf0e10cSrcweir    if [ "`uname -s`" = "Linux" ]; then
463*cdf0e10cSrcweir        install_linux_rpm
464*cdf0e10cSrcweir    elif [ "`uname -s`" = "SunOS" ]; then
465*cdf0e10cSrcweir        check_architecture
466*cdf0e10cSrcweir        find_solaris_jre
467*cdf0e10cSrcweir        if [ "$java_runtime_found" = "yes" ]; then
468*cdf0e10cSrcweir            check_jre_version
469*cdf0e10cSrcweir            if [ ! "$java_runtime_sufficient" = "yes" ]; then
470*cdf0e10cSrcweir                errortext="Error: Did not find a valid Java Runtime Environment (JRE). Required JRE versions: $java_versions_supported"
471*cdf0e10cSrcweir                errorcode="9"
472*cdf0e10cSrcweir                do_exit
473*cdf0e10cSrcweir            fi
474*cdf0e10cSrcweir        else
475*cdf0e10cSrcweir            errortext="Error: Did not find an installed Java Runtime Environment (JRE)."
476*cdf0e10cSrcweir            errorcode="10"
477*cdf0e10cSrcweir            do_exit
478*cdf0e10cSrcweir        fi
479*cdf0e10cSrcweir    else
480*cdf0e10cSrcweir        errortext="Error: Platform $platform not supported for Java Runtime Environment (JRE) installation."
481*cdf0e10cSrcweir        errorcode="1"
482*cdf0e10cSrcweir        do_exit
483*cdf0e10cSrcweir    fi
484*cdf0e10cSrcweirfi
485*cdf0e10cSrcweir
486*cdf0e10cSrcweir# jre for Linux is also required, if java runtime is set (for uninstallation mode)
487*cdf0e10cSrcweirif [ "$java_runtime_set" = "yes" ]; then
488*cdf0e10cSrcweir    platform=`uname -s`
489*cdf0e10cSrcweir    if [ "`uname -s`" = "Linux" ]; then
490*cdf0e10cSrcweir        set_jre_for_uninstall
491*cdf0e10cSrcweir    fi
492*cdf0e10cSrcweirfi
493*cdf0e10cSrcweir
494*cdf0e10cSrcweirstart_java
495*cdf0e10cSrcweir
496*cdf0e10cSrcweircleanup
497*cdf0e10cSrcweir
498*cdf0e10cSrcweirexit 0
499