#!/bin/sh ################################################################################################# # # LAXUNIX.SH - LaunchAnywhere (tm) version 19.0 # # (c) Copyright 2018 Flexera Software LLC. All rights reserved. # # To run this script you will need to have the following: # 1) a Java VM installed (however, it will handle a lack of Java nicely). # 2) a Java-style properties file having the same name as this script # with the suffix .lax. If this script is appended to the # self-extractor, it will look for the properties file in the # directory specified by $seLaxPath; otherwise, it will look in # the same directory that this script is in. # 3) a Java program in the file "lax.jar". # # The .lax property file must contain at least the following properties: # 1) lax.class.path classpath (do not include the environment variable $CLASSPATH ) # 2) lax.nl.java.launcher.main.class (main class of LaunchAnywhere Executable) # ################################################################################################# # # Since USERENV is already set in the self-extractor, if its not set we know # this is not an installer but a separate launcher. # USERENV is just a flag passed from use.sh. # IS_INSTALLER='' [ $USERENV ] && IS_INSTALLER=true # # later on we might add things to the PATH, but we want to preserve the PATH # order for which VMs are the first ones found. # VM_SEARCH_PATH="$PATH" case `uname -s` in "SunOS") TR="/usr/xpg4/bin/tr" ;; *) TR="/usr/bin/tr" ;; esac #################################################################################### # Set some constants if [ "$1" = "LAX_VM" ]; then lax_vm="LAX_VM" lax_vm_value="$2" shift 2 else lax_vm="" fi anyVMlist="JDK_J2 D12 JRE_J2 R12 JDK_J1 JRE_J1 JDK JRE ALL" #################################################################################### #Specifying some global variables IATEMP="/tmp" DEBUG=0 var_searchAndverifyJvm=2 #var_searchAndverifyJvm - jvm search&verify result; successful search&verify sets to zero; initializing to non-zero var_verifyJVM=2 # verification of a JVM result. successful verification of searched JVM sets to zero; initializing to non-zero pbc=1 LOG=/tmp/ourlog iaVV="true" actvmType="" actvm="" PLATFORM_HINT_FILE=/tmp/tmpPlatformHintFile #################################################################################### # Format commandline args # To overcome the problem of quoted args (with internal spaces) to the launcher # is that they get "unquoted" or separated into discreet args when they are put # on the cmdline for the application. This following block makes sure the stay intact overrideDefaultUIMode="false" ignoreMode="false"; uimode="not set" hasSeenI="false" tmpArgs="" origArgs=$@ for arg in "$@" do if [ "$arg" != "" ]; then tmpArgs="$tmpArgs \"$arg\"" if [ "$arg" = "-i" -o "$arg" = "-I" ]; then hasSeenI="true" elif [ "$hasSeenI" = "true" ]; then lowerArg=`echo $arg | $TR "[:upper:]" "[:lower:]"` if [ "$lowerArg" = "awt" ]; then uimode="awt" overrideDefaultUIMode="true" elif [ "$lowerArg" = "swing" ]; then uimode="swing" overrideDefaultUIMode="true" elif [ "$lowerArg" = "gui" ]; then uimode="gui" overrideDefaultUIMode="true" elif [ "$lowerArg" = "console" ]; then uimode="console" overrideDefaultUIMode="true" elif [ "$lowerArg" = "text" ]; then uimode="console" overrideDefaultUIMode="true" elif [ "$lowerArg" = "silent" ]; then uimode="silent" overrideDefaultUIMode="true" else ignoreMode="true" fi fi fi done # JVM heap size option are no longer required, hence removing it from the command line arguments. # *NOTE* :: This part can be done in the above code but still doing the same again. tmpArgs="" jvmOptPresent="false" for arg in "$@" do if [ "$arg" != "-jvmxms" ] && [ "$arg" != "-jvmxmx" ] && [ "$jvmOptPresent" = "false" ]; then tmpArgs="$tmpArgs \"$arg\"" else if [ "$jvmOptPresent" = "false" ]; then jvmOptPresent="true" else jvmOptPresent="false" fi fi done cmdLineArgs="$tmpArgs" thisScript="$0" # make sure thisScript is an abs path case $thisScript in /*) ;; *) thisScript="`pwd`/$thisScript" ;; esac #################################################################################### # # WHere does the LAX_DEBUG output go? # if [ "$LAX_DEBUG" = "file" ]; then jx_log="`pwd`/jx.log" rm -f "$jx_log" touch "$jx_log" if [ "$?" -gt "0" ]; then jx_log_ok="false" echo "Could not create $jx_log. Sending debug output to console." else jx_log_ok="true" fi fi debugOut() { case "$LAX_DEBUG" in "file" ) if [ "$jx_log_ok" = "true" ]; then echo "$1" >> "$jx_log" else echo "$1" fi ;; "" ) echo "$1" >> /dev/null ;; * ) echo "$1" ;; esac } #################################################################################### # # UNIX ENVIRONMENT configuration # debugOut "" debugOut "========= Analyzing UNIX Environment =================================" # Get os type , note that it is LOWER-CASED. Used here and later on osName=`uname -s 2> /dev/null | $TR "[:upper:]" "[:lower:]" 2> /dev/null` debugOut "Setting UNIX ($osName) flavor specifics." vmScript=".java_wrapper" case "$osName" in *irix*) cpuName="unknown" ;; *hp-ux*|*hpux*) cpuName=`uname -m 2> /dev/null` ;; *solaris*|*sunos*) cpuName=`uname -p 2> /dev/null` THREADS_FLAG=""; export THREADS_FLAG PATH=/usr/bin:$PATH; export PATH ;; *aix*) cpuName="unknown" ;; *freebsd*) cpuName=`uname -p 2> /dev/null` ;; *linux*) cpuName=`uname -m 2> /dev/null` ;; # tlb 2001-09-18 updating to support Darwin *rhapsody*|*darwin*) cpuName=`uname -p 2> /dev/null` vmScript=".java_command" ;; *compaq*|*dg*|*osf*) cpuName="unknown" ;; *) cpuName="unknown" ;; esac if [ -x /bin/ls ]; then lsCMD="/bin/ls" elif [ -x /usr/bin/ls ]; then lsCMD="/usr/bin/ls" else lsCMD="ls" fi debugOut "Importing UNIX environment into LAX properties." #################################################################################### # # CREATE ENV.PROPERTIES and figure out if this is being exec'd from an installer # # We need POSIX awk. On some systems it's called awk, on others # nawk. It's most frequently called nawk, so start with that. # debugOut "Checking for POSIX awk." AWK=nawk ( $AWK '{}' ) < /dev/null 2>&0 || AWK=awk if [ -z "$IATEMPDIR" ]; then TMPDIR=/tmp else TMPDIR=$IATEMPDIR fi if [ -z "$envPropertiesFile" ] then if [ -d $TMPDIR ] then envPropertiesFile=$TMPDIR/env.properties.$$ else envPropertiesFile="$HOME/env.properties.$$" fi fi # # Convert environment variables to LAX properties. The variables # are also named with alternate case (all upper, all lower). # # E.g. # export My_Env_Var="abc # def" # # is converted to: # lax.nl.env.exact_case.My_Env_Var=abc def # lax.nl.env.MY_ENV_VAR=abc def # lax.nl.env.my_env_var=abc def # # The second gsub() is used to escape backslashes so that when the properties # file is read by the java.util.Properties object, there is not a problem # with incorrectly interpreted escaped unicode. # # This code segment is written in POSIX awk for performance reasons. # $AWK -v ISINSTALLER="$IS_INSTALLER" -v LAX_PREFIX=lax.nl.env. ' END { for (var in ENVIRON) { # get variable value value = ENVIRON[var] # strip newlines gsub(/\n/, " ", value) # convert one backslash to two if(ISINSTALLER) gsub(/\\\\/, "\\\\\\\\\\\\\\\\", value) else gsub(/\\/, "\\\\", value) # print as LAX property print LAX_PREFIX "exact_case." var "=" value print LAX_PREFIX tolower(var) "=" value print LAX_PREFIX toupper(var) "=" value } }' < /dev/null > $envPropertiesFile #################################################################################### # # Tracing symbolic links to actual launcher location # resolveLink() { rl_linked="true" rl_operand="$1" rl_origDir="`dirname "$1"`" # bypass the whole thing if this isnt a link rl_ls=`$lsCMD -l "$rl_operand"` case "$rl_ls" in *"->"*) ;; *) resolvedLink="$rl_operand" return ;; esac while [ "$rl_linked" = "true" ]; do # if the operand is not of an abs path, get its abs path case "$rl_operand" in /*) rl_origDir=`dirname "$rl_operand"` ;; \./*) rl_origDir=`pwd` rl_operand="$rl_origDir/$rl_operand" ;; *) rl_operand="$rl_origDir/$rl_operand" ;; esac # # the prevPrev hack is here because .../java often points to .java_wrapper. # at the end of the resolution rl_operand actually points to garbage # signifying it is done resolving the link. So prev is actually .java_wrapper. # but we want the one just before that, its the real vm starting poiint we want # rl_prevOperand="$rl_operand" rl_ls=`$lsCMD -l "$rl_operand"` # get the output ls into a list set x $rl_ls # get rid of x and file info from ls -l shift 9 #is this a link? case "$rl_ls" in *"->"*) rl_linked="true" # is a link, shift past the "->" rl_linker="" while [ "$1" != "->" -a $# -gt 1 ]; do rl_linker="$rl_linker $1" shift done if [ "$1" = "->" ]; then shift fi ;; *) # not a link, the rest must be the targets name rl_linked="false" ;; esac # now grab what's left rl_linkee="$*" # debugOut "Following link to LAX $rl_linker -> $rl_linkee" if [ "$rl_linked" = "true" -a "`basename "$rl_linkee"`" != "$vmScript" ]; then # set to true incase the thing linked to is also a link and we can # try again. The current think linked to now becomes the operand rl_operand="$rl_linkee" # if the linkee is not abs, make it abs relative to the linker case "$rl_operand" in /*) ;; *) rl_operand="$rl_origDir/$rl_operand" ;; esac else # otherwise, this operand is not a link itself and we are done rl_resolvedLink="$rl_prevOperand" # however, do not resolve the last leg of a VMs linked scripts. this will # disrupt their scripts. it is expecting a link to the .java* script # let us believe it is not linked and continue on... if [ "`basename "$rl_linkee"`" = "$vmScript" ]; then rl_linked="false" fi fi # make sure the path returned is absolute case "$rl_operand" in \.\/*) rl_operand="`pwd`/$rl_operand" ;; esac done # remove "/./" in paths, make it "/" # i,e, "/a/b/./c" becomes "/a/b/c" resolvedLink=`echo "$rl_resolvedLink" | sed 's,/\./,/,'` } #################################################################################### # # FINDING THE LAX FILE # # If this is an installer, use $seLaxPath # debugOut "" debugOut "========= Analyzing LAX ==============================================" olddir=`pwd` resolveLink "$thisScript" absLauncherName="$resolvedLink" cd "`dirname "$absLauncherName"`" if [ "$IS_INSTALLER" != "" ]; then if [ ! -z "$seLaxPath" ]; then propfname="$seLaxPath" else # legacy for old self-extractors propfname="$templaxpath" fi else propfname="$absLauncherName.lax" fi if [ ! -r "$propfname" ]; then debugOut "The file "$propfname" could" debugOut "not be found, and the program cannot be run without it." debugOut "Try reinstalling the program." exit; else debugOut "LAX found............................ OK." fi #################################################################################### # # READING THE LAX FILE # OFS="$IFS" # run prop file through sed calls that do: # 1. transform first '=' on a line into a control-O # 2. transform all other ='s to control-F # 3. transform control-Os back to = # this is to differentiate the lhs=rhs processing from confusing the first = from other # = that might be part of the value. Later on those =-tranformed-to-control-Fs are # transformed back to = signs. set x `cat "$propfname" | sed -e 's~^\([^\=]*\)\=\(.*\)~\1\\2~g' -e 's~=~~g' -e 's~~=~g' | grep '='`; shift while test $# -gt 0; do # line separator case "x${1}x" in *"="* ) BIFS=" "; ;; * ) BIFS="" ; ;; esac # word separator case "x${2}x" in *"="* ) AIFS=""; ;; * ) AIFS=""; ;; esac INPUT="$INPUT$BIFS$1$AIFS" shift done while test "x$INPUT" != "x"; do set x $INPUT; shift X="$1" shift INPUT="$@" IFS="=$AIFS" set x $X; shift IFS="$OFS" lhs="${1}" shift rhs="$@" # transform non lhs=rhs delimiting = signs back from ^F to = case "$rhs" in **) rhs=`echo $rhs | sed 's~~=~g'` ;; esac # assing the values case $lhs in lax.class.path*) lax_class_path="$rhs" ;; lax.main.class*) lax_main_class="$rhs" ;; lax.nl.java.launcher.main.class*) lax_nl_java_launcher_main_class="$rhs" ;; lax.nl.current.vm*) lax_nl_current_vm="$rhs" ;; lax.user.dir*) lax_user_dir="$rhs" lax_user_dir=`echo $lax_user_dir | sed 's;^[ ]*\(.*\)[ ]*$;\1;'` ;; lax.resource.dir*) lax_resource_dir="$rhs" lax_resource_dir=`echo $lax_resource_dir | sed 's;^[ ]*\(.*\)[ ]*$;\1;'` ;; lax.stdout.redirect*) lax_stdout_redirect="$rhs" ;; lax.stderr.redirect*) lax_stderr_redirect="$rhs" ;; lax.dir*) lax_dir="$rhs" ;; lax.always.ask*) lax_always_ask="$rhs" ;; lax.application.name*) lax_application_name="$rhs" ;; lax.nl.message.vm.not.loaded*) lax_nl_message_vm_loaded="$rhs" ;; lax.nl.valid.vm.list*) # transform an blank value to "ALL" case "$rhs" in "") rhs="ALL"; ;; esac lax_nl_valid_vm_list="$rhs" ;; lax.nl.java.option.check.source*) verify="$rhs" ;; lax.nl.java.option.verify.mode*) verify_mode="$rhs" ;; lax.nl.java.option.verbose*) verbo="$rhs" ;; lax.nl.java.option.garbage.collection.extent*) gcxtnt="$rhs" ;; lax.nl.java.option.garbage.collection.background.thread*) gcthrd="$rhs" ;; lax.nl.java.option.native.stack.size.max*) nsmax="$rhs" ;; lax.nl.java.option.java.stack.size.max*) jsmax="$rhs" ;; lax.nl.java.option.java.heap.size.max*) jhmax="$rhs" ;; lax.nl.java.option.java.heap.size.initial*) jhinit="$rhs" ;; lax.nl.java.option.debugging*) debug="$rhs" ;; lax.nl.$osName.$cpuName.java.compiler*) lax_nl_osname_cpuname_java_compiler="$rhs" ;; lax.nl.$osName.java.compiler*) lax_nl_osname_java_compiler="$rhs" ;; lax.nl.java.compiler*) lax_nl_java_compiler="$rhs" ;; lax.nl.java.option.additional*) lax_nl_java_option_additional="$rhs" ;; ###################################################### # tlb 2001-09-18 # Reading default UI mode for UNIX lax.installer.unix.ui.default*) lax_installer_unix_ui_default="$rhs" ;; ###################################################### # JIT overrides lax.nl.unix.JDK_J1.java.compiler*) lax_nl_unix_JDK_J1_java_compiler="$rhs" ;; lax.nl.unix.JDK_J2.java.compiler*) lax_nl_unix_JDK_J2_java_compiler="$rhs" ;; lax.nl.unix.JRE_J1.java.compiler*) lax_nl_unix_JRE_J1_java_compiler="$rhs" ;; lax.nl.unix.JRE_J2.java.compiler*) lax_nl_unix_JRE_J2_java_compiler="$rhs" ;; lax.nl.unix.J1.java.compiler*) lax_nl_unix_J1_java_compiler="$rhs" ;; lax.nl.unix.J2.java.compiler*) lax_nl_unix_J2_java_compiler="$rhs" ;; lax.nl.unix.JRE.java.compiler*) lax_nl_unix_JRE_java_compiler="$rhs" ;; lax.nl.unix.JDK.java.compiler*) lax_nl_unix_JDK_java_compiler="$rhs" ;; lax.nl.unix.ALL.java.compiler*) lax_nl_unix_ALL_java_compiler="$rhs" ;; # lax.nl.JDK_J1.java.compiler*) lax_nl_JDK_J1_java_compiler="$rhs" ;; lax.nl.JDK_J2.java.compiler*) lax_nl_JDK_J2_java_compiler="$rhs" ;; lax.nl.JRE_J1.java.compiler*) lax_nl_JRE_J1_java_compiler="$rhs" ;; lax.nl.JRE_J2.java.compiler*) lax_nl_JRE_J2_java_compiler="$rhs" ;; lax.nl.J1.java.compiler*) lax_nl_J1_java_compiler="$rhs" ;; lax.nl.J2.java.compiler*) lax_nl_J2_java_compiler="$rhs" ;; lax.nl.JRE.java.compiler*) lax_nl_JRE_java_compiler="$rhs" ;; lax.nl.JDK.java.compiler*) lax_nl_JDK_java_compiler="$rhs" ;; lax.nl.ALL.java.compiler*) lax_nl_ALL_java_compiler="$rhs" ;; # lax.nl.$osName.JDK_J1.java.compiler*) lax_nl_osname_JDK_J1_java_compiler="$rhs" ;; lax.nl.$osName.JDK_J2.java.compiler*) lax_nl_osname_JDK_J2_java_compiler="$rhs" ;; lax.nl.$osName.JRE_J1.java.compiler*) lax_nl_osname_JRE_J1_java_compiler="$rhs" ;; lax.nl.$osName.JRE_J2.java.compiler*) lax_nl_osname_JRE_J2_java_compiler="$rhs" ;; lax.nl.$osName.J1.java.compiler*) lax_nl_osname_J1_java_compiler="$rhs" ;; lax.nl.$osName.J2.java.compiler*) lax_nl_osname_J2_java_compiler="$rhs" ;; lax.nl.$osName.JRE.java.compiler*) lax_nl_osname_JRE_java_compiler="$rhs" ;; lax.nl.$osName.JDK.java.compiler*) lax_nl_osname_JDK_java_compiler="$rhs" ;; lax.nl.$osName.ALL.java.compiler*) lax_nl_osname_ALL_java_compiler="$rhs" ;; # # JIT overrides ###################################################### esac done debugOut "LAX properties read.................. OK." if [ "${lax_class_path:-""}" = "" ]; then debugOut "The classpath specified in the LAX properties file" debugOut "is invalid. Try reinstalling the program." exit; fi if [ "${lax_nl_java_launcher_main_class:-""}" = "" ]; then debugOut "The main class specified in the LAX properties file" debugOut "is invalid. Try reinstalling the program." exit; fi if [ ! -z "$INSTALLER_OVERRIDE_VMLIST" ]; then lax_nl_valid_vm_list="$INSTALLER_OVERRIDE_VMLIST" fi ################################################### # tlb 2001-09-18 # Making sure the default UNIX UI mode is honored # if overrideDefaultUIMode is not set, which means no commandline # options were entered at the commandline regarding # ui mode, we will look to the LAX file to set a ui # mode. If there is no such setting in the LAX, # which would be an error, we default to GUI. if [ "$overrideDefaultUIMode" = "false" ]; then if [ -n "$lax_installer_unix_ui_default" -a "$ignoreMode" = "false" ]; then if [ $lax_installer_unix_ui_default = SILENT ]; then isSilent="true" cmdLineArgs="$cmdLineArgs -m SILENT" uimode="silent" elif [ $lax_installer_unix_ui_default = CONSOLE ]; then isConsole="true" cmdLineArgs="$cmdLineArgs -m CONSOLE" uimode="console" elif [ $lax_installer_unix_ui_default = GUI ]; then isSilent="false" isConsole="false" uimode="gui" fi fi fi #################################################################################### # # if user.dir != . then relative paths on the classpath will be broken. they # are expecting the pwd to be '.' (meaning the install dir). If user.dir is # any other directory, it will break lax_class_path=`echo "$lax_class_path" | sed 's^;^:^g'` absInstallDir=`dirname "$absLauncherName"` OFS="$IFS" IFS=":" set x $lax_class_path; shift IFS="$OFS" tmp_lcp="" while test $# -gt 0; do case "$1" in \/*) if [ "$tmp_lcp" = "" ]; then tmp_lcp="$1" else tmp_lcp="$tmp_lcp:$1" fi ;; *|*\$ENV_CLASSPATH\$*) if [ "$tmp_lcp" = "" ]; then tmp_lcp="${absInstallDir}/$1" else tmp_lcp="$tmp_lcp:${absInstallDir}/$1" fi ;; esac shift done lax_class_path="$tmp_lcp" # resolve $ENV_CLASSPATH$ OFS="$IFS" IFS=":" set x $lax_class_path; shift IFS="$OFS" tmp_lcp="" while test $# -gt 0; do case "$1" in *\$ENV_CLASSPATH\$*) if [ "$tmp_lcp" = "" ]; then tmp_lcp="$CLASSPATH" else tmp_lcp="$tmp_lcp:$CLASSPATH" fi ;; *) if [ "$tmp_lcp" = "" ]; then tmp_lcp="$1" else tmp_lcp="$tmp_lcp:$1" fi ;; esac shift done lax_class_path="$tmp_lcp" #################################################################################### # just incase this the lax was written in DOS, be sure to make all ';' path # separators into :'s or it will fubar the commandline # case "$smclp" in *\;*) oldIFS=$IFS IFS=";" for smclp_piece in $smclp; do tmp_smclp="$tmp_smclp:$smclp_piece" done IFS=$oldIFS clp=$tmp_smclp ;; esac ################################################################## # Setting stdout and stderr redirection # if [ "$LAX_DEBUG" = "file" -o "$LAX_DEBUG" = "" ]; then echo "lax.stderr.redirect=$lax_stderr_redirect" >> $envPropertiesFile echo "lax.stdout.redirect=$lax_stdout_redirect" >> $envPropertiesFile else echo "lax.stderr.redirect=console" >> $envPropertiesFile echo "lax.stdout.redirect=console" >> $envPropertiesFile lax_stdout_redirect="console" lax_stderr_redirect="console" fi lax_version="16.5" validVMtypeList="$lax_nl_valid_vm_list" # MMA 04.26.2000 # # Added check for validVMtypeList not being set to any value, in # which case we should just set the valid list to all. # if [ "$validVMtypeList" = "ALL" -o "$validVMtypeList" = "" ]; then validVMtypeList=$anyVMlist fi ############################################################# # PICK A VALID VM # debugOut "" debugOut "========= Finding VM =================================================" debugOut "Valid VM types.......................... $validVMtypeList" # # If the vm gets a relative path, we must make it absolute to the Install # Directory tm 3/3 # if [ ! -z "${lax_nl_current_vm:-""}" ]; then # tlb 2001-09-18 updating the LAX to support CD-ROM installations # the variable `expr "$lax_nl_current_vm" : '\/'` will evaluate to 1 if the path starts with / isAbsPath=`expr "$lax_nl_current_vm" : '\/'` if [ "$isAbsPath" = "0" ]; then # When running a CD-ROM installer lax_dir is not set, lax_dir is set by the SEA. # We set it to the working directory if it is not set if [ -z "$lax_dir" ]; then lax_dir=`pwd` abs_lax_nl_current_vm="${lax_dir}"/"${lax_nl_current_vm}" else abs_lax_nl_current_vm="${lax_dir}""${lax_nl_current_vm}" fi else abs_lax_nl_current_vm="$lax_nl_current_vm" fi debugOut "Absolute LAX_VM path.................... $abs_lax_nl_current_vm" fi #-------------------------------------------------------- # getJavaVersion() # # $1: path to java executeable # # returns: # $javaVersion # getJavaVersion() { javaExe=$1 javaVersion=` "${javaExe}" -version 2>&1 | $AWK ' $3 ~ /"[0-9]\.[0-9]\.[0-9][^"]*"$/ { gsub ("[^0-9._]", "", $3) print $3 } ' ` #Added for only jre9 which has java.version as 9 if [ "$javaVersion" = "" ]; then javaVersion=` "${javaExe}" -version 2>&1 | $AWK ' $3 ~ /"[0-9][^"]*"$/ { gsub ("[^0-9._]", "", $3) print $3 } ' ` fi unset javaExe } # #-------------------------------------------------------- ################################################################################# # inspectVM() # # param: a pathname to a potential VM file, maybe a link # # returns: $inspectedVMpath the real path to the VM file # returns: $inspectedVMtype the type of the VM # returns: $inspectedOldVMtype ? # inspectVM() { resolveLink "$1" inspectee="$resolvedLink" inspecteeDir=`dirname "$inspectee"` inspecteeName=`basename "$inspectee"` inspectedVMpath="$inspectee" # # is it JDK1.1 , JDK1.2 or JRE1.2? # if [ "$inspecteeName" = "oldjava" ]; then inspectedOldVMtype="OLDJAVA" inspectedVMtype="OLDJAVA" elif [ "$inspecteeName" = "java" ]; then ############################################################ # Do some OS-specific quirky stuff # # MacOS X / Rhapsody # quirk_classesZip="" if [ "$osName" = "rhapsody" ]; then if [ "`expr "$inspecteeDIR" : ".*JavaVM.framework$"`" != "0" ]; then quirk_classesZip="$file/Classes/classes.jar" inspecteeDir="$inspecteeDir/Home/bin" fi fi # END OS quirky stuff ############################################################ # # is it JDK1.1? # if [ -r "$inspecteeDir/../lib/classes.zip" -o -r "$quirk_classesZip" ]; then inspectedOldVMtype="JDK" inspectedVMtype="JDK_J1" inspectedVMVersion="1.1" else # JDK1.2 # # is the "java" JRE1.2 or JDK1.2? # if [ -r "$inspecteeDir/../lib/dt.jar" ] then inspectedOldVMtype="D12" inspectedVMtype="JDK_J2" else inspectedOldVMtype="R12" inspectedVMtype="JRE_J2" fi # # find version # if [ -r "$inspecteeDir/pack200" ]; then inspectedVMVersion="1.5" elif [ -r "$inspecteeDir/client" -o -r "$inspecteeDir/server" -o -r "$inspecteeDir/../jre/bin/server" -o -r "$inspecteeDir/../jre/bin/server" ]; then inspectedVMVersion="1.4" elif [ -r "$inspecteeDir/hotspot" -o -r "$inspecteeDir/../jre/bin/hotspot" ]; then inspectedVMVersion="1.3" elif [ -r "$inspecteeDir/classic" ]; then inspectedVMVersion="1.2" fi getJavaVersion $inspectee if [ -n "$javaVersion" ]; then inspectedVMVersion=$javaVersion fi unset javaVersion fi elif [ "$inspecteeName" = "jre" ]; then inspectedOldVMtype="JRE" inspectedVMtype="JRE_J1" inspectedVMVersion="1.1" else inspectedOldVMtype="UNKNOWN" inspectedVMtype="UNKNOWN" fi } ### ### end inspectVM() ### ######################################################################################## # massage valid VM list. Expand inclusive types (i.e. JRE = JRE_J1 and JRE_J2 ) tmpValidVMlist="" for type in $validVMtypeList; do case $type in J1) tmpValidVMlist="$tmpValidVMlist JRE_J1 JDK_J1" ;; J2) tmpValidVMlist="$tmpValidVMlist JRE_J2 JDK_J2" ;; JRE) tmpValidVMlist="$tmpValidVMlist JRE_J2 R12 JRE_J1" ;; JDK) tmpValidVMlist="$tmpValidVMlist JDK_J2 D12 JDK_J1" ;; *) tmpValidVMlist="$tmpValidVMlist $type " ;; esac done validVMtypeList="$tmpValidVMlist" debugOut "Expanded Valid VM types................. $validVMtypeList" #-------------------------------------------------------------- # strictCheck # checks that the version passed in matches the 'strict vm # selection pattern' # # $1: vm version # $2: pattern to match # $3: vm type list # # returns: # # exit status: # 0 on match, 1 otherwise strictCheck() { vmVersion=$1 pattern=$2 types=$3 eval `$AWK ' BEGIN { if ( ARGV[1] ~ /^(JDK|JRE)_/ ) { printf ("version=%s\ntype=%s\n", substr(ARGV[1],5), substr(ARGV[1], 1, 3) ); } else { printf ("version=%s\ntype=%s\n",ARGV[1],"none"); } } ' $pattern` $AWK ' function asNum(s) { return s+0; } function versionToNumber(verStr) { split(verStr, verVec, "[._+*]"); return (asNum(verVec[1]) * 1000000) + \ (asNum(verVec[2]) * 10000) + \ (asNum(verVec[3]) * 100) + \ asNum(verVec[4]); } function subVersionOf(version, pattern) { pString = sprintf("%0.8d", pattern); vString = sprintf("%0.8d", version); sub( "0+$", "", pString ); return vString ~ "^" + pString; } BEGIN { version = versionToNumber( ARGV[1] ); pattern = versionToNumber( ARGV[2] ); op = substr(ARGV[2],length(ARGV[2]) ); if (op=="+") success = version >= pattern; else if (op=="*") success = subVersionOf(version, pattern); else success = version == pattern; if (success) exit(0); exit(1); } ' "$vmVersion" "$version" success=$? if [ $success = 0 ]; then case "none $types" in *$type*) debugOut "checking: \"$vmVersion\" against \"$pattern\": passed" success=0 ;; *) debugOut "checking: \"$vmVersion\" against \"$pattern\": failed (wrong type)" success=1 ;; esac else debugOut "checking: \"$vmVersion\" against \"$pattern\": failed (wrong version)" fi return $success } #--------------------------------------------------------------- writetab() { awk ' BEGIN { processingTag=0 } $0 == "/:" { if (beginprocessingTag == 1) beginprocessingTag=0 ; next } $0 == tag { beginprocessingTag=1; next } { if (beginprocessingTag == 1) { print $0 >> tab; next } } END { } ' tab="$2" tag="$3" "$1" } pbclr() { [ -z "$SILENT" ] && { awk ' END { printf("%c",13); printf("%s"," "); i=length(pbmesg); for (k=1 ; k <= i; k++ ) printf("%c",32); }' pbmesg="$pbmesg" /dev/null` if [ $alive != "0" ] ; then sleep 1 ctr=`expr $ctr + 1` else return fi done foo=`kill -9 $1 > /dev/null 2>&1` } VerifyJVM() { pbclr pbmesg="Verifying JVM" pb [ ! -f "$INSTALLER_DATA_DIR/jvmspecs/Verify.jar" ] awk ' BEGIN { begin=0; i=1 } $0 == "/:" { if (begin == 1) begin=0 ; next; } $0 == tag { begin=1; next; } { if (begin== 1) { item[i]=$0; i++; next; } } END { for (k=1; k < i; k++) print item[k] >> tab; } ' tab="$IATEMP/sp" tag="JVM_PROPERTIES:" "$1" 2>/dev/null if [ -f "$IATEMP/sp" ] ; then spc=`wc -l "$IATEMP/sp" | awk '{ print $1 }'` spcc=1 systemprops= while [ $spcc -le $spc ] ; do spl=`sed -n -e "${spcc}p" "$IATEMP/sp"` spl=`echo "$spl" | sed 's/\"//g'` systemprops=`awk 'END { i=index(spl,"="); s=substr(spl,1,i-1); ss=sprintf("%s %s", sp, s); print ss; } ' spl="$spl" sp="$systemprops" /dev/null` spcc=`expr $spcc + 1` done jvm_classpath= cp_switch=`awk 'BEGIN{ FS=":"} $1 == tag { print $2; exit; }' tag=CLASSPATH $1` cp_switch=`echo "$cp_switch" | sed 's/\"//g'` jvm_classpath=`awk 'BEGIN { FS=":" } $1 == tag { i=index($0,":"); s=substr($0,i+1); print s; exit; }' tag=JVM_CLASSPATH $1` debugOut "---" if [ -z "$jvm_classpath" ] ; then debugOut "Verifying1... $2 $cp_switch $INSTALLER_DATA_DIR/jvmspecs/Verify.jar Verify $systemprops" eval "\"$2\"" $cp_switch "$INSTALLER_DATA_DIR/jvmspecs/Verify.jar" Verify $systemprops 1>"$IATEMP/jvmout" 2>/dev/null& bgpid=$! Timer $bgpid& wait $bgpid 1>/dev/null 2>&1 else jb=`awk 'BEGIN { FS=":" } $1 == tag { i=index($0,":"); s=substr($0,i+1); print s; exit; }' tag=JVM_EXE $1 2>/dev/null` jb=`echo "$jb" | sed 's/^[ ]*//;s/[ ]*$//;s/^[ ]*//;s/[ ]*$//'` jb=`echo "$jb" | sed 's/\//\\\\\//g'` JVM_HOME=`echo "$2" | sed "s/${jb}//"` eval jvm_classpath="$jvm_classpath" debugOut "Verifying2... $2 $cp_switch $jvm_classpath:$INSTALLER_DATA_DIR/jvmspecs/Verify.jar Verify $systemprops" eval "\"$2\"" $cp_switch "$jvm_classpath":"$INSTALLER_DATA_DIR/jvmspecs/Verify.jar" Verify $systemprops 1>"$IATEMP/jvmout" 2>/dev/null& bgpid=$! Timer $bgpid& wait $bgpid 1>/dev/null 2>&1 JVM_HOME= fi if [ -f "$IATEMP/jvmout" ] ; then spc=`wc -l "$IATEMP/sp" | awk '{ print $1 }'` spcc=1 systemprops= while [ $spcc -le $spc ] ; do spl=`sed -n -e "${spcc}p" "$IATEMP/sp"` spl=`echo $spl | sed 's/\"//g'` jvmfilevalue=`awk 'END { i=index(spl,"="); s=substr(spl,i+1); print s } ' spl="$spl" sp="$systemprops" /dev/null` jvmoutc=`expr $spcc + 1` jvmout=`sed -n -e "${jvmoutc}p" "$IATEMP/jvmout"` var_verifyJVM=`awk ' END { exactMatch=1 var_verifyJVM=2 len = length(jvmfilevalue) for (k = len ; k >len-3 ; k--) { char=substr(jvmfilevalue, k, 1); s = sprintf("%s%s", s,char); } if (length(s) == length("...")) { if ( index(s, "...") == 1) { exactMatch=0 } } if (exactMatch == 1) { if ( (length(jvmfilevalue) == length(jvmout)) && (index(jvmfilevalue, jvmout) == 1) ) var_verifyJVM=0 } else { jvmfilevalue_prefix=substr(jvmfilevalue, 1, len-3) if (index(jvmout,jvmfilevalue_prefix) == 1 ) var_verifyJVM=0 } if (length(iaVV) > 0) { printf("jvm system property specified in jvm file=%s\n",jvmfilevalue) >> ilog printf("jvm system property from running Verify diagnostics on the JVM=%s\n",jvmout) >> ilog if (var_verifyJVM == 0) { if (exactMatch == 1) { print "exact match of system property succeeded" >> ilog } else { print "non-exact match of system property succeeded" >> ilog } } else { if (exactMatch == 1) { print "exact match of system property failed" >> ilog } else { print "non-exact match of system property failed" >> ilog } } } print var_verifyJVM } ' jvmout="$jvmout" jvmfilevalue="$jvmfilevalue" iaVV="$iaVV" ilog="$LOG" /dev/null` if [ "$var_verifyJVM" != "0" ] ; then break fi spcc=`expr $spcc + 1` done else debugOut "$IATEMP/jvmout does not exist. JVM Verification process may have failed." fi else debugOut "system properties are not specified in "$1"" fi rm -f "$IATEMP/sp" rm -f "$IATEMP/jvmout" } preparePlatformHintFile() { JVM_FILE=$1 while read fileLine do eachLine=`echo $fileLine` if [ "$eachLine" = "PLATFORM_HINT:" ] ; then flag=0 fi if [ "$flag" = 0 ] ; then echo $eachLine >> $PLATFORM_HINT_FILE fi if [ "$eachLine" = "/:" ] ; then flag=1 fi done < $JVM_FILE #sed -i 's/^PLATFORM_HINT://' $PLATFORM_HINT_FILE sed 's/^PLATFORM_HINT://' $PLATFORM_HINT_FILE > $PLATFORM_HINT_FILE.tmp mv $PLATFORM_HINT_FILE.tmp $PLATFORM_HINT_FILE #sed -i 's/^\/://' $PLATFORM_HINT_FILE sed 's/^\/://' $PLATFORM_HINT_FILE > $PLATFORM_HINT_FILE.tmp mv $PLATFORM_HINT_FILE.tmp $PLATFORM_HINT_FILE } searchPlatformHints() { debugOut "Checking the environment variables specifed in the JVM spec files to find the JVM..." DOT_JVM_FILE=$1 preparePlatformHintFile "$DOT_JVM_FILE" if [ ! -f /tmp/tmpActvmFile ] ; then touch /tmp/tmpActvmFile fi envVarValue="" while read fileLine do eachLine=`echo $fileLine` if [ ! -z "$eachLine" ] ; then envVarValue=`env | grep -w $eachLine | cut -d "=" -f2` if [ -x $envVarValue/$JVM_EXE ] ; then VerifyJVM "$DOT_JVM_FILE" "$envVarValue/$JVM_EXE" if [ "$var_verifyJVM" = "0" ] ; then actvm="$envVarValue/$JVM_EXE" echo $actvm > /tmp/tmpActvmFile var_searchAndverify=0 var_searchAndverifyJvm=0 debugOut "Verification passed for $envVarValue/$JVM_EXE using JVM file $DOT_JVM_FILE using PLATFORM_HINT section" break else var_searchAndverifyJvm=2 debugOut "Verification failed for $envVarValue/$JVM_EXE using JVM file $DOT_JVM_FILE using PLATFORM_HINT section" fi elif [ -x $envVarValue/jre/$JVM_EXE ] ; then VerifyJVM "$DOT_JVM_FILE" "$envVarValue/jre/$JVM_EXE" if [ "$var_verifyJVM" = "0" ] ; then actvm="$envVarValue/jre/$JVM_EXE" echo $actvm > /tmp/tmpActvmFile var_searchAndverify=0 var_searchAndverifyJvm=0 debugOut "Verification passed for $envVarValue/jre/$JVM_EXE using JVM file $DOT_JVM_FILE using PLATFORM_HINT section" break else var_searchAndverifyJvm=2 debugOut "Verification failed for $envVarValue/jre/$JVM_EXE using JVM file $DOT_JVM_FILE using PLATFORM_HINT section" fi fi fi done < $PLATFORM_HINT_FILE actvm=`cat /tmp/tmpActvmFile` if [ -f /tmp/tmpActvmFile ] ; then rm -rf /tmp/tmpActvmFile fi if [ -f "$PLATFORM_HINT_FILE" ] ; then rm -f $PLATFORM_HINT_FILE fi } searchPathHints() { writetab "$1" "$IATEMP/pathHint" "PATH_HINT:" installerPath= if [ -f "$IATEMP/pathHint" ] ; then debugOut "using path hints in the JVM file $1" pathHintc=`wc -l "$IATEMP/pathHint" | awk '{ print $1 }'` pathHintcc=1 while [ $pathHintcc -le $pathHintc ] ; do pbc=`expr $pbc + 1` pb PathHint=`sed -n -e "${pathHintcc}p;s/^[ ]*//;s/[ ]*$//" "$IATEMP/pathHint"` pathSep=`echo $PathHint | grep "^/" | wc -l` char='.' count=0 i=1 #if [[ "$PathHint" =~ "../" ]]; then case "$PathHint" in *../*) seaLocPath=$lax_user_dir/sea_loc while IFS='|' read -r LINE do installerPath=$LINE break done < $seaLocPath len=`expr length $PathHint` pathLength=`expr $len + 1` while [ $i -le $len ] do cchar=`expr substr $PathHint $i 1` if [ $char = $cchar ] then count=`expr $count + 1 ` fi i=`expr $i + 1` done if [ $count -gt 0 ] then newcount=`expr $count / 2` mat='../' res=${PathHint//$mat} j=0 while [ $newcount -gt $j ] do val="/*" installerPath=${installerPath%$val} newcount=`expr $newcount - 1` done fi if [ $count -gt $j ] then PathHint="$installerPath/$res" fi ;; esac #fi IS_RELATIVE=0 if [ -f "$1.fr" ] ; then rm -f "$1.fr" fi debugOut "Checking whether the passed pathhint is a directory" if [ -d "$PathHint" ] ; then for x in $PathHint ; do if [ -x "$x/$JVM_EXE" ] ; then echo "$x/$JVM_EXE" >> "$1.fr.shellxpansion" else var_searchAndverifyJvm=2 fi if [ -x "$x/jre/$JVM_EXE" ] ; then echo "$x/jre/$JVM_EXE" >> "$1.fr.shellxpansion" else var_searchAndverifyJvm=2 fi done fi find $PathHint/$JVM_EXE > "$1.fr.findcommand" 2>/dev/null if [ $? -eq 0 ] ; then if [ -f "$1.fr.findcommand" ] ; then frc=`wc -l "$1.fr.findcommand" | awk '{ print $1 }'` frcc=1 while [ $frcc -le $frc ] ; do frl=`sed -n -e "${frcc}p" "$1.fr.findcommand"` grep "$frl" "$1.fr.shellxpansion" 1>/dev/null 2>&1 if [ $? -ne 0 ] ; then echo "$frl" >> "$1.fr.shellxpansion" fi frcc=`expr $frcc + 1` done fi else var_searchAndverifyJvm=2 fi if [ -f "$1.fr.findcommand" ] ; then rm -f "$1.fr.findcommand" fi if [ -f "$1.fr.shellxpansion" ] ; then mv "$1.fr.shellxpansion" "$1.fr" rm -f "$1.fr.shellxpansion" fi if [ -f "$1.fr" ] ; then frc=`wc -l "$1.fr" | awk '{ print $1 }'` frcc=1 while [ $frcc -le $frc ] ; do frl=`sed -n -e "${frcc}p" "$1.fr"` jvm_exe=`echo $JVM_EXE | sed 's/\//\\\\\//g'` # $1 is the *.jvm file and $frl is the resolved jvm path from the path hint taken one at a time for e.g. # params to verify jvmspecs/ibm_aix_15x.jvm /usr/java14/bin/java # params to verify jvmspecs/ibm_aix_15x.jvm /usr/java14/jre/bin/java VerifyJVM "$1" "$frl" debugOut " === verify=$var_verifyJVM" if [ "$var_verifyJVM" = "0" ] ; then debugOut " &&& $1" J=`echo "$frl" | sed "s/${jvm_exe}//"` J=`echo "$J" | sed 's/^[ ]*//;s/[ ]*$//;s/^[ ]*//;s/[ ]*$//'` echo "JVM_HOME:$J" >> "$1" RESOLVED_JVM="$1" actvm="$J"/bin/java if [ $IS_RELATIVE -eq 1 ] ; then IS_JVM_TEMP=1 DESTINATION_DIR=$MEDIA_DIR fi var_searchAndverify=0 var_searchAndverifyJvm=0 debugOut "Verification passed for $frl using the JVM file $1." rm -f "$1.fr" return else var_searchAndverifyJvm=2 debugOut "Verification failed for $frl using the JVM file $1." fi frcc=`expr $frcc + 1` done else debugOut "find result is empty for the pathhint=$PathHint" fi pathHintcc=`expr $pathHintcc + 1` done fi } #function to search and verify a valid JVM as specified in the .jvm file searchAndVerifyJVM() { debugOut "Searching for a JVM using $1 If found, will verify" if [ -f "$IATEMP/pathHint" ] ; then rm -f "$IATEMP/pathHint" fi JVM_EXE=`awk ' BEGIN { FS=":" } /^JVM_EXE/ { print $2; exit }' "$1" 2>/dev/null` JVM_EXE=`echo "$JVM_EXE" | sed 's/^[ ]*//;s/[ ]*$//;s/^[ ]*//;s/[ ]*$//;s/\"//g'` if [ -z "$JVM_EXE" ] ; then return else var_searchAndverifyJvm=0 fi #Search using PLATFORM_HINT section in the spec file searchPlatformHints $1 #Search using PATH_HINT section in the spec file only if PLATFORM_HINT search doesn't yield any result if [ -z "$actvm" ] ; then debugOut "PLATFORM_HINT did not find any suitable JVM. Searching for JVM using PATH_HINT section" searchPathHints $1 fi } func_ourJVMSearch() { jvmSpecBuildJvmSpecTotalNum=$1 jvmSpecPropFilePath=$2 idx=0 while [ $idx -lt $jvmSpecBuildJvmSpecTotalNum ] ; do jvmSpecFile_1=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.jvmspec.$idx=" | cut -d "=" -f2` jvmSpecFile=$INSTALLER_DATA_DIR/jvmspecs/$jvmSpecFile_1 dotJvmFile=`echo $jvmSpecFile | $TR -cd "[:print:]"` if [ -f "$dotJvmFile" ] ; then debugOut "JVM Spec file found!!" searchAndVerifyJVM "$dotJvmFile" if [ $var_searchAndverifyJvm -eq 0 ]; then debugOut "jvm found and verification passed for $dotJvmFile." break fi else debugOut "JVM Spec file not found!!" fi idx=`expr $idx + 1` done if [ -f "$IATEMP/pathHint" ] ; then rm -f "$IATEMP/pathHint" fi } func_existingJVMSearch() { debugOut "Searching without JVM specs" abs_lax_nl_current_vm=$1 inspectedVMtype=$2 inspectedOldVMtype=$3 VM_SEARCH_PATH=$4 IFS=$5 inspectedVMpath=$6 inspectedVMVersion=$7 validVMtypeList=$8 # 1st inspect the lax.nl.current.vm. As long as it is in the # valid vm list it takes precedence over everything else. laxVMisValid="false" # is the lax current vm is specifies if [ ! -z "$abs_lax_nl_current_vm" -a -x "$abs_lax_nl_current_vm" ]; then # inspect it inspectVM "$abs_lax_nl_current_vm" eval laxVMtype="$inspectedVMtype" eval laxOldVMType="$inspectedOldVMtype" # when VM is specified using the lax.nl.current.vm property or the # LAX_VM command-line option, just accept that VM, no validation is required laxVMisValid="true" fi # if the lax current vm is valid use it if [ "$laxVMisValid" = "true" ]; then # dont overwrite the lax.nl.current.vm if this one works just fine actvm="$abs_lax_nl_current_vm" actvmType="$laxVMtype" debugOut "* Using VM.....(lax.nl.current.vm)...... $actvm" else # other wise search the path debugOut "WARNING! No valid lax.nl.current.vm available." # sift through the path to look for VMs # unique the PATH to limit the amount of work; see bug #6285. debugOut "$VM_SEARCH_PATH" uniquedPath=`echo $VM_SEARCH_PATH | $TR ':' '\012'` vmNumber=0; OFS="$IFS" IFS=":" set x $uniquedPath; shift IFS="$OFS" debugOut "Searching for VMs in PATH:" for pathDir in $*; do debugOut "Looking in:............................. $pathDir" # For each type of binary vm name for binaryName in java jre oldjava; do vmPath="$pathDir/$binaryName" # if the binary exists, is executable and is not a directory... if [ -x "$vmPath" -a \( ! -d "$vmPath" \) ]; then debugOut " Found VM:............................. $vmPath" inspectVM "$vmPath" # set up a Bourne-style array of VM props using var1, var2, etc... eval vmBinary$vmNumber="$inspectedVMpath" eval vmType$vmNumber="$inspectedVMtype" eval oldVMtype$vmNumber="$inspectedOldVMtype" eval vmVersion$vmNumber="$inspectedVMVersion" vmNumber=`expr ${vmNumber:-0} + 1` debugOut " Version:............................. $inspectedVMVersion" fi done done ######################################### # VERIFY VMS against valid types # actvmType="" vmHighNumber="$vmNumber" # for each type of valid VM for validType in $validVMtypeList; do vmNumber="0"; # run through the list of VMs found while [ "$vmNumber" -lt $vmHighNumber ]; do eval type="$"vmType$vmNumber"" eval oldType="$"oldVMtype$vmNumber"" eval bin="$"vmBinary$vmNumber"" eval version="$"vmVersion$vmNumber"" # if the type of this VM is of '$type' or '$oldType' # make it the actual vm (actvm) to use case "${type} ${oldType}" in *${validType}*) actvm="$bin" actvmType="$type" debugOut "* Using VM:............................. $actvm" break 2 ;; esac if strictCheck "$version" "$validType" "$type"; then actvm="$bin" actvmType="$type" debugOut "* Using VM:............................. $actvm" break 2 fi vmNumber=`expr ${vmNumber:-0} + 1` done done fi } func_existingJVMSearch_WithVMNoSpecFile() { debugOut "Searching without JVM specs for With VM; if not found, use bundled VM" abs_lax_nl_current_vm=$1 inspectedVMtype=$2 inspectedOldVMtype=$3 VM_SEARCH_PATH=$4 IFS=$5 inspectedVMpath=$6 inspectedVMVersion=$7 validVMtypeList=$8 # other wise search the path debugOut "WARNING! No valid lax.nl.current.vm available." # sift through the path to look for VMs # unique the PATH to limit the amount of work; see bug #6285. debugOut "$VM_SEARCH_PATH" uniquedPath=`echo $VM_SEARCH_PATH | $TR ':' '\012'` vmNumber=0; OFS="$IFS" IFS=":" set x $uniquedPath; shift IFS="$OFS" debugOut "Searching for VMs in PATH:" for pathDir in $*; do debugOut "Looking in:............................. $pathDir" # For each type of binary vm name for binaryName in java jre oldjava; do vmPath="$pathDir/$binaryName" # if the binary exists, is executable and is not a directory... if [ -x "$vmPath" -a \( ! -d "$vmPath" \) ]; then debugOut " Found VM:............................. $vmPath" inspectVM "$vmPath" # set up a Bourne-style array of VM props using var1, var2, etc... eval vmBinary$vmNumber="$inspectedVMpath" eval vmType$vmNumber="$inspectedVMtype" eval oldVMtype$vmNumber="$inspectedOldVMtype" eval vmVersion$vmNumber="$inspectedVMVersion" vmNumber=`expr ${vmNumber:-0} + 1` debugOut " Version:............................. $inspectedVMVersion" fi done done ######################################### # VERIFY VMS against valid types # actvmType="" vmHighNumber="$vmNumber" # for each type of valid VM for validType in $validVMtypeList; do vmNumber="0"; # run through the list of VMs found while [ "$vmNumber" -lt $vmHighNumber ]; do eval type="$"vmType$vmNumber"" eval oldType="$"oldVMtype$vmNumber"" eval bin="$"vmBinary$vmNumber"" eval version="$"vmVersion$vmNumber"" # if the type of this VM is of '$type' or '$oldType' # make it the actual vm (actvm) to use case "${type} ${oldType}" in *${validType}*) actvm="$bin" actvmType="$type" debugOut "* Using VM:............................. $actvm" break 2 ;; esac if strictCheck "$version" "$validType" "$type"; then actvm="$bin" actvmType="$type" debugOut "* Using VM:............................. $actvm" break 2 fi vmNumber=`expr ${vmNumber:-0} + 1` done done } func_extract_vm_pack() { RESOURCE_PATH="$ZIPLOC/$RESOURCE_DIR/resource" JRE_TARZ="$RESOURCE_PATH/vm.tar.Z" JRE_TAR="$RESOURCE_PATH/vm.tar" # save the old directory and switch into the temp directory sePwd=`pwd` cd "$ZIPLOC" # make the platform directory and switch into it mkdir "$RESOURCE_DIR" cd "$RESOURCE_DIR" # make the resource directory mkdir resource # switch back to the previous directory cd "$sePwd" # Extract the .vm file TAR_CMD="" GZIP_CMD="" UNZIP_CMD="" if [ -x /usr/bin/tar ] ; then TAR_CMD="/usr/bin/tar" elif [ -x /bin/tar ] ; then TAR_CMD="/bin/tar" elif [ -x /usr/sbin/tar] ; then TAR_CMD="/usr/sbin/tar" else TAR_CMD="tar" fi if [ -x /bin/gzip ] ; then GZIP_CMD="/bin/gzip" elif [ -x /usr/bin/gzip ] ; then GZIP_CMD="/usr/bin/gzip" elif [ -x /usr/sbin/gzip ] ; then GZIP_CMD="/usr/sbin/gzip" else GZIP_CMD="gzip" fi if [ -x /usr/bin/unzip ] ; then UNZIP_CMD="/usr/bin/unzip" elif [ -x /usr/sbin/unzip ] ; then UNZIP_CMD="/usr/sbin/unzip" elif [ -x /usr/local/bin/unzip ] ; then UNZIP_CMD="/usr/local/bin/unzip" else UNZIP_CMD="unzip" fi unzip_verify=`$UNZIP_CMD` if [ -z "$unzip_verify" ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then INVALIDUNZIP=`getLocalizedString invalidUnzip` printLocalizedString "$INVALIDUNZIP" "Invalid unzip command found" else debugOut "Invalid unzip command found. Exiting..." fi fi cd "$RESOURCE_PATH" unzip_success=`$UNZIP_CMD $1` R_unzip=$? if [ $R_unzip -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "Unzipping of VM pack $1 failed" fi exit $R_unzip else debugOut "Unzip done" fi gzip_sucess=`$GZIP_CMD -d $JRE_TARZ` R_gzip=$? if [ $R_gzip -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "Gzip failed" fi exit $R_gzip else debugOut "Gzip done" fi untar_success=`$TAR_CMD xf $JRE_TAR` R_untar=$? if [ $R_untar -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "TAR failed" echo "The included VM could not be unarchived (TAR). Please try to download" echo "the installer again and make sure that you download using 'binary'" echo "mode. Please do not attempt to install this currently downloaded copy." fi exit 15 else debugOut "TAR done" fi chmod -R 755 jre > /dev/null 2>&1 javaDir=$RESOURCE_PATH/jre/bin/java javaDir_Special=$RESOURCE_PATH/jre/jre/bin/java if [ -f "$javaDir" ] ; then actvm=$javaDir elif [ -f "$javaDir_Special" ] ; then actvm=$javaDir_Special fi cd "$sePwd" if [ $R_unzip -eq 0 -a $R_gzip -eq 0 -a $R_untar -eq 0 ] ; then debugOut "Extracted the JVM pack $1 successfully!!" fi } func_download_vm_pack() { R_wget= if [ -z "$1" ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "Download URL empty. Returning...." fi return fi if [ -x /usr/bin/wget ] ; then WGET_CMD="/usr/bin/wget" elif [ -x /usr/sbin/wget ] ; then WGET_CMD="/usr/sbin/wget" elif [ -x /usr/local/bin/wget ] ; then WGET_CMD="/usr/local/bin/wget" else WGET_CMD="wget" fi wget_success= if [ ! -z "$WGET_CMD" ] ; then if [ ! -z "$uimode" -a "$uimode" = "silent" ] ; then wget_success=`$WGET_CMD --tries=3 --output-file="$IATEMP/downloadLog" --directory-prefix="$INSTALLER_DATA_DIR" "$1"` else wget_success=`$WGET_CMD --tries=3 --directory-prefix="$INSTALLER_DATA_DIR" "$1"` fi R_wget=$? if [ $R_wget -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "Download of VM pack failed" fi #exit $R_wget else debugOut "Download of VM pack succeded" fi fi return $R_wget } func_md5Verification() { R_md5= #find the location of md5sum tool on the UNIX machine MD5SUM_CMD="" if [ -x /usr/bin/md5sum ] ; then MD5SUM_CMD="/usr/bin/md5sum" elif [ -x /usr/sbin/md5sum ] ; then MD5SUM_CMD="usr/sbin/md5sum" elif [ -x /usr/local/bin/md5sum ] ; then MD5SUM_CMD="/usr/local/bin/md5sum" else MD5SUM_CMD="md5sum" fi jvmSpecBuildWithoutVMDownloadUrl=$1 jvmSpecBuildWithoutVMMD5ChecksumValue=$2 debugOut "Verifying the downloaded JVM with MD5 checksum specified" downloadedJVMURL=`basename $jvmSpecBuildWithoutVMDownloadUrl` downloadedJVM=$INSTALLER_DATA_DIR/$downloadedJVMURL md5_var=`$MD5SUM_CMD $downloadedJVM` if [ ! -z "$md5_var" ] ;then md5_checksum_value=`echo $md5_var | awk '{print $1}'` if [ ! -z "$md5_checksum_value" ] ; then if [ "$md5_checksum_value" = "$jvmSpecBuildWithoutVMMD5ChecksumValue" ] ; then R_md5=0 else R_md5=1 fi fi else if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then echo "Warning!! Error in executing md5sum command on the downloaded JVM." echo "Check if md5sum tool is available on your machine or if you have the required permissions to execute md5sum command" fi R_md5=1 fi return $R_md5 } # #-------------------------------------------------------------- # if a VM was forced on the command line use it otherwise search if [ "$lax_vm" = "LAX_VM" ]; then # Using VM passed in as argument debugOut "JVM specified using LAX_VM" inspectVM "$lax_vm_value" actvmType="$inspectedVMtype" actvm="$lax_vm_value" debugOut "* Using VM:.........(LAX_VM)............ $actvm" else #try to unzip the installer.zip to extract *.jvm and jvmspecs.properties files to the tmp directory if [ $IS_INSTALLER ] ; then if [ -x /usr/bin/unzip ] ; then UNZIP_CMD="/usr/bin/unzip" elif [ -x /usr/sbin/unzip ] ; then UNZIP_CMD="/usr/sbin/unzip" elif [ -x /usr/local/bin/unzip ] ; then UNZIP_CMD="/usr/local/bin/unzip" else UNZIP_CMD="unzip" fi unzip_verify=`$UNZIP_CMD >/dev/null 2>&1` I_unzip=$? if [ $I_unzip -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then INSTALLINVALIDUNZIP=`getLocalizedString installInvalidUnzip` debugOut "$INSTALLINVALIDUNZIP" "InstallAnywhere could not find a supported unzip program on the system, this should not have any impact on the installation process" else debugOut "Invalid unzip command found. Exiting..." fi fi unzip_success=`$UNZIP_CMD -d $INSTALLER_DATA_DIR $INSTALL_ZIP jvmspecs* > /dev/null 2>&1` R_unzip=$? if [ $R_unzip -ne 0 ] ; then debugOut "Unzipping of installer.zip failed." debugOut "Using the Default JVM Search" func_existingJVMSearch "$abs_lax_nl_current_vm" "$inspectedVMtype" "$inspectedOldVMtype" "$VM_SEARCH_PATH" "$IFS" "$inspectedVMpath" "$inspectedVMVersion" "$validVMtypeList" else if [ -f "$INSTALLER_DATA_DIR/jvmspecs/jvmspecs.properties" ] ; then debugOut "Found jvmspecs.properties" jvmSpecPropFilePath=$INSTALLER_DATA_DIR/jvmspecs/jvmspecs.properties jvmSpecBuildWithoutVM=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm=" | cut -d "=" -f2` jvmSpecBuildOption=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.option=" | cut -d "=" -f2` jvmSpecBuildWithVM=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.with.vm=" | cut -d "=" -f2` jvmSpecBuildWithVMSearchOption=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.with.vm.search.option=" | cut -d "=" -f2` jvmSpecBuildWithoutVMNotFoundDownloadUrl=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.not.found.download.url=" | cut -d "=" -f2` jvmSpecBuildJvmSpecTotalNum=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.jvmspec.total.num=" | cut -d "=" -f2` jvmSpecBuildJvmSpecApplicable=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.jvmspec.applicable=" | cut -d "=" -f2` jvmSpecBuildWithoutVmSearchOption=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.search.option=" | cut -d "=" -f2` jvmSpecBuildWithoutVmDirectDownloadUrl=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.direct.download.url=" | cut -d "=" -f2` jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumApplicable=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.not.found.download.url.md5Checksum.applicable=" | cut -d "=" -f2` jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumValue=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.not.found.download.url.md5Checksum.value=" | cut -d "=" -f2` jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumApplicable=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.dont.search.download.url.md5Checksum.applicable=" | cut -d "=" -f2` jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumValue=`sed '/^#/d' $jvmSpecPropFilePath | grep "build.without.vm.dont.search.download.url.md5Checksum.value=" | cut -d "=" -f2` if [ ! -z "$jvmSpecBuildOption" ] ; then if [ $jvmSpecBuildOption = "withvm" ] ; then if [ ! -z "$jvmSpecBuildWithVMSearchOption" ] ; then case $jvmSpecBuildWithVMSearchOption in 20) #20 = WITH_VM_SEARCH_FOR_VM_IF_NOT_FOUND_USE_BUNDLED if [ ! -z "$jvmSpecBuildJvmSpecTotalNum" ]; then if [ $jvmSpecBuildJvmSpecTotalNum -gt 0 ]; then func_ourJVMSearch "$jvmSpecBuildJvmSpecTotalNum" "$jvmSpecPropFilePath" fi else debugOut "Searching without JVM specs" func_existingJVMSearch_WithVMNoSpecFile "$abs_lax_nl_current_vm" "$inspectedVMtype" "$inspectedOldVMtype" "$VM_SEARCH_PATH" "$IFS" "$inspectedVMpath" "$inspectedVMVersion" "$validVMtypeList" fi if [ -z "$actvm" ] ; then debugOut "JVM not found with or without spec file. Using bundled JVM" if [ -f "$ZIPLOC/$RESOURCE_DIR/resource/jre/bin/java" ] ; then actvm="$ZIPLOC/$RESOURCE_DIR/resource/jre/bin/java" elif [ -f "$ZIPLOC/$RESOURCE_DIR/resource/jre/jre/bin/java" ] ; then actvm="$ZIPLOC/$RESOURCE_DIR/resource/jre/jre/bin/java" fi fi ;; 21) #21 = WITH_VM_DONT_SEARCH_USE_BUNDLED if [ -f "$ZIPLOC/$RESOURCE_DIR/resource/jre/bin/java" ] ; then actvm="$ZIPLOC/$RESOURCE_DIR/resource/jre/bin/java" elif [ -f "$ZIPLOC/$RESOURCE_DIR/resource/jre/jre/bin/java" ] ; then actvm="$ZIPLOC/$RESOURCE_DIR/resource/jre/jre/bin/java" fi ;; *) DEFAULT=`getLocalizedString default` printLocalizedString "$DEFAULT" "default" ;; esac fi elif [ $jvmSpecBuildOption = "withoutvm" ] ; then debugOut "JVM Spec Build Option Specified Without VM" if [ ! -z "$jvmSpecBuildWithoutVmSearchOption" ] ; then case $jvmSpecBuildWithoutVmSearchOption in 10) if [ ! -z "$jvmSpecBuildJvmSpecTotalNum" ]; then if [ $jvmSpecBuildJvmSpecTotalNum -gt 0 ]; then func_ourJVMSearch "$jvmSpecBuildJvmSpecTotalNum" "$jvmSpecPropFilePath" fi else debugOut "Searching without JVM specs" func_existingJVMSearch "$abs_lax_nl_current_vm" "$inspectedVMtype" "$inspectedOldVMtype" "$VM_SEARCH_PATH" "$IFS" "$inspectedVMpath" "$inspectedVMVersion" "$validVMtypeList" fi ;; 11) if [ ! -z "$jvmSpecBuildJvmSpecTotalNum" ]; then if [ $jvmSpecBuildJvmSpecTotalNum -gt 0 ]; then func_ourJVMSearch "$jvmSpecBuildJvmSpecTotalNum" "$jvmSpecPropFilePath" fi else debugOut "Searching without JVM specs" func_existingJVMSearch "$abs_lax_nl_current_vm" "$inspectedVMtype" "$inspectedOldVMtype" "$VM_SEARCH_PATH" "$IFS" "$inspectedVMpath" "$inspectedVMVersion" "$validVMtypeList" fi if [ -z "$actvm" ] ; then func_download_vm_pack "$jvmSpecBuildWithoutVMNotFoundDownloadUrl" R_download_status=$? if [ $R_download_status -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then VMDOWNLOADERROR=`getLocalizedString vmDownloadError` printLocalizedString "$VMDOWNLOADERROR" "Error in downloading the VM. Installer exiting..." fi else if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then DOWNLOADEDVM1=`getLocalizedString downloadedVM1` printLocalizedString "$DOWNLOADEDVM1" "Downloaded VM Pack using URL=$jvmSpecBuildWithoutVMNotFoundDownloadUrl" fi jreDownloadFile=`basename $jvmSpecBuildWithoutVMNotFoundDownloadUrl` jreDownloadFileName=$INSTALLER_DATA_DIR/$jreDownloadFile if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then DOWNLOADLOC1=`getLocalizedString downloadLoc1` printLocalizedString "$DOWNLOADLOC1" "Download location=$jreDownloadFileName" fi if [ ! -z "$jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumApplicable" -a "$jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumApplicable" = "true" ] ; then if [ ! -z "$jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumValue" ] ; then func_md5Verification "$jvmSpecBuildWithoutVMNotFoundDownloadUrl" "$jvmSpecBuildWithoutVMsearchFailDownloadMD5ChecksumValue" R_md5Verification_1=$? if [ $R_md5Verification_1 -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then CHECKSUMFAILED=`getLocalizedString checksumFailed` printLocalizedString "$CHECKSUMFAILED" "Error!! MD5 checksum verification for downloaded JVM failed. Installer exiting..." fi else if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then CHECKSUMPASSED=`getLocalizedString checksumPassed` printLocalizedString "$CHECKSUMPASSED" "MD5 checksum verification for downloaded JVM passed" fi func_extract_vm_pack "$jreDownloadFileName" fi fi else func_extract_vm_pack "$jreDownloadFileName" fi fi fi ;; 12) func_download_vm_pack "$jvmSpecBuildWithoutVmDirectDownloadUrl" #12 = WITHOUT_VM_DO_NOT_SEARCH_DOWNLOAD R_download_status=$? if [ $R_download_status -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then VMDOWNLOADERROR=`getLocalizedString vmDownloadError` printLocalizedString "$VMDOWNLOADERROR" "Error in downloading the VM. Installer exiting..." fi else if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then DOWNLOADEDVM2=`getLocalizedString downloadedVM2` printLocalizedString "$DOWNLOADEDVM2" "Downloaded VM Pack using URL=$jvmSpecBuildWithoutVmDirectDownloadUrl" fi jreDownloadFile_1=`basename $jvmSpecBuildWithoutVmDirectDownloadUrl` jreDownloadFileName_1=$INSTALLER_DATA_DIR/$jreDownloadFile_1 if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then DOWNLOADLOC2=`getLocalizedString downloadLoc2` printLocalizedString "$DOWNLOADLOC2" "Download location=$jreDownloadFileName_1" fi if [ ! -z "$jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumApplicable" -a "$jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumApplicable" = "true" ] ; then if [ ! -z "$jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumValue" ] ; then func_md5Verification "$jvmSpecBuildWithoutVmDirectDownloadUrl" "$jvmSpecBuildWithoutVMDirectDownloadMD5ChecksumValue" R_md5Verification_2=$? if [ $R_md5Verification_2 -ne 0 ] ; then if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then CHECKSUMFAILED=`getLocalizedString checksumFailed` printLocalizedString "$CHECKSUMFAILED" "Error!! MD5 checksum verification for downloaded JVM failed. Installer exiting..." fi else if [ ! -z "$uimode" -a "$uimode" != "silent" ] ; then CHECKSUMPASSED=`getLocalizedString checksumPassed` printLocalizedString "$CHECKSUMPASSED" "MD5 checksum verification for downloaded JVM passed" fi func_extract_vm_pack "$jreDownloadFileName_1" fi fi else func_extract_vm_pack "$jreDownloadFileName_1" fi fi ;; *) DEFCASE=`getLocalizedString defaultCase` printLocalizedString "$DEFCASE" "default case" ;; esac fi fi fi else debugOut "Could not detect JVM Search Policy. Exiting..." exit; fi fi else func_existingJVMSearch "$abs_lax_nl_current_vm" "$inspectedVMtype" "$inspectedOldVMtype" "$VM_SEARCH_PATH" "$IFS" "$inspectedVMpath" "$inspectedVMVersion" "$validVMtypeList" fi #============================================================================================= fi # If no VMs are found in path if [ -z "$actvm" ] then echo "No Java virtual machine could be found from your PATH" echo "environment variable. You must install a VM prior to" echo "running this program." # Mikey [5/16/2000] -- If this was SEA'd then remove the temp directory if [ "$IS_INSTALLER" = "true" ]; then debugOut "Removing temporary installation directory: \"$lax_user_dir\"" rm -rf "$lax_user_dir" fi cd "$olddir" exit fi # write the current vm out to the environment properties echo "lax.nl.current.vm=$actvm" >> $envPropertiesFile # set up a variable to esilty know if we are going to run 1.1 or 1.2 # for setting up VM cmd line options later on case "$actvmType" in "JRE" | "JDK" | "JRE_J1" | "JDK_J1" ) actvmVersion="1.1" ;; "R12" | "D12" | "JDK_J2" | "JRE_J2" | "OLDJAVA") actvmVersion="1.2" ;; *) actvmVersion="" ;; esac # # end of finding VMs ########################################################################################## #################################################################################### # Determining VM invocation options to use # # # Verification # if [ "$actvmVersion" = "1.1" ]; then if [ "$verify" = "off" ]; then options="$options -noverify" else if [ "$verify_mode" = "remote" ]; then options="$options -verifyremote" elif [ "$verify_mode" = "none" ]; then options="$options -noverify" elif [ "$verify_mode" = "all" ]; then options="$options -verify" fi fi fi verbo=${verbo:="none"} if [ $verbo = "normal" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -verbose" elif [ "$actvmVersion" = "1.2" ]; then options="$options -verbose:class" fi elif [ $verbo = "all" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -verbose -verbosegc" elif [ "$actvmVersion" = "1.2" ]; then options="$options -verbose:class -verbose:gc" fi elif [ $verbo = "gc" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -verbosegc" elif [ "$actvmVersion" = "1.2" ]; then options="$options -verbose:gc" fi fi # # Memory mgnt # gcxtnt=${gcxtnt:="none"} if [ $gcxtnt = "min" ] then if [ "$actvmVersion" = "1.1" ]; then options="$options -noclassgc" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xnoclassgc" fi fi gcthrd=${gcthrd:="none"} if [ "$actvmVersion" = "1.1" ]; then if [ $gcthrd = "off" ] then options="$options -noasyncgc" fi fi nsmax=${nsmax:="none"} if [ "$nsmax" != "none" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -ss$nsmax" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xss$nsmax" fi fi jsmax=${jsmax:="none"} if [ "$jsmax" != "none" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -oss$jsmax" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xoss$jsmax" fi fi jhmax=${jhmax:="none"} if [ "$jhmax" != "none" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -mx$jhmax" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xmx$jhmax" else # Note that the above conditions are always false in case of SFX. # Adding else statement to add Java Maximum Heap size to JVM options argument. options="$options -Xmx$jhmax" fi fi jhinit=${jhinit:="none"} if [ "$jhinit" != "none" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -ms$jhinit" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xms$jhinit" else # Note that the above conditions are always false in case of SFX. # Adding else statement to add Java Initial Heap size to JVM options argument. options="$options -Xms$jhinit" fi fi debug=${debug:-"off"} if [ $debug != "off" ]; then if [ "$actvmVersion" = "1.1" ]; then options="$options -debug" elif [ "$actvmVersion" = "1.2" ]; then options="$options -Xdebug" fi fi ############################################################### # JIT options # Resetting java home and JIT compiler environment variables # jitOnOrOff=on; # # turn off according to VM type # if [ ! -z "$lax_nl_osname_JDK_J1_java_compiler" -a "$actvmType" = "JDK_J1" ]; then jitOnOrOff=$lax_nl_osname_JDK_J1_java_compiler elif [ ! -z "$lax_nl_osname_JDK_J2_java_compiler" -a "$actvmType" = "JDK_J2" ]; then jitOnOrOff=$lax_nl_osname_JDK_J2_java_compiler elif [ ! -z "$lax_nl_osname_JRE_J1_java_compiler" -a "$actvmType" = "JRE_J1" ]; then jitOnOrOff=$lax_nl_osname_JRE_J1_java_compiler elif [ ! -z "$lax_nl_osname_JRE_J2_java_compiler" -a "$actvmType" = "JRE_J2" ]; then jitOnOrOff=$lax_nl_osname_JRE_J2_java_compiler elif [ ! -z "$lax_nl_osname_J1_java_compiler" -a "$actvmType" = "J1" ]; then jitOnOrOff=$lax_nl_osname_J1_java_compiler elif [ ! -z "$lax_nl_osname_J2_java_compiler" -a "$actvmType" = "J2" ]; then jitOnOrOff=$lax_nl_osname_J2_java_compiler elif [ ! -z "$lax_nl_osname_JRE_java_compiler" -a "$actvmType" = "JRE" ]; then jitOnOrOff=$lax_nl_osname_JRE_java_compiler elif [ ! -z "$lax_nl_osname_JDK_java_compiler" -a "$actvmType" = "JDK" ]; then jitOnOrOff=$lax_nl_osname_JDK_java_compiler elif [ ! -z "$lax_nl_osname_ALL_java_compiler" ]; then jitOnOrOff=$lax_nl_osname_ALL_java_compiler # elif [ ! -z "$lax_nl_unix_JDK_J1_java_compiler" -a "$actvmType" = "JDK_J1" ]; then jitOnOrOff=$lax_nl_unix_JDK_J1_java_compiler elif [ ! -z "$lax_nl_unix_JDK_J2_java_compiler" -a "$actvmType" = "JDK_J2" ]; then jitOnOrOff=$lax_nl_unix_JDK_J2_java_compiler elif [ ! -z "$lax_nl_unix_JRE_J1_java_compiler" -a "$actvmType" = "JRE_J1" ]; then jitOnOrOff=$lax_nl_unix_JRE_J1_java_compiler elif [ ! -z "$lax_nl_unix_JRE_J2_java_compiler" -a "$actvmType" = "JRE_J2" ]; then jitOnOrOff=$lax_nl_unix_JRE_J2_java_compiler elif [ ! -z "$lax_nl_unix_J1_java_compiler" -a "$actvmType" = "J1" ]; then jitOnOrOff=$lax_nl_unix_J1_java_compiler elif [ ! -z "$lax_nl_unix_J2_java_compiler" -a "$actvmType" = "J2" ]; then jitOnOrOff=$lax_nl_unix_J2_java_compiler elif [ ! -z "$lax_nl_unix_JRE_java_compiler" -a "$actvmType" = "JRE" ]; then jitOnOrOff=$lax_nl_unix_JRE_java_compiler elif [ ! -z "$lax_nl_unix_JDK_java_compiler" -a "$actvmType" = "JDK" ]; then jitOnOrOff=$lax_nl_unix_JDK_java_compiler elif [ ! -z "$lax_nl_unix_ALL_java_compiler" ]; then jitOnOrOff=$lax_nl_unix_ALL_java_compiler # elif [ ! -z "$lax_nl_JDK_J1_java_compiler" -a "$actvmType" = "JDK_J1" ]; then jitOnOrOff=$lax_nl_JDK_J1_java_compiler elif [ ! -z "$lax_nl_JDK_J2_java_compiler" -a "$actvmType" = "JDK_J2" ]; then jitOnOrOff=$lax_nl_JDK_J2_java_compiler elif [ ! -z "$lax_nl_JRE_J1_java_compiler" -a "$actvmType" = "JRE_J1" ]; then jitOnOrOff=$lax_nl_JRE_J1_java_compiler elif [ ! -z "$lax_nl_JRE_J2_java_compiler" -a "$actvmType" = "JRE_J2" ]; then jitOnOrOff=$lax_nl_JRE_J2_java_compiler elif [ ! -z "$lax_nl_J1_java_compiler" -a "$actvmType" = "J1" ]; then jitOnOrOff=$lax_nl_J1_java_compiler elif [ ! -z "$lax_nl_J2_java_compiler" -a "$actvmType" = "J2" ]; then jitOnOrOff=$lax_nl_J2_java_compiler elif [ ! -z "$lax_nl_JRE_java_compiler" -a "$actvmType" = "JRE" ]; then jitOnOrOff=$lax_nl_JRE_java_compiler elif [ ! -z "$lax_nl_JDK_java_compiler" -a "$actvmType" = "JDK" ]; then jitOnOrOff=$lax_nl_JDK_java_compiler elif [ ! -z "$lax_nl_ALL_java_compiler" ]; then jitOnOrOff=$lax_nl_ALL_java_compiler # elif [ ! -z "$lax_nl_osname_java_compiler" ]; then jitOnOrOff=$lax_nl_osname_java_compiler elif [ ! -z "$lax_nl_java_compiler" ]; then jitOnOrOff=$lax_nl_java_compiler else jitOnOrOff=on fi # JIT is ON by default, so we only need to change its status # the above else-if lists figures it should be OFF if [ "$jitOnOrOff" = "off" ]; then if [ "$actvmVersion" = "1.1" ]; then case "$osName" in *irix*) jitinvoc="-nojit" JIT_OPTIONS="-nojit" export JIT_OPTIONS ;; *hp-ux*|*hpux*) JIT_OPTIONS="-nojit" export JIT_OPTIONS jitinvoc="-nojit" ;; *solaris*|*sunos*) jitinvoc="-Djava.compiler=" ;; *aix*) JAVA_COMPILER=off export JAVA_COMPILER ;; *freebsd*) jitinvoc="-Djava.compiler=" ;; *linux*) jitinvoc="-Djava.compiler=" ;; *rhapsody*|*macos*) ;; *compaq*|*dg*|*osf*) jitinvoc="-nojit" ;; *) debugOut "Unknown OS name (\"$osName\"). Cannot set JIT Options." ;; esac elif [ "$actvmVersion" = "1.2" ]; then jitinvoc="-Djava.compiler=NONE" else debugOut "Unknown VM version. Cannot set JIT Options." fi fi options="$jitinvoc $options" # set this variable to something so we're guaranteed a value linux_LD_ASSUME_KERNEL_hack=0; # work around problem on RedHat Linux 7.1 IA-32 # see Bug Id 4447270 at Sun JDC bug parade if [ `cat /etc/redhat-release 2>/dev/null | grep "7\.1" | wc -l` = "1" ]; then if [ `uname -s` = "Linux" ]; then if [ `uname -m` != "ia64" ]; then case `uname -r` in 2.[456]*) linux_LD_ASSUME_KERNEL_hack=1 ;; esac fi fi fi # LD_ASSUME_KERNEL for Native POSIX Threading Library on some Linux distros #if [ `uname` = "Linux" -a -n "`which strings 2>/dev/null`" ]; then # debugOut "checking for NPTL + JVM vulernability..." #check libc to see if it was compiled with NPTL # nptl="`strings /lib/libc.so.6 | grep -i nptl`" # if [ "$nptl" ]; then # debugOut "NPTL detected! checking for vulnerable JVM...."; # I have to set this before I check the JVM version, a-cuz # the call will hang, if it -is- vulnerable! # export LD_ASSUME_KERNEL=2.2.5 # $actvm -version > /dev/null 2> /dev/null # if [ "$?" -eq "0" ]; then # eval `$actvm -version 2>&1 | $AWK ' # BEGIN { # vendor="Sun" # } # /"[0-9]\.[0-9]\.[0-9][^"]*"$/ { # gsub ("[\"]", "", $3) # split ($3, ver, "[\._-]") # printf "v_major=%s\nv_minor=%s\nv_patch=%s\n",ver[1],ver[2],ver[3] # } # /IBM/ { # vendor="IBM" # } # END { # printf "v_vendor=%s\n",vendor # } # ' ` # unset the LD_ASSUME_KERNEL in cause we don't need it # unset LD_ASSUME_KERNEL # debugOut "major : ${v_major}" # debugOut "minor : ${v_minor}" # debugOut "patch : ${v_patch}" # debugOut "vendor: ${v_vendor}" # check our rules for setting LD_ASSUME_KERNEL # currently, we're only setting this for JVMS < 1.4 # we can add more rules later, if we need to. # if [ ${v_minor:-0} -lt 4 ]; then # debugOut "Vulnerable JVM detected... implementing workaround" # linux_LD_ASSUME_KERNEL_hack=1 # else # debugOut "Your JVM is OK! Congratulations!" # fi # else # unset LD_ASSUME_KERNEL # fi # fi #fi if [ $linux_LD_ASSUME_KERNEL_hack -eq 1 ]; then LD_ASSUME_KERNEL=2.2.5 export LD_ASSUME_KERNEL fi ################################################################################## # LAUNCH VM # Passing in addtional stuff options="$options $lax_nl_java_option_additional" # Changing working directory if [ ! "$lax_user_dir" = "" ] then if [ ! "$lax_user_dir" = "." ]; then cd "$lax_user_dir" fi else cd "$olddir" fi resolveLink "$actvm" actvm="$resolvedLink" ################################################################################## # JAVA 9 AND ABOVE ADDITIONAL OPTIONS # Stores TRUE if java version is Java-9 and above, else FALSE isJava9AndAbove="FALSE" # 'inspectedVMVersion' will be empty in case of With VM. Hence the following. if [ "$inspectedVMVersion" = "" ] then getJavaVersion $actvm inspectedVMVersion=$javaVersion unset javaVersion fi # Checking Java Version and adding Java-9 module illegal access switch only in case of Java-9 and above. # Chances are this options may be removed in the next major release. extractVMVer=`echo $inspectedVMVersion | cut -c1-2` if [ "$extractVMVer" != "1." ] ; then debugOut "Java 9 or higher version detected. Adding module access switch." isJava9AndAbove="TRUE" //Fix for WO IA-20048 Adding JVM param to disable default //UI Scaling of Java 9 and above versions java9Options="--add-opens java.base/jdk.internal.loader=ALL-UNNAMED -Dsun.java2d.uiScale.enabled=false " options="$java9Options $options" fi # Optional printout of all variable values for debugging purposes debugOut "" debugOut "========= Virtual Machine Options ====================================" debugOut "LAX properties incorporated............. OK." debugOut "classpath............................... \"$lax_class_path\"" debugOut "main class.............................. \"$lax_main_class\"" debugOut ".lax file path.......................... \"$propfname\"" debugOut "user directory.......................... \"$lax_user_dir\"" debugOut "stdout to............................... \"$lax_stdout_redirect\"" debugOut "sterr to................................ \"$lax_stderr_redirect\"" debugOut "install directory....................... \"$lax_dir\"" debugOut "JIT..................................... ${jittype:-"none"}" debugOut "option (verify)......................... ${verify:-"none"}" debugOut "option (verbosity)...................... ${verbo:-"none"}" debugOut "option (garbage collection extent)...... ${gcxtnt:-"none"}" debugOut "option (garbage collection thread)...... ${gcthrd:-"none"}" debugOut "option (native stack max size).......... ${nsmax:-"none"}" debugOut "option (java stack max size)............ ${jsmax:-"none"}" debugOut "option (java heap max size)............. ${jhmax:-"none"}" debugOut "option (java heap initial size)......... ${jhinit:-"none"}" debugOut "option (lax.nl.java.option.additional).. ${lax_nl_java_option_additional:-"none"}" # Below debug ouput will be shown only in case of Java-9 and above if [ "$isJava9AndAbove" = "TRUE" ] ; then debugOut "option (Java 9 and above switch)........ ${java9Options:-"none"}" fi actvmBinaryName=`basename "$actvm"` # get dirname of binary actvmHome=`dirname "$actvm"` # is the dir the binary is in named "bin"? if [ "`basename "$actvmHome"`" = "bin" ]; then # if so then the dir above bin is the java home JAVA_HOME=`dirname "$actvmHome"` else JAVA_HOME= fi # Making $JAVA_HOME available to the application. export JAVA_HOME # [RW] reset the locale that what we remember it to be (see use.sh line 22) if [ "$IS_INSTALLER" = "true" ]; then if [ "X$OLD_LANG" = X ] then # no locale was defined prior to running this program unset LANG else # there was a locale: revert back to it LANG="$OLD_LANG" fi fi ########################################################################### # tlb 2001-09-18 # Moving the checking for the DISPLAY variable down here as there are # options in the LAX that might override the need for checking the DISPLAY. # Those options need loading before the check is performed. # Also making sure we don't report an error when running on Mac OS X. debugOut "" debugOut "========= Display settings ===========================================" # # check the display # isRemoteDisplay="false" if [ "$IS_INSTALLER" = "true" -a "$isConsole" = "false" -a "$isSilent" = "false" -a ! "$osName" = "darwin" ]; then hostname=`hostname` isRemoteDisplay="true" for display in ${hostname}:0 ${hostname}:0.0 localhost:0 localhost:0.0 unix:0 unix:0.0 :0 :0.0 do if [ "$DISPLAY" = "$display" ]; then isRemoteDisplay="false"; fi done fi xDisp="local" if [ "$isRemoteDisplay" = "true" ]; then xDisp="remote" fi if [ -z "$DISPLAY" ]; then xDisp="not set" fi debugOut "X display............................... $xDisp" if [ -z "$DISPLAY" -a "$uimode" = "gui" ]; then debugOut "WARNING: This shell's DISPLAY variable has not been set." debugOut "This installer is configured to run in GUI and will probably" debugOut "fail. Try running this installer in console or silent mode," debugOut "or on another UNIX host which has the DISPLAY variable set," debugOut "if the installer unexpectedly fails." else if [ "$isRemoteDisplay" = "true" -a "$uimode" = "gui" ]; then debugOut "WARNING: The name of this host ($hostname) and the setting" debugOut "of this shell's DISPLAY ($DISPLAY) variable do not match." debugOut "If this launcher is being displayed to a Microsoft Windows desktop" debugOut "through X Windows the Java Virtual Machine might abort. Try running" debugOut "this installer locally on the target system or through X Windows to" debugOut "another UNIX host if the installer unexpectedly fails." fi fi debugOut "UI mode................................. $uimode" # COMMENT ME TO REMOVE OUTPUT FROM NORMAL INSTALLER EXECUTION if [ "$IS_INSTALLER" = "true" ]; then if [ "$uimode" != "silent" ]; then echo "" LAN_CON_MSG=`getLocalizedString launch` printLocalizedString "$LAN_CON_MSG" "Launching installer..." echo "" fi [ -f "$CUSTOM" ] && rm -f "$CUSTOM" fi # MMA - clear ENV to address a problem where the shell initialization # file (.Xshrc) pointed to by ENV may overide the classpath we have just set, # causing the app to fail. Drawback is that other environment variables set # in the init file will not be available in the environment (they will be # available as Java system properties, however). Comment out the two lines # below to change this behavior. ENV= export ENV # I split these up so they would be a bit clearer on the screen. #debugOut "" debugOut "========= VM Command Line ============================================" #debugOut "CLASSPATH=$lax_class_path" #debugOut "\"$actvm\" $options $lax_nl_java_launcher_main_class \"$propfname\" \"$envPropertiesFile\" $cmdLineArgs" #debugOut "$command" debugOut "options: $options" # Here is where we actually run the app in Java: CLASSPATH="$lax_class_path:$CLASSPATH"; export CLASSPATH debugOut "CLASSPATH:$CLASSPATH" if [ "`echo $actvm | grep 'jre$'`" ]; then cpArg="-cp" fi debugOut "" unset POSIXLY_CORRECT if [ $DO_NOT_FORK ] then debugOut "========= Executing JAVA =============================================" # this is the original, it's still here for copy/paste purposes #eval \"$actvm\" $options $lax_nl_java_launcher_main_class \"$propfname\" \"$envPropertiesFile\" $cmdLineArgs lax_class_path=\"$lax_class_path\" if [ $cpArg ]; then command="\"$actvm\" $options $cpArg \"$CLASSPATH\" $lax_nl_java_launcher_main_class \"$propfname\" \"$envPropertiesFile\"" else command="\"$actvm\" $options $lax_nl_java_launcher_main_class \"$propfname\" \"$envPropertiesFile\"" fi eval $command $cmdLineArgs else debugOut "========= Forking JAVA =============================================" if [ $cpArg ]; then exec "$actvm" $options $cpArg "$CLASSPATH" $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs else DISTRO_NAME= GUEST_OS_NAME= if [ -f /etc/issue ] ; then DISTRO_NAME=`cat /etc/issue` fi if [ -f /etc/centos-release ] ; then DISTRO_NAME=`cat /etc/centos-release` fi if [ -f /etc/redhat-release ] ; then DISTRO_NAME=`cat /etc/redhat-release` fi if [ ! -z "$DISTRO_NAME" ] ; then if [ ! -z "$(echo "$DISTRO_NAME" | awk '/Ubuntu/')" ] ; then jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *not*found*|*install*bin* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac elif [ ! -z "$(echo "$DISTRO_NAME" | awk '/CentOS/')" ] ; then jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac elif [ ! -z "$(echo "$DISTRO_NAME" | awk '/SUSE/')" ] ; then jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac elif [ ! -z "$(echo "$DISTRO_NAME" | awk '/Red Hat Enterprise Linux/')" ] ; then jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac elif [ ! -z "$(echo "$DISTRO_NAME" | awk '/Fedora/')" ] ; then jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac else jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac fi else if [ -f /etc/release ] ; then DISTRO_NAME=`cat /etc/release` fi if [ ! -z "$DISTRO_NAME" ] ; then if [ ! -z "$(echo "$DISTRO_NAME" | awk '/Solaris/')" ] ; then if [ -z "$(echo "$DISTRO_NAME" | awk '/SPARC/')" ] ; then DO_NOT_FORK=1; export DO_NOT_FORK fi JRE_SUCCESS=`exec "$actvm" 2>&1` case "$JRE_SUCCESS" in *cannot*execute*|*install*bin* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *Usage*) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac else exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs fi else jre_success=`exec "$actvm" 2>&1` case "$jre_success" in *No*such*file*or*directory*|*install*bin*|*cannot*execute*binary*file* ) echo "JRE libraries are missing or not compatible...." echo "Exiting...." ;; *) exec "$actvm" $options $lax_nl_java_launcher_main_class "$propfname" "$envPropertiesFile" $cmdLineArgs ;; esac fi fi fi fi exitValue=$? debugOut "========= JAVA Finished ==============================================" debugOut "" # Change back to directory used priory to this script running. cd "$olddir" exit $exitValue