-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMac-Check-Rosetta2.sh
More file actions
34 lines (28 loc) · 998 Bytes
/
Mac-Check-Rosetta2.sh
File metadata and controls
34 lines (28 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# This script is provided AS IS without warranty of any kind.
# https://github.com/Mac-Nerd/Mac-scripts
# -----------------------------------------------------------
# Checks and optionally installs Rosetta 2 on Apple Silicon (M1) Macs.
# Usage: run with option "true" to install Rosetta 2 on M1 devices that do not already
# have it installed. Otherwise, with no options to just run the check.
if [ "$(sysctl -in hw.optional.arm64)" != "1" ]
then
# Not running on Apple ARM Silicon
echo "Error: This Mac is not running an Apple Silicon (M1) CPU."
exit 1
else
if arch -x86_64 /usr/bin/true 2> /dev/null
then
# Running Intel code on ARM, so Rosetta2 already installed.
echo "Error: Rosetta 2 is already installed and running."
exit 0
elif [ "$1" = "true" ]
then
# install Rosetta2
echo "Installing Rosetta 2:"
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
else
echo "Rosetta 2 not installed. Exiting."
exit 0
fi
fi