Home > Casper, Java, Mac administration, Scripting > Casper Extension Attribute scripts to report Java browser plug-in info

Casper Extension Attribute scripts to report Java browser plug-in info

To help Casper admins identify which Macs should be getting the new Oracle Java 7 browser plug-in update, I’ve posted a couple of Casper extension attributes to my GitHub repo. The first one detects if a Mac’s Java browser plug-in in /Library/Internet Plug-Ins was supplied by Apple or Oracle. If no Java plug-in is detected, a No Java Plug-In Available message is displayed.

#!/bin/bash

javaVendor=`/usr/bin/defaults read /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Info CFBundleIdentifier`

if [ "$javaVendor" = "com.oracle.java.JavaAppletPlugin" ]; then
        result=Oracle
elif [ "$javaVendor" = "com.apple.java.JavaAppletPlugin" ]; then
        result=Apple
elif [ "$javaVendor" = "" ]; then
        result="No Java Plug-In Available"
fi

echo "<result>$result</result>"

The other one was shared on JAMF Nation by Christoph von Gabler-Sahm. This script detects the version of the active JavaAppletPlugin plug-in in /Library/Internet Plug-Ins.

#!/bin/bash

# Christoph von Gabler-Sahm (email-redacted)
# Version 1.0

# checks installed version of Java Applet Plugin
# returns values like "Not installed", "JavaInstallOnDemand: 14.5.0", "JavaJDK16: 14.5.0" or "Java 7 Update 09"

PLUGINPATH="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin"

# Plugin version
S_VERSION=$( /usr/bin/defaults read "${PLUGINPATH}/Contents/Info" CFBundleShortVersionString 2>/dev/null )

# JavaInstallOnDemand or empty
S_PROJECT=$( /usr/bin/defaults read "${PLUGINPATH}/Contents/version" ProjectName 2>/dev/null )

if [[ -e "${PLUGINPATH}" ]]; then
    if [[ "${S_PROJECT}" == "" ]]; then
        EA_RESULT="${S_VERSION}"
    else
        EA_RESULT="${S_PROJECT}: ${S_VERSION}"
    fi
else
    EA_RESULT="Not installed"
fi

echo "<result>${EA_RESULT}</result>"

For Macs that have had the Java for OS X 2012-006 update installed, Christoph’s script above will report the following version status:

JavaInstallOnDemand: 14.5.0

Both scripts are available on my GitHub repo:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Extension_Attributes/java_browser_plug-in_version

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Extension_Attributes/java_vendor

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment