-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathinstall.sh
357 lines (294 loc) · 11.9 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
#
# _ _ _ _ __ _
# (_)_ __ ___| |_ __ _| | |/ _| ___ ___| |_
# | | '_ \/ __| __/ _` | | | |_ / _ \/ __| __|
# | | | | \__ \ || (_| | | | _| __/\__ \ |_
# |_|_| |_|___/\__\__,_|_|_|_| \___||___/\__|
#
# Installfest Script for development on a Mac
#
# Author: Phillip Lamplugh, GA Instructor (2014)
# Contributions: PJ Hughes, GA Instructor (2014)
#
# Resources
# https://github.com/divio/osx-bootstrap
# https://github.com/paulirish/dotfiles
# https://github.com/mathiasbynens/dotfiles/
# References
# http://www.sudo.ws/
# http://www.gnu.org/software/bash/manual/bashref.html
# http://www.shellcheck.net
# http://explainshell.com/
#-------------------------------------------------------------------------------
# Colors
#-------------------------------------------------------------------------------
# Foreground
BLACK=$(tput setaf 0)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
GREEN=$(tput setaf 2)
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 172)
PURPLE=$(tput setaf 141)
RED=$(tput setaf 1)
WHITE=$(tput setaf 7)
YELLOW=$(tput setaf 226)
# Background
BG_BLACK=$(tput setab 0)
BG_BLUE=$(tput setab 4)
BG_CYAN=$(tput setab 6)
BG_GREEN=$(tput setab 2)
BG_MAGENTA=$(tput setab 5)
BG_ORANGE=$(tput setab 172)
BG_RED=$(tput setab 1)
BG_WHITE=$(tput setab 7)
BG_YELLOW=$(tput setab 226)
# Formatting
UNDERLINE=$(tput smul)
NOUNDERLINE=$(tput rmul)
BOLD=$(tput bold)
RESET=$(tput sgr0)
#-------------------------------------------------------------------------------
# Functions
#-------------------------------------------------------------------------------
# ABRB
function quoth_the_bard () {
local message=$1
local attribution=$2
echo ""
echo "$YELLOW$message$RESET"
echo "$PURPLE$attribution$RESET"
}
# upcase error message and exit script
function fie () {
local message=$(echo $1 | tr 'a-z' 'A-Z')
echo ""
echo "$RED$message$RESET"
exit
}
# announce our acts
function figlet_announces () {
clear
local act=$1
figlet -f ogre $act
}
function pause_awhile () {
read -p "$* Press Enter to continue"
}
#-------------------------------------------------------------------------------
MINIMUM_OS="10.7.0"
BELOVED_RUBY_VERSION="2.1.0"
SRC_DIR=~/.wdi-installfest
SCRIPTS=$SRC_DIR/scripts
SETTINGS=$SRC_DIR/settings
INSTALL_REPO=git@github.com:ga-instructors/installfest_script.git
# Determine OS version ################################################################
osx_version=$(sw_vers -productVersion)
# Force the user to upgrade if they're below 10.7
echo "You're running OSX $osx_version"
if [[ "$osx_version" < "$MINIMUM_OS" ]]; then
fie "Please upgrade to the latest OS then rerun this script."
fi
# The one prereq is Xcode Command Line Tools ##########################################
# Either download from the App store or install via xcode-select --install
# PL: it is possible earlier versions of xcode are installed to /dev... deal with this?
# https://gist.github.com/trinitronx/6217746
# if on mavericks just offer xcode-select
# need a check for command line tools
# `pkgutil --pkgs=com.apple.pkg.DeveloperToolsCLI` should return com.apple.pkg.DeveloperToolsCLI
#######################################################################################
# Check that command line tools are installed
case $osx_version in
*10.9*) cmdline_version="CLTools_Executables" ;; # Mavericks
*10.8*) cmdline_version="DeveloperToolsCLI" ;; # Mountain Lion
*10.7*) cmdline_version="DeveloperToolsCLI" ;; # Lion
*) echo "Please upgrade your OS"; exit 1;;
esac
# Check for Command Line Tools based on OS versions
if [ ! -z $(pkgutil --pkgs=com.apple.pkg.$cmdline_version) ]; then
echo "Command Line Tools are installed";
elif [[ $osx_version < "10.9" ]]; then
echo "Command Line Tools are not installed"
echo "Register for a Developer Account"
echo "Download the Command Lion Tools from"
echo "https://developer.apple.com/downloads/index.action"
echo "Then rerun this script"
exit 1
else
echo "Command Line Tools are not installed"
echo "run '$ sudo xcodebuild -license' then"
echo "'$ xcode-select --install'"
echo "Then rerun this script."
exit 1
fi
#######################################################################################
# clear terminal screen
clear
echo "Welcome to Installfest"
sudo echo "Thanks." # PJ: capture the user's password
# Start install fest ###################################################################
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo "Please register for an account on github.com if you haven't already done so."
read -p "Enter your full name: " user_name
read -p "Github Username: " github_name
read -p "Github Email: " github_email
#######################################################################################
# Let's make sure we're updated #######################################################
# and in control of the home folder
echo "Let's ensure you have full control over your user folder"
echo "This may take awhile"
sudo chown -R ${USER} ~
diskutil repairPermissions /
echo "Checking for recommended software updates."
echo "This may require a restart."
sudo softwareupdate -i -r --ignore iTunes
sudo chown -R ${USER} ~
#######################################################################################
quoth_the_bard "The play's the thing..."
# The curtain rises ###################################################################
# download the repo for the absolute paths
if [[ ! -d $SRC_DIR ]]; then
echo 'Downloading Installfest repo...'
# autoupdate bootstrap file
git clone $INSTALL_REPO $SRC_DIR
# hide folder
chflags hidden $SRC_DIR
else
# update repo
echo 'Updating repo...'
cd $SRC_DIR
git pull origin master
fi
#######################################################################################
# Ensure Macports and RVM aren't installed ############################################
clear
echo " _ _ _ "
echo " __ _ ___| |_ / | ___ ___ ___ _ __ ___ / |"
echo " / _' |/ __| __| | | _____ / __|/ __/ _ \ '_ \ / _ \ | |"
echo "| (_| | (__| |_ | | |_____| \__ \ (_| __/ | | | __/ | |"
echo " \__,_|\___|\__| |_| |___/\___\___|_| |_|\___| |_|"
echo " "
quoth_the_bard \
"Woe, destruction, ruin, and decay\; the worst is death and death will have his day." \
"--Richard II (III.ii)"
pause_awhile "Removing any previous installations of RVM and Macports."
source $SCRIPTS/clean.sh
######################################################################################
# Install homebrew and formulae ######################################################
clear
echo " _ _ ____ "
echo " __ _ ___| |_ / | ___ ___ ___ _ __ ___ |___ \ "
echo " / _' |/ __| __| | | _____ / __|/ __/ _ \ '_ \ / _ \ __) |"
echo "| (_| | (__| |_ | | |_____| \__ \ (_| __/ | | | __/ / __/ "
echo " \__,_|\___|\__| |_| |___/\___\___|_| |_|\___| |_____|"
echo " "
quoth_the_bard \
"PISTOL: The plain-song is most just: for humours do abound:
Knocks go and come; God's vassals drop and die;
And sword and shield,
In bloody field,
Doth win immortal fame.
Boy: Would I were in an alehouse in London! I would give
all my fame for a pot of ale and safety." \
"--Henry V (III.ii)"
pause_awhile "Installing our Package Manager HomeBrew"
source $SCRIPTS/brew.sh
######################################################################################
# Additional settings and bash_profile ###############################################
# FIGLET enters stage left. (homebrew installed a figlet formula to do auto ascii-text art)
# PHIL: What ho, Figlet!
# FIGLET: It is a tale. Told by an idiot, full of sound and fury. Signifying nothing.
# PHIL: Ummmmm, ok... Would you mind announcing the acts?
figlet_announces "act 1 - scene 3"
quoth_the_bard \
"I have touch'd the highest point of all my greatness;
And, from that full meridian of my glory,
I haste now to my setting: I shall fall
Like a bright exhalation in the evening,
And no man see me more." \
"--Henry VIII (III.ii)"
pause_awhile "Config settings for terminal"
source $SCRIPTS/settings.sh # PL: someday maybe these are kept in a hidden folder?
#######################################################################################
# Ruby setup ##########################################################################
figlet_announces "act 3 - scene 1"
quoth_the_bard \
"Once more the ruby-colour'd portal open'd," \
"--Venus and Adonis (1593)"
pause_awhile "Setting up RBENV our Ruby Version Manager"
source $SCRIPTS/rbenv.sh
#######################################################################################
# git setup ###########################################################################
figlet_announces "act 2 - scene 1"
quoth_the_bard \
"MARIA: This and these pearls to me sent Longaville:
The letter is too long by half a mile.
PRINCESS OF FRANCE: I think no less. Dost thou not wish in heart
The chain were longer and the letter short?" \
"--Love's Labour Lost (V.ii)"
pause_awhile "Setting up Git for Version Control"
source $SCRIPTS/git.sh
#######################################################################################
# Apps ###############################################################################
figlet_announces "act 2 - scene 2"
quoth_the_bard \
"Lend me an arm; the rest have worn me out
With several applications..." \
"--All's Well That Ends Well (I.ii)"
pause_awhile "Installing applications for development"
source $SCRIPTS/apps.sh
#######################################################################################
# Sublime setup #######################################################################
figlet_announces "act 2 - scene 3"
quoth_the_bard \
"Suit the action to the word, the word to the action,
with this special observance that you o'erstep not the modesty of nature." \
"--Hamlet (III.ii)"
pause_awhile "Configuring Sublime and Terminal"
source $SCRIPTS/sublime.sh
source $SCRIPTS/terminal.sh & # solarize terminal colors
#######################################################################################
# PJ STOPPED CHECKING HERE ...
# Gem setup ###########################################################################
figlet_announces "act 3 - scene 2"
quoth_the_bard \
"Making a couplement of proud compare,
With sun and moon, with earth and sea's rich gems,
With April's first-born flowers, and all things rare
That heaven's air in this huge rondure hems." \
"--Sonnet 21"
pause_awhile "Installing system gems"
source $SCRIPTS/gems.sh
#######################################################################################
# Install Postgres ####################################################################
figlet_announces "act 4 - scene 1"
quoth_the_bard \
"'Tis in my memory lock'd, And you yourself shall keep the key of it." \
"--Hamlet (I.iii)"
pause_awhile "Configuring Postgres"
source $SCRIPTS/postgres.sh
#######################################################################################
# Reload ##############################################################################
figlet_announces "act 4 - scene 2"
quoth_the_bard \
"Double, double toil and trouble; Fire burn, and caldron bubble." \
"--Macbeth (IV.i)"
# EPILOGUE
echo "Next we'll sure your SSH keys are setup."
source $SCRIPTS/github.sh
quoth_the_bard \
"Once more unto the breach, dear friends, once more;
Or close the wall up with our English dead." \
"--Henry V (III.i)"
pause_awhile "Let's run some checks to see how the install went"
source ~/.bash_profile
#######################################################################################
# checkpoints
source $SCRIPTS/checks.sh
welcome
source ~/.bash_profile
figlet_announces "fin"
echo "We're done"
echo "You may want to run brew doctor to ensure everything is working."
# - fin - #