-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacosprep.sh
More file actions
executable file
·35 lines (30 loc) · 1.36 KB
/
macosprep.sh
File metadata and controls
executable file
·35 lines (30 loc) · 1.36 KB
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
#!/usr/bin/env bash
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `macosprep.sh` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Step 1: Update the OS and Install Xcode Tools
echo "------------------------------"
echo "Updating macOS. If this requires a restart, run the script again."
# Install all available updates
sudo softwareupdate -ia
# Install only recommended available updates
#sudo softwareupdate -irv
softwareupdate --install-rosetta --agree-to-license
echo "------------------------------"
echo "Installing Xcode Command Line Tools."
# Install Xcode command line tools
# https://developer.apple.com/forums/thread/698954
# Only run if the tools are not installed yet
# To check that try to print the SDK path
xcode-select -p &> /dev/null
if [ $? -ne 0 ]; then
echo "Command Line Tools for Xcode not found. Installing from softwareupdate…"
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')
softwareupdate -i "$PROD" --verbose;
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
else
echo "Command Line Tools for Xcode have been installed."
fi