Skip to main content
Question

Firefox - Get Version

  • November 18, 2014
  • 6 replies
  • 18 views

Forum|alt.badge.img+3

Is there a script to get Firefox versions for inventory or adding to extension attributes
Thanks

6 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • November 18, 2014

Why? That should be collected in normal application inventory.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • November 18, 2014

Yes but it's easier to have a display attribute


Forum|alt.badge.img+14
  • Contributor
  • November 18, 2014

Here you go:

if [ -d /Applications/Firefox.app ] ; then
    RESULT=$( defaults read /Applications/Firefox.app/Contents/Info CFBundleShortVersionString )
    echo "<result>$RESULT</result>"
else
    echo "<result>Not Installed</result>"
fi

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • November 18, 2014

I get you. I agree it would be a nice feature if we could add a column for any type of inventory item that gets captured to display in the regular columns.

Given that, if you really want a column/Extension Attribute for this, its pretty easy to get just about any application or plugins version information from the Info.plist file inside the <app>.app/Contents/ location.

So something like this for Firefox. Just adjust accordingly for other apps or plug-ins.

#!/bin/sh

FirefoxVersion=$( defaults read /Applications/Firefox.app/Contents/Info.plist CFBundleShortVersionString )

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

Note that although most applications store their version info in the "CFBundleShortVersionString" location in the plist. some store it in just "CFBundleVersion" so you should test any scripts you make for other applications before making them into Extension Attributes.

Also note that the above will just return a blank result if Firefox isn't installed or happens to be in a different location than /Applications/ That can be accounted for, but not sure how much you were looking for here.
Edit: Josh.Smith's script account for that very scenario.


Forum|alt.badge.img+10
  • Contributor
  • November 18, 2014

Here is what we use, the benefit to this is that it saves the value as an integer so you can do greater than and less than comparisons.

#!/bin/bash

ffAppExist=/Applications/Firefox.app
ffInfoPlist=${ffAppExist}/Contents/Info

if [[ -e $ffAppExist ]]; then
    echo "<result>$(/usr/bin/defaults read $ffInfoPlist CFBundleShortVersionString | awk -F. '{print $1"."$2}')</result>"
else
    echo "<result>0</result>"
fi

Yes, yes I know. The full version of Firefox has three number places. In my opinion I don't care 90% of the time about that. About 90% of the time I am looking at who has the major release versions.The few times I need to know the minor release version I am not relying on the EA to do it.


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • November 19, 2014

Thanks to all for your help , it works fine :)