forked from sjdweb/mac-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·199 lines (137 loc) · 6.52 KB
/
bootstrap
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env bash
################################################################################
# bootstrap
#
# This script is intended to set up a new Mac computer with my dotfiles and
# other development preferences.
################################################################################
# Thank you, thoughtbot!
bootstrap_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n[BOOTSTRAP] $fmt\n" "$@"
}
################################################################################
# Variable declarations
################################################################################
osname=$(uname)
export COMMANDLINE_TOOLS="/Library/Developer/CommandLineTools"
export OLD_DOTFILES_BACKUP=$HOME/old_dotfiles_backup
export DOTFILES_REPO_URL="git@github.com:sjdweb/dotfiles.git"
export DOTFILES_BRANCH="master"
export DOTFILES_DIR=$HOME/dotfiles
# export BOOTSTRAP_REPO_URL="https://github.com/sjdweb/mac-bootstrap.git"
# export BOOTSTRAP_BRANCH="master"
export BOOTSTRAP_DIR=$HOME/Code/mac-bootstrap
################################################################################
# Make sure we're on a Mac before continuing
################################################################################
if [ "$osname" == "Linux" ]; then
bootstrap_echo "Oops, looks like you're on a Linux machine. Please have a look at
my Linux Bootstrap script: https://github.com/joshukraine/linux-bootstrap"
exit 1
elif [ "$osname" != "Darwin" ]; then
bootstrap_echo "Oops, it looks like you're using a non-UNIX system. This script
only supports Mac. Exiting..."
exit 1
fi
################################################################################
# Check for presence of command line tools if macOS
################################################################################
if [ ! -d "$COMMANDLINE_TOOLS" ]; then
bootstrap_echo "Apple's command line developer tools must be installed before
running this script. To install them, just run 'xcode-select --install' from
the terminal and then follow the prompts. Once the command line tools have been
installed, you can try running this script again."
exit 1
fi
################################################################################
# Clone mac-bootstrap repo
################################################################################
# NOTE: run this locally rather than re-clone.
# bootstrap_echo "Cloning mac-bootstrap repo..."
# git clone "$BOOTSTRAP_REPO_URL" -b "$BOOTSTRAP_BRANCH" "$BOOTSTRAP_DIR"
################################################################################
# Authenticate
################################################################################
sudo -v
# Keep-alive: update existing `sudo` time stamp until bootstrap has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# ################################################################################
# # Set machine name
# ################################################################################
# printf "\nPlease enter a name for your Mac and press [ENTER] (e.g. Joshua's iMac)\n"
# read -r -p "> " COMPUTER_NAME
# export COMPUTER_NAME
# printf "\nPlease enter a host name for your Mac and press [ENTER] (e.g. joshuas-imac)\n"
# read -r -p "> " HOST_NAME
# export HOST_NAME
# printf "\nPlease enter your desired time zone and press [ENTER] (e.g. Europe/Kiev)\n(To view available options run \`sudo systemsetup -listtimezones\`)\n"
# read -r -p "> " TIME_ZONE
# export TIME_ZONE
################################################################################
# 1. Provision with my adaptation of Laptop (install/laptop)
################################################################################
bootstrap_echo "Step 1: Installing Laptop script..."
cp "$BOOTSTRAP_DIR"/install/Brewfile "$HOME"/.Brewfile
sh "$BOOTSTRAP_DIR"/install/laptop 2>&1 | tee ~/laptop.log
bootstrap_echo "Done!"
################################################################################
# 2. Install Oh-My-Zsh (http://ohmyz.sh/)
################################################################################
bootstrap_echo "Step 2: Installing Oh-My-Zsh..."
if [ -d "$HOME"/.oh-my-zsh ]; then
rm -rf "$HOME"/.oh-my-zsh
fi
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
bootstrap_echo "Done!"
################################################################################
# 3. Install NVM (https://github.com/creationix/nvm)
################################################################################
bootstrap_echo "Step 3: Installing NVM..."
# shellcheck source=/dev/null
source "$BOOTSTRAP_DIR"/install/nvm
bootstrap_echo "Done!"
################################################################################
# 4. Setup dotfiles (http://jsua.co/dotfiles)
################################################################################
bootstrap_echo "Step 4: Installing dotfiles..."
if [[ -d $DOTFILES_DIR ]]; then
bootstrap_echo "Backing up old dotfiles to $HOME/old_dotfiles_backup..."
rm -rf "$OLD_DOTFILES_BACKUP"
cp -R "$DOTFILES_DIR" "$OLD_DOTFILES_BACKUP"
rm -rf "$DOTFILES_DIR"
fi
bootstrap_echo "Cloning dotfiles repo to ${DOTFILES_DIR} ..."
git clone "$DOTFILES_REPO_URL" -b "$DOTFILES_BRANCH" "$DOTFILES_DIR"
# shellcheck source=/dev/null
source "$DOTFILES_DIR"/install.sh
bootstrap_echo "Done!"
################################################################################
# 5. Install Powerline-patched fonts
################################################################################
bootstrap_echo "Step 5: Installing fixed-width fonts patched for use with Powerline symbols..."
if [ -d "$HOME"/src/fonts ]; then
rm -rf "$HOME"/src/fonts
fi
git clone https://github.com/powerline/fonts.git "$HOME"/src/fonts
cd "$HOME"/src/fonts || exit
./install.sh
cd "$HOME" || exit
rm -rf "$HOME"/src/fonts
bootstrap_echo "Done!"
################################################################################
# 6. Set macOS preferences
################################################################################
bootstrap_echo "Step 10: Setting macOS preferences..."
# shellcheck source=/dev/null
source "$BOOTSTRAP_DIR"/install/macos-defaults
# shellcheck source=/dev/null
source "$BOOTSTRAP_DIR"/install/macos-dock
rm -rf "$BOOTSTRAP_DIR"
bootstrap_echo "Done!"
echo
echo "**********************************************************************"
echo "**** Mac Bootstrap script complete! Please restart your computer. ****"
echo "**********************************************************************"
echo