Skip to content

Instantly share code, notes, and snippets.

@marksharrison
Last active July 16, 2020 18:20
Show Gist options
  • Save marksharrison/0658979387fa8d4a7f4f to your computer and use it in GitHub Desktop.
Save marksharrison/0658979387fa8d4a7f4f to your computer and use it in GitHub Desktop.
OS X 10.11 El Capitan Clean Install

OS X El Capitan 10.11 Clean Install

Download OS X El Capitan 10.11.1

OSX

Create OS X El Capitan 10.11 Bootable Installer USB Flash Drive

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/ElCapInstaller --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app --nointeraction

Install Apple Xcode

Download Apple Xcode from Apple Developer Site

XcodeApp

Install Apple Xcode Command Line Developer Tools

xcode-select --install

Install Homebrew Package Manager

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Check for installation issues
brew doctor

Install Homebrew Formulae

TODO add coreutils findutils and others

formulae=(
     go
     python
     node
     ffmpeg
     webkit2png
     imagemagick
     bash
     openssl
     openssh
     libxml2
     rename
     trash
     tree
     nano
     ack
     git
     wget
     curl
     syncthing
     homebrew/dupes/grep
     Caskroom/cask/brew-cask
     Caskroom/cask/osxfuse
     homebrew/fuse/sshfs
     Caskroom/cask/1password
     Caskroom/cask/evernote
     Caskroom/cask/atom
)
brew tap homebrew/dupes caskroom/fonts
brew install ${formulae[@]}
brew cask install font-open-sans
# Delete all downloaded formula installation files
brew cleanup

Formulae can be searched online at [BrewFormulas][] or [Caskroom][] [brewformulas]: http://brewformulas.org/ "BrewFormulas" [caskroom]: http://caskroom.io/search "Caskroom"

Set /usr/local permissions for Homebrew on OS X 10.11

[ -d "/usr/local" ] && sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local/ && echo "Permissions set" || echo "Directory /usr/local does not exist. Disable SIP via 'csrutil disable; reboot’ in Recovery Mode and execute the following command 'sudo mkdir /usr/local && sudo chflags norestricted /usr/local && sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local’ then renable SIP via 'csrutil enable; reboot’ in Recovery Mode"

Set Homebrew Environment Variables

# TODO: Add $PATH=$(brew --prefix coreutils)/libexec/gnubin:$PATH
# Build PATH variable script in ~/.bash_path
for i in /usr/local/Cellar/*/*/bin; do
  echo 'export PATH="'$i':$PATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/libexec/gnubin; do
  echo 'export PATH="'$i':$PATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/share/man; do
  echo 'export MANPATH="'$i':$MANPATH"' >> ~/.bash_path
done
for i in /usr/local/Cellar/*/*/libexec/gnuman; do
  echo 'export MANPATH="'$i':$MANPATH"' >> ~/.bash_path
done

Check if .bash_path is being called from .bash_profile

PATCH='grep "~/.bash_path" ~/.bash_profile'
if [ "$PATCH" == "" ]; then
  # Add Ubuntu-style PS1 to .bash_profile
  cat <<EOF > ~/.bash_profile
export PS1="\[\033[1;32m\]\u@\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]# "
EOF
  # Add .bash_path to .bash_profile
  echo "source ~/.bash_path" >> ~/.bash_profile
fi

Set Computer Names

#!/bin/bash
# Set 'The name associated with hostname(1) and gethostname(3)'
sudo scutil --set HostName "subdomain.domain.tld"
# Set 'The user-friendly name for the system’ from ‘HostName' value
sudo scutil --set ComputerName $HOSTNAME
# Set 'The local (Bonjour) host name'
sudo scutil --set LocalHostName ${HOSTNAME%%.*}
# Set NetBIOSName to HostName Value
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName $HOSTNAME

Flush DNS Caches

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Enable Mac App Store Auto Updates

# Quit System Preferences app
osascript -e "tell application \"System Preferences\" to quit"
# Disable softwareupdate as workaround for defaults cache breaking
sudo softwareupdate --schedule off
# Automatically check for updates
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool True
# Download newly available updates in background
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool True
# Install OS X updates
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool True
# Install app updates
sudo defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool True
# Install system data files and security updates
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool True
# Automatically download apps purchased on other Macs
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool True
#  Enable softwareupdate
sudo softwareupdate --schedule on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment