-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·354 lines (304 loc) · 13.8 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
#!/bin/bash
# Defines SO type
if echo $HOME | grep -q '/home' ; then
export MY_SO=Linux
elif echo $HOME | grep -q '/Users' ; then
export MY_SO=MacOS
elif echo $HOME | grep -q 'C:' ; then
export MY_SO=Windows
else
export MY_SO=Windows
fi
project="$HOME/Workspace/github/jonathanccalixto/dotfiles"
dotfiles="$HOME/.dotfiles"
profiles="$dotfiles/.profile.d"
# Updates dependencies
if [ $MY_SO = 'Linux' ]; then
echo "\033[0;32m## Updating \033[1;34mall package\033[0;37;00m"
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y
sudo apt autoclean -y
echo "\033[0;32m## \033[1;34mpackage\033[0;32m updated\033[0;37;00m"
fi
if [ $MY_SO = 'Linux' ]; then
# Installs build-essential
if [ -z `dpkg --list | grep build-essential` ]; then
echo "\033[0;32m## Installing \033[1;34mbuild-essential\033[0;37;00m"
sudo apt install -y build-essential
fi
echo "\033[0;32m## \033[1;34mbuild-essential\033[0;32m installed\033[0;37;00m"
elif [ $MY_SO = 'MacOS' ]; then
# Installs build-essential
if [ ! -d "/usr/local/Cellar" ]; then
echo "\033[0;32m## Installing \033[1;34mhomebrew\033[0;37;00m"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install wget htop
fi
echo "\033[0;32m## \033[1;34mhomebrew\033[0;32m installed\033[0;37;00m"
fi
# Installs git
if [ $MY_SO = 'Linux' ]; then
if [ -z `dpkg --list | grep git` ]; then
echo "\033[0;32m## Installing \033[1;34mgit\033[0;37;00m"
sudo apt install -y git
fi
echo "\033[0;32m## \033[1;34mgit\033[0;32m installed\033[0;37;00m"
elif [ $MY_SO = 'MacOS' ]; then
# Installs build-essential
if [ ! -x "$(which git)" ]; then
echo "\033[0;32m## Installing \033[1;34mgit\033[0;37;00m"
brew install git
fi
echo "\033[0;32m## \033[1;34mgit\033[0;32m installed\033[0;37;00m"
fi
# Imports project
if [ ! -d "$project/.git" ]; then
echo "\033[0;32m## Importing \033[1;34mdotfiles\033[0;32m project\033[0;37;00m"
git clone https://github.com/jonathanccalixto/dotfiles.git $project
fi
echo "\033[0;32m## \033[1;34mdotfiles\033[0;32m imported\033[0;37;00m"
# Makes shotcut to dotfiles folder in home path
if [ ! -d $dotfiles ]; then
echo "\033[0;32m## Linking \033[1;34mdotfiles\033[0;32m on \033[1;34m$HOME\033[0;37;00m"
ln -snfv $project $dotfiles
fi
echo "\033[0;32m## \033[1;34mdotfiles\033[0;32m linked on \033[1;34m$HOME\033[0;37;00m"
# Installs zsh
if [ $MY_SO = 'Linux' ]; then
if [ ! -x "$(which zsh)" ]; then
echo "\033[0;32m## Installing \033[1;34mzsh\033[0;37;00m"
sudo apt install -y zsh
fi
echo "\033[0;32m## \033[1;34mzsh\033[0;32m installed\033[0;37;00m"
fi
# Installs oh-my-zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
if [ $MY_SO = 'Linux' ]; then
if [ ! -x "$(which curl)" ]; then
echo "\033[0;32m#### Installing \033[1;34mcurl\033[0;37;00m"
sudo apt install -y curl
fi
echo "\033[0;32m#### \033[1;34mcurl\033[0;32m installed\033[0;37;00m"
fi
echo "\033[0;32m## Installing \033[1;34m.oh-my-zsh\033[0;37;00m"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
echo "\033[0;32m## \033[1;34m.oh-my-zsh\033[0;32m installed\033[0;37;00m"
# Installs spaceship theme
ZSH_THEMES="$HOME/.oh-my-zsh/custom/themes"
if [ ! -d "$ZSH_THEMES/spaceship-prompt" ]; then
echo "\033[0;32m## Importing \033[1;34mspaceship theme\033[0;32m project\033[0;37;00m"
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_THEMES/spaceship-prompt"
fi
echo "\033[0;32m## \033[1;34mspaceship theme\033[0;32m imported\033[0;37;00m"
# Configures spaceship theme
if [ ! -f "$ZSH_THEMES/spaceship.zsh-theme" ]; then
echo "\033[0;32m## Linking \033[1;34mspaceship theme\033[0;32m on \033[1;34m$ZSH_THEMES\033[0;37;00m"
ln -snfv "$ZSH_THEMES/spaceship-prompt/spaceship.zsh-theme" "$ZSH_THEMES/spaceship.zsh-theme"
fi
echo "\033[0;32m## \033[1;34mspaceship theme\033[0;32m linked on \033[1;34m$ZSH_THEMES\033[0;37;00m"
# Applies zsh
bash_applied=$(grep -i "if \[ -x /bin/zsh \]; then" $HOME/.bashrc)
if [ -z "$bash_applied" ]; then
echo "\033[0;32m## Setting \033[1;34mzsh\033[0;32m on \033[1;34m$HOME/.bashrc\033[0;37;00m"
echo "\nif [ -x /bin/zsh ]; then\n /bin/zsh && exit 0\nfi" >> $HOME/.bashrc
fi
echo "\033[0;32m## \033[1;34mzsh\033[0;32m setted on \033[1;34m$HOME/.bashrc\033[0;37;00m"
# Installs zinit (old zplugin)
if [ ! -d "$HOME/.zinit/bin" ]; then
# READ https://z-shell.pages.dev/docs/getting_started/installation
echo "\033[0;32m## Importing \033[1;34mZinit\033[0;32m project\033[0;37;00m"
git clone https://github.com/zdharma-continuum/zinit.git $HOME/.zinit/bin
fi
echo "\033[0;32m## \033[1;34mZinit\033[0;32m imported\033[0;37;00m"
# makes zshrc backup
zshrc=$HOME/.zshrc
if [ -f "$zshrc" ]; then
echo "\033[0;32m## Making \033[1;34mzshrc\033[0;32m backup\033[0;37;00m"
if [ ! -f "$zshrc.pre" ]; then
mv "$zshrc" "$zshrc.pre"
else
mv "$zshrc" "$zshrc.pre-$(date)"
fi
fi
echo "\033[0;32m## Backup of \033[1;34mzshrc\033[0;32m made\033[0;37;00m"
# Installs rbenv
RBENV="$HOME/.rbenv"
if [ ! -d $RBENV ]; then
# Donwloads project
echo "\033[0;32m## Importing \033[1;34mrbenv\033[0;32m project\033[0;37;00m"
git clone https://github.com/rbenv/rbenv.git $RBENV
echo "\033[0;32m## \033[1;34mrbenv\033[0;32m imported\033[0;37;00m"
# Tries to compile dynamic bash extension to speed up rbenv.
echo "\033[0;32m## Configuring \033[1;34mrbenv\033[0;32m\033[0;37;00m"
cd $RBENV && src/configure && make -C src && cd -
echo "\033[0;32m## \033[1;34mrbenv\033[0;32m configured\033[0;37;00m"
# Defines plugin path
RPLUGINS="$RBENV/plugins"
# Adds rbenvs's plugins
if [ ! -d $RPLUGINS ]; then
mkdir -p $RPLUGINS
fi
if [ ! -d "$RPLUGINS/ruby-build" ]; then
echo "\033[0;32m## Importing \033[1;34mruby-build\033[0;32m project\033[0;37;00m"
git clone https://github.com/rbenv/ruby-build.git "$RPLUGINS/ruby-build"
fi
echo "\033[0;32m## \033[1;34mruby-build\033[0;32m imported\033[0;37;00m"
# Verifies that rbenv is properly set up using this rbenv-doctor script
echo "\033[0;32m## Checking \033[1;34mrbenv\033[0;32m status\033[0;37;00m"
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
echo "\033[0;32m## \033[1;34mrbenv\033[0;32m cheked\033[0;37;00m"
fi
echo "\033[0;32m## \033[1;34mrbenv\033[0;32m installed\033[0;37;00m"
# Installs pyenv
PYENV="$HOME/.pyenv"
if [ ! -d $PYENV ]; then
# Donwloads project
echo "\033[0;32m## Importing \033[1;py\033[0;32m project\033[0;37;00m"
git clone https://github.com/pyenv/pyenv.git $PYENV
echo "\033[0;32m## \033[1;34mpyenv\033[0;32m imported\033[0;37;00m"
# Tries to compile dynamic bash extension to speed up pyenv.
echo "\033[0;32m## Configuring \033[1;34mpyenv\033[0;32m\033[0;37;00m"
cd $PYENV && src/configure && make -C src && cd -
echo "\033[0;32m## \033[1;34mpyenv\033[0;32m configured\033[0;37;00m"
# Defines plugin path
PPLUGINS="$PYENV/plugins"
# Adds pyenvs's plugins
if [ ! -d $PPLUGINS ]; then
mkdir -p $PPLUGINS
fi
if [ -d "$PPLUGINS/python-build" ]; then
echo "\033[0;32m## Importing \033[1;34mpython-build\033[0;32m project\033[0;37;00m"
./install.sh
fi
echo "\033[0;32m## \033[1;34mpython-build\033[0;32m imported\033[0;37;00m"
# Verifies that pyenv is properly set up using this pyenv-doctor script
echo "\033[0;32m## Checking \033[1;34mpyenv\033[0;32m status\033[0;37;00m"
git clone https://github.com/pyenv/pyenv-doctor.git "$PPLUGINS/pyenv-doctor"
pyenv doctor
echo "\033[0;32m## \033[1;34mpyenv\033[0;32m cheked\033[0;37;00m"
fi
echo "\033[0;32m## \033[1;34mpyenv\033[0;32m installed\033[0;37;00m"
# Installs ruby and python dependencies
if [ $MY_SO = 'Linux' ]; then
if [ -z `dpkg --list | grep libxml2-dev` ]; then
echo "\033[0;32m## Installing \033[1;34mruby and python dependencies\033[0;37;00m"
sudo apt install -y libbz2-dev libcurl4-openssl-dev libffi-dev liblzma-dev \
libncursesw5-dev libreadline-dev libsqlite3-dev libssl-dev \
libxml2-dev libxml2-dev libxmlsec1-dev libxslt1-dev \
libyaml-dev software-properties-common tk-dev xz-utils \
zlib1g-dev
fi
echo "\033[0;32m## \033[1;34mruby and python dependencies\033[0;32m installed\033[0;37;00m"
elif [ $MY_SO = 'MacOS' ]; then
if [ -z `brew list | grep libxml2` ]; then
echo "\033[0;32m## Installing \033[1;34mruby and python dependencies\033[0;37;00m"
brew install coreutils libxml2 libyaml openssl qt readline sqlite3 tcl-tk xz zlib
fi
echo "\033[0;32m## \033[1;34mruby and python dependencies\033[0;32m installed\033[0;37;00m"
fi
# Installs nvm
export NVM_DIR="$HOME/.nvm"
if [ ! -d "$NVM_DIR" ]; then
echo "\033[0;32m## Installing \033[1;34mnvm\033[0;32m\033[0;37;00m"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
fi
echo "\033[0;32m## \033[1;34mnvm\033[0;32m installed\033[0;37;00m"
# Installs docker
if [ $MY_SO = 'Linux' ]; then
if [ ! -x `which docker` ]; then
# Donwloads project
echo "\033[0;32m## Installing \033[1;34mdocker dependecies\033[0;37;00m"
sudo apt install -y apt-transport-https ca-certificates\
curl gnupg-agent software-properties-common
echo "\033[0;32m## \033[1;34mdocker dependencies\033[0;32m installed\033[0;37;00m"
echo "\033[0;32m## Adding \033[1;34mdocker gpg key\033[0;37;00m"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -f -
sudo apt-key fingerprint 0EBFCD88
echo "\033[0;32m## \033[1;34mdocker gpg key\033[0;32m added\033[0;37;00m"
echo "\033[0;32m## Adding \033[1;34mdocker respository\033[0;37;00m"
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
echo "\033[0;32m## \033[1;34mdocker respository\033[0;32m added\033[0;37;00m"
echo "\033[0;32m## Installing \033[1;34mdocker\033[0;37;00m"
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
echo "\033[0;32m## \033[1;34mdocker\033[0;32m installed\033[0;37;00m"
echo "\033[0;32m## Configuring \033[1;34mdocker user\033[0;37;00m"
sudo usermod -aG docker $USER
echo "\033[0;32m## \033[1;34mdocker user\033[0;32m configured\033[0;37;00m"
fi
echo "\033[0;32m## \033[1;34mdocker\033[0;32m installed\033[0;37;00m"
# Installs docker-compose
echo "\033[0;32m## Installing \033[1;34mdocker-compose\033[0;37;00m"
if [ ! -x `which docker` ]; then
echo "\033[0;32m## Downloading \033[1;34mdocker-compose\033[0;37;00m"
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
echo "\033[0;32m## \033[1;34mdocker-compose\033[0;32m downloaded\033[0;37;00m"
echo "\033[0;32m## Configuring permission for \033[1;34mdocker-compose\033[0;37;00m"
sudo chmod +x /usr/local/bin/docker-compose
echo "\033[0;32m## \033[1;34mdocker-compose\033[0;32m persmissions configured\033[0;37;00m"
echo "\033[0;32m## Linking \033[1;34mdocker-compose\033[0;37;00m"
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo "\033[0;32m## \033[1;34mdocker-compose\033[0;32m linked\033[0;37;00m"
fi
echo "\033[0;32m## \033[1;34mdocker\033[0;32m installed\033[0;37;00m"
# Installs docker-machine
echo "\033[0;32m## Installing \033[1;34mdocker-machine\033[0;37;00m"
if [ ! -x `which docker` ]; then
echo "\033[0;32m## Making \033[1;34mdocker-machine\033[0;32m base variable\033[0;37;00m"
base=https://github.com/docker/machine/releases/download/v0.16.2
echo "\033[0;32m## \033[1;34mdocker-machine\033[0;32m variable made\033[0;37;00m"
echo "\033[0;32m## Downloading \033[1;34mdocker-machine\033[0;37;00m"
sudo curl -L "$base/docker-machine-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-machine
echo "\033[0;32m## \033[1;34mdocker-machine\033[0;32m downloaded\033[0;37;00m"
echo "\033[0;32m## Configuring permission for \033[1;34mdocker-machine\033[0;37;00m"
sudo chmod +x /usr/local/bin/docker-machine
echo "\033[0;32m## \033[1;34mdocker-machine\033[0;32m persmissions configured\033[0;37;00m"
echo "\033[0;32m## Linking \033[1;34mdocker-machine\033[0;37;00m"
sudo ln -s /usr/local/bin/docker-machine /usr/bin/docker-machine
echo "\033[0;32m## \033[1;34mdocker-machine\033[0;32m linked\033[0;37;00m"
fi
echo "\033[0;32m## \033[1;34mdocker-machine\033[0;32m installed\033[0;37;00m"
fi
# Installs gpg
if [ $MY_SO = "MacOS" ]; then
if [ -z `brew list | grep gpg` ]; then
echo "\033[0;32m## Installing \033[1;34mGPG\033[0;37;00m"
brew install gpg2 gnupg pinentry-mac
fi
echo "\033[0;32m## \033[1;34mGPG\033[0;32m installed\033[0;37;00m"
fi
# Installs java
if [ $MY_SO = 'Linux' ]; then
if [ ! -d /usr/lib/jvm/java-8-openjdk-amd64 ]; then
echo "\033[0;32m## Installing \033[1;34mjava 8\033[0;37;00m"
sudo apt install -y openjdk-8-jdk
fi
echo "\033[0;32m## \033[1;34mjava 8\033[0;32m installed\033[0;37;00m"
fi
# Installs graphic libs
if [ $MY_SO = 'Linux' ]; then
if [ -z `dpkg --list | grep gcc-multilib` ]; then
echo "\033[0;32m## Installing \033[1;34mAndroid graphic libs\033[0;37;00m"
sudo apt install -y gcc-multilib lib32z1 lib32stdc++6
fi
echo "\033[0;32m## \033[1;34mAndroid graphic libs\033[0;32m installed\033[0;37;00m"
fi
echo "" > $dotfiles/dotfiles.d/gitconfig
echo "\033[0;32m## \033[1;34mgitconfig\033[0;32m made\033[0;37;00m"
# Makes shortcut to dotfiles
for original_file in `find $dotfiles/dotfiles.d/* -maxdepth 1 | sort`; do
file=".`basename $original_file`"
dotfile="$HOME/$file"
if [ ! -f $dotfile ]; then
echo "### Makes link to \033[1;34m$file\033[0;37;00m.";
ln -snfv $original_file $dotfile
else
echo "### Link to \033[1;34m$file\033[0;37;00m already made.";
fi
done
# ln -snfv dotfiles/bin/git-publish-branch bin/
# Performs zsh on finish instalation
/bin/zsh && exit 0