JDK 8 CPU patch definition checks the JRE version

jhamil50
New Contributor III

Hi all,

I wasn't sure if anyone still uses this patch definition, but the extension attribute for Java SE Development Kit 8 (CPU) seems to check for the JRE version instead of the JDK:

#!/usr/bin/env bash
#######################################################################################
# Collects information to determine which version of the Java plugin is installed and # 
# then returning that version back if major version (1.X) match what we're searching  # 
# for with SEARCH_FOR_VERSION. Builds the result as 1.X.Y, ignoring the build number, #
# where X is major version and Y is the minor version.                                # 
#######################################################################################
NOT_INSTALLED="Not Installed"
SEARCH_FOR_VERSION="8"
RESULT=""

if [ -f "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" ] ; then
    RESULT=$( /usr/bin/defaults read "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" CFBundleVersion )
    REPORTED_MAJOR_VERSION=`/bin/echo "$RESULT" | /usr/bin/awk -F'.' '{print $2}'`
    REPORTED_MINOR_VERSION=`/bin/echo "$RESULT" | /usr/bin/awk -F'.' '{print $3}'`
    if [ "$REPORTED_MAJOR_VERSION" != "$SEARCH_FOR_VERSION" ] ; then
        RESULT="$NOT_INSTALLED"
    else
        RESULT=1."$REPORTED_MAJOR_VERSION".$REPORTED_MINOR_VERSION
    fi
else
    RESULT="$NOT_INSTALLED"
fi

/bin/echo "<result>$RESULT</result>"

As an example, I have a Mac with JDK 1.8.191 and JRE 1.8.201, but after an inventory update, the version on JDK 8 CPU is reported as Unknown. Running the above extension attribute in a script outputs <result>1.8.201</result>. Is anyone else seeing this behavior? I'm not seeing any modifications to the extension attribute that I have to approve, and I tried adding a new definition for the same title, but still see the above extension attribute.

0 REPLIES 0