Jamf Pro is not picking up BeyondTrust Remote Assist in Applications with current version

AJPinto
Honored Contributor III

Random puzzle for the day. I had an issue that I was over thinking and did not realize the vendor just changed the application name, but it raised a question that I wanted to solve for funzies. 

 

You have a plist that you need to read CFBundleGetInfoString from (not that this ever happens), but the path to the plist has a random folder name in it (the example I was working on is the application vendor uses a random string at the end of the app name for whatever reason). Due to the variable, defaults cannot be used to read the plist. I was using find which works fine locally to identify the path of the plist but would take too long for an extension attribute and would make check-ins take too long.

find /Applications -name "*.app" -print | grep "/Remote Support Customer Client.app/Contents/Info.plist" | while readplist; do defaults read "$plist" | grep CFBundleGetInfoString | awk -F'"' '{print substr($2, 1, 8)}' done

 

 ~ % defaults read /Applications/.com.Application.scc.66ABEF6D/Remote\ Support\ Customer\ Client.app/Contents/Info.plist | grep CFBundleGetInfoString | awk -F'"' '{print substr($2, 1, 6)}'
24.1.2

 

Again, Jamf is getting the data we need, I was curious of how to accomplish the task. Jamf is clearly doing it already, possibly even using the find command, but I was wondering if any of you guys have a different way to approach this?

 

2 REPLIES 2

sdagley
Esteemed Contributor II

Try the "mdfind" command to use Spotlight's database to find the app via the bundle identifier. As an example here's an EA to find all copies of Firefox in the /Applications directory:

 

#!/bin/bash

# EA - Find all non-current Firefox apps in /Applications

OIFS=$IFS
IFS=$'\n'
files=($(mdfind -onlyin "/Applications" "kMDItemCFBundleIdentifier == org.mozilla.firefox"))
IFS=$OIFS

result=0
# Loop through all found copies and check to see if they're not version 128.0.3
for AppPath in "${files[@]}"
do
	if [[ -e "$AppPath/Contents/Info.plist" ]]; then
  		AppVersion=$(/usr/bin/defaults read "$AppPath/Contents/Info.plist" CFBundleShortVersionString)
  		if [[ "$AppVersion" != "128.0.3" ]]; then
  			((result++))
  		fi
	fi
done

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

 

 

AJPinto
Honored Contributor III

I ultimately landed on using cat binary which I forgot could read plists and supports wildcards. In the example below I'm reading a .ini instead of a plist, but it also works for plists. That is a nifty EA you have their, I may steal it lol.

 

#!/bin/bash

#=============================================================================
# Script Name: Version Beyond Trust Support Client
# Created: 
# Author:
#=============================================================================

# Find the settings.ini file(s)
files=$(ls /Users/Shared/.com.bomgar*/settings.ini 2>/dev/null)

# Check if any file is found
if [ -n "$files" ]; then
    ApplicationVersion=$(cat $files | grep build_version | sort -u | sed 's/.*build_version="\([^"]*\)".*/\1/')
    echo "<result>$ApplicationVersion</result>"
else
    echo "<result>Beyond Trust Support Client Not Installed</result>"
fi

exit 0