Posted on 11-18-2014 08:20 AM
Is there a script to get Firefox versions for inventory or adding to extension attributes
Thanks
Posted on 11-18-2014 08:21 AM
Why? That should be collected in normal application inventory.
Posted on 11-18-2014 08:37 AM
Yes but it's easier to have a display attribute
Posted on 11-18-2014 08:49 AM
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
Posted on 11-18-2014 08:58 AM
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.
Posted on 11-18-2014 09:41 AM
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.
Posted on 11-19-2014 12:56 AM
Thanks to all for your help , it works fine :)