Skip to main content
Question

HomeBrew Detection

  • October 6, 2022
  • 4 replies
  • 108 views

Forum|alt.badge.img+9

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

Forum|alt.badge.img+8
  • Contributor
  • October 7, 2022

This is what we use

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

 


Forum|alt.badge.img+9
  • Author
  • Valued Contributor
  • October 7, 2022

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

Forum|alt.badge.img+8
  • Contributor
  • October 7, 2022

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

Cool, the EA even returns where brew is installed.


Cayde-6
Forum|alt.badge.img+22
  • Honored Contributor
  • December 6, 2023

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