Slack - Version Installed Extension Attribute

BoscoATX
New Contributor III

I found a great script to update Slack here on Jamf Nation but I couldn't find an extension attribute to find the current installed version so I wrote my own (borrowed from a Google Chrome version EA). My intent is to create a smart group with less than the newest version to scope to the auto-install script. Enjoy!

Slack update script:
Slack OS X app auto-install/update deployment method / script

Slack: Version Installed EA

<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>Slack Version</displayName>
<description/>
<dataType>string</dataType>
<scriptContentsMac>#!/bin/sh&#13;
#&#13;
############################################################################&#13;
#&#13;
# Extension Attribute checks to display Slack's Version with Release number.&#13;
#&#13;
# Uses CFBundleShortVersionString because this is the "release version number of the bundle"&#13;
# Ref: https://developer.apple.com/library/IOS/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html&#13;
#&#13;
#&#13;
############################################################################&#13;
#&#13;
if [ -d /Applications/Slack.app/ ] ; then&#13;
    RESULT=$( sudo defaults read /Applications/Slack.app/Contents/Info CFBundleShortVersionString )&#13;
    echo "&lt;result&gt;$RESULT&lt;/result&gt;"&#13;
else&#13;
    echo "&lt;result&gt;Not Installed&lt;/result&gt;"&#13;
fi&#13;
&#13;
</scriptContentsMac>
<scriptContentsWindows/>
</extensionAttribute>
2 REPLIES 2

cwaldrip
Valued Contributor

Is the CFBundleShortVersionString sometimes different than the version number found by making a smart group using Application Version?

Missed that Slack update script though. That's cool.

(also, the html escaped carriage returns "&#13" in your script are unnecessary I think)

bwiessner
Contributor II

This is what I did for my slack EA

#!/bin/sh

APP_VERSION_KEY="CFBundleShortVersionString"

currentSlackVersion=$(/usr/bin/curl -s 'https://downloads.slack-edge.com/mac_releases/releases.json' | grep -o "[0-9].[0-9].[0-9]" | tail -1)

localSlackVersion=$(defaults read /Applications/Slack.app/Contents/Info.plist "CFBundleShortVersionString")


if [[ "${currentSlackVersion}" = "${localSlackVersion}" ]]; then
    result="updated $localSlackVersion"
else 
    result="not current"
fi


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