HomeBrew Detection

bmack99
Contributor III

I'm curious if anyone has an extension attribute or script to detect the presence of homebrew anywhere on a device(not just the default install location)?

 

Thanks for any help!

4 REPLIES 4

ssoun
New Contributor III

This is what we use

#!/bin/bash

if [ ! -z $(which brew) ];then
  echo "<result>Yes</result>"
else
  echo "<result>No</result>"
fi

exit 0

 

bmack99
Contributor III

Thanks @ssoun I actually posed this same question over in the scripting channel of mac admins slack yesterday and had someone respond with the below, which seems to be working well in our environment:

#!/bin/sh

crntusr="$(/usr/bin/stat -f %Su /dev/console)"
brewchk="$(/usr/bin/sudo -i -u "$crntusr" /usr/bin/which brew)"

if [ -z "$brewchk" ]
then
	echo "<result>no</result>"
else
	echo "<result>$brewchk</result>"
fi

ssoun
New Contributor III

Cool, the EA even returns where brew is installed.

Cayde-6
Release Candidate Programs Tester

Curious if this is still working?

I'm getting blank returns from the brewchk variable when running through Jamf.

Brew is installed and the path is found in the user's $PATH