-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rosetta-2-install.sh
executable file
·51 lines (46 loc) · 1.58 KB
/
Rosetta-2-install.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
: << DOC
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?
if [[ "$(/usr/bin/arch)" == "arm64"* ]]; then
echo "[Rosetta-2-install] This is an arm64 Mac."
# is Rosetta 2 installed?
if /usr/bin/pgrep oahd >/dev/null 2>&1 ; then
echo "[Rosetta-2-install] Rosetta 2 is already installed"
else
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
echo
if /usr/bin/pgrep oahd >/dev/null 2>&1 ; then
echo "[Rosetta-2-install] Rosetta 2 is now installed"
else
echo "[Rosetta-2-install] Rosetta 2 installation failed"
exit 1
fi
fi
else
echo "[Rosetta-2-install] This is an Intel Mac."
fi
exit 0