-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_script
More file actions
executable file
·168 lines (141 loc) · 6.38 KB
/
Copy pathsetup_script
File metadata and controls
executable file
·168 lines (141 loc) · 6.38 KB
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
#!/usr/bin/env bash
###############################################################################
# ERROR: Let the user know if the script fails
###############################################################################
trap 'ret=$?; test $ret -ne 0 && printf "\n \e[31m\033[0m Install failed \e[31m\033[0m\n" >&2; exit $ret' EXIT
set -e
###############################################################################
# TWIRL: Check for required functions file
###############################################################################
if [ -e lib/setup/blotto ]; then
cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "lib/setup/blotto"
else
printf "\n ⚠️ ./blotto not found - oTTo loves to get blotto!\n"
exit 1
fi
###############################################################################
# CHECK: Bash version
###############################################################################
check_bash_version
printf "
_
│───────────────────────────────────────────────────│
│ Safe to run multiple times on the same machine. │
│ It ${green}installs${reset}, ${blue}upgrades${reset}, or ${yellow}skips${reset} packages based │
│ on what is already installed on the machine. │
╰───────────────────────────────────────────────────╯
${dim}$(get_os) $(get_os_version) ${normal} // ${dim}$BASH ${normal} // ${dim}$BASH_VERSION${reset}
"
###############################################################################
# CHECK: Internet
###############################################################################
chapter "Checking internet connection…"
check_internet_connection
###############################################################################
# PROMPT: Password
###############################################################################
chapter "Caching password…"
ask_for_sudo
###############################################################################
# PROMPT: SSH Key
###############################################################################
chapter 'Checking for SSH key…'
ssh_key_setup
###############################################################################
# INSTALL: Dependencies
###############################################################################
chapter "Installing Dependencies…"
# -----------------------------------------------------------------------------
# Homebrew
# -----------------------------------------------------------------------------
if ! [ -x "$(command -v brew)" ]; then
step "Installing Homebrew…"
curl -fsS 'https://raw.githubusercontent.com/Homebrew/install/master/install' | ruby
export PATH="/usr/local/bin:$PATH"
print_success "Homebrew installed!"
else
print_success_muted "Homebrew already installed. Skipping."
fi
if brew list | grep -Fq brew-cask; then
step "Uninstalling old Homebrew-Cask…"
brew uninstall --force brew-cask
print_success "Homebrew-Cask uninstalled!"
fi
# -----------------------------------------------------------------------------
# Ruby - Checking Ruby version
# -----------------------------------------------------------------------------
if [[ "$(command -v ruby)" != *"2.6.0"* ]]; then
print_warning "oTTo detected $(command -v ruby) as your system installed Ruby version"
print_warning "oTTo requires Ruby v2.6.0 to be installed at both system and RVM level."
if ask "Would you like to remove all older versions and install v2.6.0 to your system?" Y; then
print_in_yellow "Uninstalling old system version(s) of Ruby\n"
brew uninstall ruby
else
print_in_red "You have chosen to not remove older system versions of Ruby. This can cause issues between the system and RVM Ruby versions that might impact oTTo"
print_in_red "\nIf you find issues in running oTTo please rerun setup_script and choose to remove the older system versions of Ruby\n"
fi
else
print_success_muted "Correct Ruby version already installed. Skipping."
fi
# -----------------------------------------------------------------------------
# RVM
# -----------------------------------------------------------------------------
if [ -x rvm ]; then
step "Installing RVM with Ruby 2.6.0..."
curl -L https://get.rvm.io | bash -s stable --ruby
print_success "RVM installed!"
step "Installing 2.6.0 Ruby..."
rvm install 2.6.0
rvm --default use 2.6.0
rvm list
rvmv=$(rvm current)
print_success "Using Node $rvmv!"
else
print_success_muted "RVM and stable Ruby already installed. Skipping."
fi
###############################################################################
# INSTALL: brews
###############################################################################
if [ -e $cwd/dependencies/brews ]; then
chapter "Installing Homebrew formulae…"
for brew in $(<$cwd/dependencies/brews); do
install_brews $brew
done
fi
###############################################################################
# UPDATE: Homebrew
###############################################################################
chapter "Updating Homebrew formulae…"
brew update
###############################################################################
# INSTALL: casks
###############################################################################
if [ -e $cwd/dependencies/casks ]; then
chapter "Installing apps via Homebrew…"
for cask in $(<$cwd/dependencies/casks); do
install_application_via_brew $cask
done
fi
###############################################################################
# CLEAN: Homebrew files
###############################################################################
chapter "Cleaning up Homebrew files…"
brew cleanup
###############################################################################
# INSTALL: Gems
###############################################################################
if [ -e $cwd/Gemfile.lock ]; then
chapter "Updating Gemfile.lock"
bundle update
print_success "Gems updated"
else
chapter "Installing Gems"
bundle install
print_success "Gems installed"
fi
got_blotto
###############################################################################
# Much of this code is taken from Mina Markham's 'Formation' script
# https://github.com/minamarkham/formation. Credit is due to her!
###############################################################################