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