Rosetta 2 Extension Attribute

abutterman
New Contributor III

Anyone happen to have an extension attribute written that detects whether or not Rosetta 2 is installed on the new M1 computers? This would help for deploying a policy to enable Rosetta on anything where it is currently disabled just in case an update removes it for whatever reason.

5 REPLIES 5

lubkens05
New Contributor II

Also interested in this. I do not know how to check to see if Rosetta is installed.

Jason33
Contributor III

Pulled from this thread, which is a good read https://www.jamf.com/jamf-nation/discussions/37357/deploy-rosetta-on-m1-machines-before-everything-else#responseChild212868

!/bin/bash


: << DOC
EA to determine whether Rosetta is installed. Possible results:
"installed" - arm64 Mac - Rosetta is installed
"missing" - arm64 Mac - Rosetta is not installed
"ineligible" - Intel Mac - Rosetta cannot be installed
DOC

is this an ARM Mac?

arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then # is rosetta 2 installed? if [[ -f "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" ]]; then result="installed" else result="missing" fi
else result="ineligible"
fi

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

ChaseEndy
New Contributor III

@Jason33 Were you able to get this to work?

monogrant
Contributor

Apple has moved the LaunchDaemon's default install path.

You can add an OR operator to check `/System/Library/LaunchDaemons/` as well.

 

arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then # is rosetta 2 installed? 
    if [[ -f "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" || -f "/System/Library/LaunchDaemons/com.apple.oahd.plist" ]]; 
        then result="installed" 
    else result="missing"
    fi
else result="ineligible"
fi
echo "<result>$result</result>"

 

 

That's messy and if changed, it may not work in the future. I just got this code from Apple Enterprise Support for using CoreFoundation to check if the system can run x86_64 code with the arch binary.

 

% cat can_run_x86.sh
#!/bin/sh
arch -x86_64 /usr/bin/true 2> /dev/null
if [ $? -eq 0 ]; then
echo "Can run X86_64 code!"
else
echo "X86_64 code is not runnable!"
fi

 

 

...SO, put that in the EA and you get...

TLDR: USE THIS

 

#!/bin/sh
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then # is rosetta 2 installed? 
    arch -x86_64 /usr/bin/true 2> /dev/null
    if [ $? -eq 1 ];
        then result="missing"
    else result="installed"
    fi
else result="ineligible"
fi
echo "<result>$result</result>"

 

Thanks for this update. I just realized that I have 75 Macs that have been constantly reinstalling Rosetta at every Check-In because of this change of location.