Last active
June 8, 2020 18:53
-
-
Save dsudduth/91ea66a94adeac042d3c316ed729ba05 to your computer and use it in GitHub Desktop.
Bootstrap script for macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # OSX Bootstrap | |
| # Note: to obtain logs, use the following when running this script. | |
| # command | tee -a "$log_file" | |
| set -e | |
| VERSION="1.0.0" | |
| HOMEBREW_INSTALLER_URL="https://raw.githubusercontent.com/Homebrew/install/master/install" | |
| HOMEBREW_PACKAGES=( | |
| git | |
| ssh-copy-id | |
| vim | |
| wget | |
| ) | |
| PYTHON_PACKAGES=( | |
| ipython | |
| virtualenv | |
| virtualenvwrapper | |
| ) | |
| separator() { | |
| echo -e "Step Complete!" | |
| } | |
| hello() { | |
| echo "macOS Bootstrap v${VERSION}" | |
| echo | |
| echo "Installing development dependencies on macOS" | |
| echo | |
| } | |
| install_command_line_tools() { | |
| echo "Trying to detect installed Command Line Tools..." | |
| if ! [[ "$(xcode-select -p)" ]]; then | |
| echo "Command Line Tools not detected" | |
| echo "Installing Command Line Tools..." | |
| xcode-select --install | |
| else | |
| echo "Command Line Tools detected, so skipping..." | |
| fi | |
| separator | |
| sleep 1 | |
| } | |
| set_mac_defaults() { | |
| echo "Setting system defaults..." | |
| echo "Disable sleep mode - sleep is for the weak" | |
| sudo systemsetup -setcomputersleep Off > /dev/null | |
| echo "Always show filename extension" | |
| defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
| separator | |
| sleep 1 | |
| } | |
| create_global_directories() { | |
| echo "Creating directories we need for our libraries and tools..." | |
| if [[ ! -d "/usr/local/bin" ]]; then | |
| echo "Creating /usr/local/bin" | |
| mkdir "/usr/local/bin" | |
| else | |
| echo "/usr/local/bin already exists" | |
| fi | |
| if [[ ! -d "/usr/local/lib" ]]; then | |
| echo "Creating /usr/local/lib" | |
| mkdir "/usr/local/lib" | |
| else | |
| echo "/usr/local/lib already exists" | |
| fi | |
| separator | |
| sleep 1 | |
| } | |
| add_to_path() { | |
| echo "Modifying path..." | |
| echo "Adding /usr/local/bin to PATH" | |
| export PATH="/usr/local/bin:$PATH" | |
| echo "Adding /usr/local/lib to PATH" | |
| export PATH="/usr/local/lib:$PATH" | |
| separator | |
| sleep 1 | |
| } | |
| install_homebrew() { | |
| echo "Trying to detect installed Homebrew..." | |
| if test ! [[ "$(command -v brew)" ]]; then | |
| echo "Homebrew is not installed" | |
| echo "Installing Homebrew..." | |
| ruby -e "$(curl -fsSL ${HOMEBREW_INSTALLER_URL})" | |
| brew update | |
| brew upgrade | |
| echo "Homebrew installed!" | |
| else | |
| echo "You already have Homebrew installed, so skipping..." | |
| brew update | |
| brew upgrade | |
| fi | |
| separator | |
| sleep 1 | |
| } | |
| install_brew_packages() { | |
| # Install GNU core utilities (those that come with OS X are outdated) | |
| echo "Installing GNU core utilities" | |
| brew tap homebrew/dupes | |
| brew install coreutils | |
| brew install gnu-sed --with-default-names | |
| brew install gnu-tar --with-default-names | |
| brew install gnu-indent --with-default-names | |
| brew install gnu-which --with-default-names | |
| brew install gnu-grep --with-default-names | |
| brew install findutils | |
| echo "Installing additional packages..." | |
| for package in "${HOMEBREW_PACKAGES[@]}"; do | |
| brew install "${package}" | |
| done | |
| echo "Cleaning up" | |
| brew cleanup | |
| separator | |
| sleep 1 | |
| } | |
| post_install() { | |
| echo | |
| echo | |
| echo "Setup was successfully done" | |
| echo | |
| echo "Happy Coding!" | |
| exit 0 | |
| } | |
| install_pip_packages() { | |
| echo "Installing PIP packages" | |
| for package in "${PYTHON_PACKAGES[@]}"; do | |
| pip install "${package}" | |
| done | |
| separator | |
| sleep 1 | |
| } | |
| # Calling functions in order | |
| hello | |
| install_command_line_tools | |
| set_mac_defaults | |
| create_global_directories | |
| add_to_path | |
| install_homebrew | |
| install_brew_packages | |
| install_pip_packages | |
| post_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment