Skip to content

Commit

Permalink
Now checks for network and for the Rosetta process
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Pugh committed Jul 23, 2021
1 parent db1cbf1 commit ac18dfb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# Rosetta-2-install
Make a payload-free package containing a script to install Rosetta 2.

If you have `munkipkg` installed and available at `/usr/local/bin/munkipkg`, use `make` to make an unsigned payload-free package.
This script checks that the computer on which it is running has an Apple Silicon processor. If it is, it checks whether Rosetta 2 is installed. If it is not installed, it will check for a network connection and then proceed to install Rosetta 2.

If you have `sign_pkg.py` available at `../jamf-upload/sign_pkg.py`, use `make; make sign` to make a signed package.
## Payload-free package

You may wish to make a payload-free package containing a script to install Rosetta 2.

If you have `munkipkg` installed and available at `/usr/local/bin/munkipkg`, use `make` to make an unsigned payload-free package. Note that you should compile the computer on an Apple Silicon Mac to get a universal package, which you are obviously going to need!

I have also included a signed package in the Releases section of this repo.

### Signing the package

You may wish to sign the package for use in DEP enrollment. I have a script in the [Jamf-Upload](https://github.com/grahampugh/jamf-upload) repo to help with this.

Clone the Jamf-Upload repo to the same folder that contains this repo's folder.

You also need AutoPkg to be installed to use this script, and you need to add your Developer ID Installer certificate in your login keychain.

Once you have met these requirements, use `make; make sign` to make a signed package.

## Use in Jamf Pro
You can add this script or package to a policy that is scoped to **all computers**, because the script will do nothing if Rosetta is already installed, or when run on an Intel device.

It is recommended to target at **Enrollment Complete** and **Recurring Check-in**, **Once per Computer**.
You can add this script (or package) to a policy that is scoped to **All Computers**, because the script will do nothing if Rosetta is already installed, or when run on an Intel device.

It is recommended to target at **Enrollment Complete** and **Recurring Check-in**, **Once per Computer**.

Use a Policy name that will be alphabetically first in your Jamf instance. We use **0001 - Install Rosetta 2**.
43 changes: 33 additions & 10 deletions Rosetta-2-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,48 @@
Determine whether Rosetta is installed - install if not.
DOC

max_wait_count=10

wait_for_network() {
# check for
n=1
while [[ $(ifconfig -a inet 2>/dev/null | sed -n -e '/127.0.0.1/d' -e '/0.0.0.0/d' -e '/inet/p' | wc -l) -lt 1 ]] ; do
if [[ $n -gt $max_wait_count ]] ; then
echo "[Rosetta-2-install] No network - Rosetta 2 installation failed"
exit 1
fi
echo "[Rosetta-2-install] Waiting for network access... attempt $n"
sleep 5
(( n++ ))
done
while ! curl --silent http://captive.apple.com/hotspot-detect.html 2>/dev/null | grep -q Success; do
echo "[Rosetta-2-install] Waiting for network access"
sleep 5
done
}

# is this an ARM Mac?
arch=$(/usr/bin/arch)
if [ "$arch" == "arm64" ]; then
echo "This is an arm64 Mac."
if [[ "$(/usr/bin/arch)" == "arm64"* ]]; then
echo "[Rosetta-2-install] This is an arm64 Mac."
# is Rosetta 2 installed?
if arch -x86_64 /usr/bin/true 2>/dev/null ; then
echo "Rosetta 2 is already installed"
if /usr/bin/pgrep oahd >/dev/null 2>&1 ; then
echo "[Rosetta-2-install] Rosetta 2 is already installed"
else
echo "Rosetta 2 is missing - installing"
echo "[Rosetta-2-install] Rosetta 2 is missing - installing"
wait_for_network
echo "[Rosetta-2-install] Network is connected: proceeding with Rosetta 2 installation..."
echo
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
if arch -x86_64 /usr/bin/true 2>/dev/null; then
echo "Rosetta 2 is now installed"
echo
if /usr/bin/pgrep oahd >/dev/null 2>&1 ; then
echo "[Rosetta-2-install] Rosetta 2 is now installed"
else
echo "Rosetta 2 installation failed"
echo "[Rosetta-2-install] Rosetta 2 installation failed"
exit 1
fi
fi
else
echo "This is an Intel Mac."
echo "[Rosetta-2-install] This is an Intel Mac."
fi

exit 0
2 changes: 1 addition & 1 deletion pkg/Rosetta-2-install/build-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<key>suppress_bundle_relocation</key>
<true/>
<key>version</key>
<string>1.1</string>
<string>1.2</string>
</dict>
</plist>

0 comments on commit ac18dfb

Please sign in to comment.