forked from geerlingguy/mac-dev-playbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
65 lines (53 loc) · 1.75 KB
/
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Welcome to the laptop install script!
#
# This script bootstraps the OSX laptop to a point where we can run
# Ansible on localhost.
# 1. Installs
# - xcode
# - homebrew
# - ansible (via brew)
#
# It will ask you for your sudo password
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
fancy_echo "Boostrapping ..."
trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT
set -e
# Here we go.. ask for the administrator password upfront and run a
# keep-alive to update existing `sudo` time stamp until script has finished
# sudo -v
# while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Ensure Apple's command line tools are installed
if ! command -v cc >/dev/null; then
fancy_echo "Installing xcode ..."
xcode-select --install
else
fancy_echo "Xcode already installed. Skipping."
fi
if ! command -v brew >/dev/null; then
fancy_echo "Installing Homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" </dev/null
else
fancy_echo "Homebrew already installed. Skipping."
fi
# [Install Ansible](http://docs.ansible.com/intro_installation.html).
if ! command -v ansible >/dev/null; then
fancy_echo "Installing Ansible ..."
brew install ansible
else
fancy_echo "Ansible already installed. Skipping."
fi
# Clone the repository to your local drive.
if [ -d "~/Workspace/mac-dev-playbook" ]; then
fancy_echo "Mac-dev-playbook repo dir exists. Removing ..."
rm -rf ~/Workspace/mac-dev-playbook/
fi
fancy_echo "Cloning mac-dev-playbook repo ..."
cd ~/Workspace/
git clone https://github.com/timdiels1/mac-dev-playbook.git
fancy_echo "Changing to laptop repo dir ..."
cd ~/Workspace/mac-dev-playbook