Skip to content

Instantly share code, notes, and snippets.

@zouhir
Last active November 8, 2021 05:55
Show Gist options
  • Save zouhir/2ced9f4b80f4f99d67f7342ca2607616 to your computer and use it in GitHub Desktop.
Save zouhir/2ced9f4b80f4f99d67f7342ca2607616 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e # -e: exit on error
#######################################
# macOS Command Line Tools
#######################################
if pkgutil --pkgs=com.apple.pkg.CLTools_Executables >/dev/null; then
echo CommandLineTools: $(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | awk '/version:/ {print $2}')
else
xcode-select --install &> /dev/null
until pkgutil --pkgs=com.apple.pkg.CLTools_Executables >/dev/null; do
sleep 2
done
fi
if [ ! "$(command -v brew)" ]; then
# Homebrew installer now works out-of-the-box for arm mac, and puts stuff in opt/homebrew
# by default.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# https://github.com/rtrouton/rtrouton_scripts/blob/master/rtrouton_scripts/install_rosetta_on_apple_silicon/install_rosetta_on_apple_silicon.sh
# Check Rosetta LaunchDaemon. If no LaunchDaemon is found,
# perform a non-interactive install of Rosetta.
if [[ ! -f "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" ]]; then
echo "Installing Rosetta 2"
/usr/sbin/softwareupdate --install-rosetta --agree-to-license
if [[ $? -eq 0 ]]; then
echo "Rosetta 2 has been successfully installed."
else
echo "Rosetta 2 installation failed."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment