-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·217 lines (170 loc) · 5.51 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
#!/usr/bin/env bash
set -e
if ! which realpath > /dev/null 2>&1; then
# OSX dirty replacement for `realpath`
realpath() {
[[ $1 == /* ]] && echo "$1" || echo "$PWD/${1#./}"
}
fi
source "$(dirname "$(realpath "${BASH_SOURCE[0]}")")/common.sh"
is_force=false
for arg in "$@"; do
case $arg in
-f)
is_force=true
;;
esac
done
if is_osx; then
# Install brew
if ! which brew > /dev/null 2>&1; then
title1 "Install brew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo ""
fi
# Install brew formulas
if which brew > /dev/null 2>&1; then
title1 "Install brew formulas"
for formula in \
"coreutils" \
"zsh" \
"tmux" \
"htop" \
"tree" \
"wget" \
"jq" \
"cmake" \
"llvm" \
"node" \
"imagemagick" \
"bat" \
"go" \
"dep" \
"ansible" \
"fd" \
"lf" \
"exa" \
"fzf" \
"koekeishiya/formulae/skhd" \
"koekeishiya/formulae/yabai"; do
if ! brew ls --versions "$formula" > /dev/null 2>&1; then
brew install "$formula"
ok "$(blue "$formula") has installed ($(gray "$(brew ls --versions "$formula")"))"
else
ok "$(blue "$formula") is already installed ($(gray "$(brew ls --versions "$formula")"))"
fi
done
echo ""
fi
# Install brew casks
if which brew > /dev/null 2>&1; then
title1 "Install brew casks"
for cask in \
"iterm2" \
"docker" \
"telegram" \
"alfred" \
"zaplin" \
"alacritty"; do
if ! brew cask ls --versions "$cask" > /dev/null 2>&1; then
brew cask install "$cask"
ok "$(blue "$cask") has installed ($(gray "$(brew cask ls --versions "$cask")"))"
else
ok "$(blue "$cask") is already installed ($(gray "$(brew cask ls --versions "$cask")"))"
fi
done
echo ""
fi
# Start brew services
if which brew > /dev/null 2>&1; then
title1 "Start brew services"
for service in \
"skhd" \
"yabai"; do
if [ "$(brew services list | grep '^'"$service"' ' | awk '{ print $2 }')" != "started" ]; then
brew services start "$service"
ok "$(blue "$service") service has started"
else
ok "$(blue "$service") service is already started"
fi
done
fi
fi
if is_linux; then
# Retrieve new lists of packages
if is_ubuntu; then
title1 "Retrieve new lists of packages"
apt-get update
echo ""
fi
# Install packages
if is_ubuntu; then
title1 "Install packages"
for package in "jq"; do
# if ! brew ls --versions "$formula" > /dev/null 2>&1; then
if ! dpkg -l "$package" 2>&1 > /dev/null 2>&1; then
apt-get install -y jq
ok "$(blue "$package") has installed"
else
ok "$(blue "$package") is already installed"
fi
done
echo ""
fi
# Install 1Password CLI
# See: https://1password.com/downloads/command-line/
title1 "Install 1Password CLI"
tmpdir="$(mktemp -d)"
if is_x86_64; then
curl -Ls "https://cache.agilebits.com/dist/1P/op/pkg/v0.9.2/op_linux_amd64_v0.9.2.zip" -o "$tmpdir/op.zip"
unzip -o "$tmpdir/op.zip" -d "$tmpdir/op"
cp "$tmpdir/op/op" /usr/local/bin/op
ok "$(blue "op") has installed"
else
error "Installing 1Password CLI for $(blue "$(uname -m)") is not implemented"
fi
rm -rf "$tmpdir"
echo ""
# Install Terraform
# See: https://www.terraform.io/downloads.html
title1 "Install Terraform"
tmpdir="$(mktemp -d)"
if is_x86_64; then
curl -Ls "https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip" -o "$tmpdir/terraform.zip"
unzip -o "$tmpdir/terraform.zip" -d "$tmpdir/terraform"
cp "$tmpdir/terraform/terraform" /usr/local/bin/terraform
ok "$(blue "terraform") has installed"
else
error "Installing Terraform for $(blue "$(uname -m)") is not implemented"
fi
rm -rf "$tmpdir"
echo ""
fi
# Install NPM packages
title1 "Install NPM packages"
for package in "node-gyp" "node-static" "uuid" "prettier" "ramda-cli"; do
if ! npm list "$package" -g --depth 0 > /dev/null 2>&1 || [[ "$(npm list "$package" -g --depth 0 --json | jq ".dependencies.\"${package}\".version" -r > /dev/null)" -ne "null" ]]; then
npm install -g "$package"
ok "$(blue "$package") has installed ($(gray "$(npm list "$package" -g --depth 0 --json | jq ".dependencies.\"${package}\".version" -r)"))"
else
ok "$(blue "$package") is already installed ($(gray "$(npm list "$package" -g --depth 0 --json | jq ".dependencies.\"${package}\".version" -r)"))"
fi
done
echo ""
# Install modules
title1 "Install modules"
for module in *; do
if [ -f "$module" ]; then
continue
fi
if [ ! -f "$module/install.sh" ]; then
continue
fi
title2 "Install $module"
if [[ $is_force == true ]]; then
"$module/install.sh" -f
else
"$module/install.sh"
fi
echo ""
done