I've been dipping my toes into AutoPkg lately. I've been building Java, Silverlight, and a few others that all come with handy version extensions. I noticed that the Office one returns a string of "true","false", or "Not Installed". This makes it super easy to target a group (Office out of date = true) and never have to touch it again. That'd be really handy for all those other extensions. Unfortunately, they all return the version number. That's really handy, but I'd love to modify it to be more like the Office one. That way I don't have to go update the "Out_Of_Date_Java" group's criteria every time a new version comes out.
Here's what I have for my ExtensionTemplate for Java:
<computer_extension_attribute>
<name>Java Out Of Date</name>
<description />
<data_type>String</data_type>
<input_type>
<type>script</type>
<platform>Mac</platform>
<script>#!/bin/bash
from distutils.version import StrictVersion
import subprocess
import os.path
import shlex
import sys
CURRENT_VERSION = StrictVersion('%VERSION%')
JAVA_VERSION=$(defaults read /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist CFBundleVersion)
if JAVA_VERSION < CURRENT_VERSION:
result = true
else if: JAVA_VERSION = '':
result = 'Not Installed'
else:
result = false
print '<result>%s</result>' % str(result)
exit 0</script>
</input_type>
<inventory_display>Extension Attributes</inventory_display>
<recon_display>Extension Attributes</recon_display>
</computer_extension_attribute>
I have no idea if this makes any real sense though. I'm so out of date with scripting that I'm not confident in my abilities. I believe that says that if the java version is less than the current version built by AutoPkg, it returns true. If the java version is blank, it returns "Not Installed". In any other situation, it should return false. I don't believe this actually works. If it does, it is taking its sweet time to return anything from any machine.
Is there a better way to get auto-updating extension attributes to return the "true", "False", and "Not Installed" values for various?