-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·339 lines (304 loc) · 10.8 KB
/
deploy.sh
File metadata and controls
executable file
·339 lines (304 loc) · 10.8 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
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
#!/bin/bash
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' ERR
CUR_FOLDER=$(pwd)
macstr="Darwin"
linuxstr="Linux"
ret=
cat .git/config | grep -i "/dotfiles" > /dev/null
if [ "$?" != "0" ]; then
echo "Please launch $0 from the dotfile git folder root"
exit -1
fi
echo "WARNING deploy script will:"
echo " - create the following symbolic links in ${HOME} (existing links won't be overwritten):"
echo " dotfiles"
echo " .bashrc"
echo " .zshrc"
echo " .vim"
echo " .vimrc"
echo " .inputrc"
if [ "$(uname)" == "$macstr" ]; then
echo " - install brew if not already installed"
echo " - install up-to-date bash if current version is 3.* (brew version)"
echo " - install gvim if not already installed (brew version)"
echo " => This is my custom gvim setup, it installs plugins and some keys F1:F9 are predefined to do some actions, see vim/vimrc"
echo " - install iTerm2 if not already installed (brew version)"
echo " => Terminal, https://iterm2.com"
echo " - install rectangle if not already installed (brew version)"
echo " => Windows management, https://rectangleapp.com"
echo " - install aws cli v2 if not already installed"
echo " => Aws cli, https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html"
echo " - install pyenv"
echo " => Python management, https://github.com/pyenv/pyenv"
echo " - install pyenv virtualenv"
echo " => Python management, https://github.com/pyenv/pyenv-virtualenv"
echo " - install pyenv python"
echo " - install rbenv"
echo " => Ruby management, https://github.com/rbenv/rbenv"
echo " - install npm"
echo " - install/update screen if version is too old"
echo " - install ctags if not already installed (brew version)"
echo " - launch locate service"
else
echo
echo " - WARNING - created for MAC OS, need to add the apt-get install for linux"
echo
fi
read -n1 -r -p "Press a key to continue..." key
mkdir -p ~/.historylogs
if [ "$(uname)" == "${macstr}" ]; then
if [ $(which brew) ]; then
ret="${ret}\nbrew already installed, ignore"
else
echo "install brew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [ "$(uname -m)" != "x86_64" ]; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ${HOME}/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ${HOME}/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"
else
echo 'eval "$(/usr/local/Homebrew/bin/brew shellenv)"' >> ${HOME}/.zprofile
echo 'eval "$(/usr/local/Homebrew/brew shellenv)"' >> ${HOME}/.bash_profile
eval "$(/usr/local/Homebrew/bin/brew shellenv)"
fi
fi
if [ $(which git) ]; then
ret="${ret}\ngit already installed, ignore"
else
echo "install git"
brew install git
fi
if [ $(which wget) ]; then
ret="${ret}\nwget already installed, ignore"
else
echo "install wget"
brew install wget
fi
tmp=$(bash --version | grep 'version 3\.' || :)
if [ "$tmp" == "" ]; then
ret="${ret}\nbash at version $(bash --version | head -n1), ignore"
else
echo "install bash (brew version)"
brew install bash
ret="${ret}\n!!!! bash installed, version: $(bash --version)"
fi
if [ -e /usr/local/bin/ctags ]; then
ret="${ret}\ngit already installed, ignore"
else
echo "install ctags"
brew install ctags
fi
if [ ! -e /Applications/iTerm.app ]; then
echo "install iTerm2"
brew install Caskroom/cask/iterm2
else
ret="${ret}\niTerm2 already exist, ignore"
fi
if [ ! -e /Applications/Rectangle.app ]; then
echo "install rectangle"
brew install --cask rectangle
else
ret="${ret}\nRectangle already exist, ignore"
fi
if [ $(which screen) ]; then
screen_ver=$(screen --version 2>&1 | grep -oE '[0-9]+\.[0-9]+' | head -1)
if [ "$(printf '%s\n' "4.06" "$screen_ver" | sort -V | head -1)" = "4.06" ]; then
ret="${ret}\nscreen at version ${screen_ver}, ignore"
else
echo "install screen (current version ${screen_ver} is too old)"
brew install screen
fi
else
echo "install screen"
brew install screen
fi
if [ $(which gvim) ]; then
ret="${ret}\nmacvim(gvim) already installed, ignore"
else
echo "install macvim"
brew install macvim
fi
# if [ -e /Applications/Karabiner.app ]; then
# ret="${ret}\nkarabiner already installed, ignore"
# else
# echo "install karabiner"
# brew install Caskroom/cask/karabiner
# fi
if [ $(which aws) ]; then
ret="${ret}\naws already installed, ignore"
else
echo "install aws"
wget https://awscli.amazonaws.com/AWSCLIV2.pkg -O /tmp/awscliv2.pkg
sudo installer -pkg /tmp/awscliv2.pkg -target /
fi
if [ $(which npm) ]; then
ret="${ret}\nnpm already installed, ignore"
else
echo "install npm"
brew install npm
fi
if [ $(which aws-azure-login) ]; then
ret="${ret}\aws-azure-login already installed, ignore"
else
echo "install aws-azure-login"
npm install -g aws-azure-login
fi
if [ $(which gtimeout) ]; then
ret="${ret}\ngtimeout already installed, ignore"
else
echo "install coreutils"
brew install coreutils
fi
fi
if [ "$(uname)" == "${linuxstr}" ]; then
if [ $(which git) ]; then
ret="${ret}\ngit already installed, ignore"
else
echo "install git"
sudo apt-get install -y git
fi
tmp=$(bash --version | grep 'version 3\.')
if [ "$tmp" == "" ]; then
ret="${ret}\nbash at version $(bash --version), ignore"
else
echo "do something for bash ?"
fi
#if [ -e /usr/local/bin/ctags ]; then
# ret="${ret}\nctags already installed, ignore"
#else
# echo "do something for ctags ?"
# sudo apt-get install exuberant-ctags
# if [ -e /usr/bin/ctags ]; then
# sudo ln -s /usr/bin/ctags /usr/local/bin/ctags
# fi
#fi
if [ $(which gvim) ]; then
ret="${ret}\ngvim already installed, ignore"
else
echo "install vim"
sudo apt-get install -y vim-gnome
fi
echo 'Installing build essentials and other packages.'
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
fi
if [ ! -d ~/.oh-my-zsh ]; then
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O /tmp/ohmyzsh_install.sh
sh /tmp/ohmyzsh_install.sh --unattended
ln -s ${HOME}/dotfiles/omzsh/themes/cedric.zsh-theme ${HOME}/.oh-my-zsh/themes/cedric.zsh-theme
else
ret="${ret}\noh-my-zsh already installed, ignore"
fi
if [ ! -e ~/dotfiles ]; then
echo "Current folder not in ${HOME}, create symbolic link"
ln -sf ${CUR_FOLDER} ~/dotfiles
else
ret="${ret}\n~/dotfiles already exist, ignore"
fi
if [ ! -e ~/.bashrc ]; then
echo 'deploy bashrc'
ln -sf ${CUR_FOLDER}/rcfiles/bashrc ~/.bashrc
else
ret="${ret}\n~/.bashrc already exist, ignore"
fi
if [ ! -e ~/.zshrc ]; then
echo 'deploy zshrc'
ln -sf ${CUR_FOLDER}/rcfiles/zshrc ~/.zshrc
else
ret="${ret}\n~/.zshrc already exist, ignore"
fi
if [ ! -e ~/.vim ]; then
echo 'deploy vim/'
mkdir -p ${CUR_FOLDER}/vim/vim
ln -sf ${CUR_FOLDER}/vim/vim/ ~/.vim
else
ret="${ret}\n~/.vim already exist, ignore"
fi
if [ ! -e ~/.vimrc ]; then
echo 'deploy vimrc'
ln -sf ${CUR_FOLDER}/vim/vimrc ~/.vimrc
else
ret="${ret}\n~/.vimrc already exist, ignore"
fi
if [ ! -e ~/.inputrc ]; then
echo 'deploy inputrc'
ln -sf ${CUR_FOLDER}/rcfiles/inputrc ~/.inputrc
else
ret="${ret}\n~/.inputrc already exist, ignore"
fi
if [ ! -e ~/.gitignore ]; then
echo 'deploy gitignore'
ln -sf ${CUR_FOLDER}/gitignore ~/.gitignore
else
ret="${ret}\n~/.gitignore already exist, ignore"
ret="${ret}\n maybe check if $(pwd)/gitignore and ~/.gitignore can be merged, and a symbolic link created"
fi
if [ ! -e ~/.pyenvrc ]; then
echo 'deploy pyenvrc'
ln -sf ${CUR_FOLDER}/rcfiles/pyenvrc ~/.pyenvrc
else
ret="${ret}\n~/.pyenvrc already exist, ignore"
fi
if [ ! -e pyenv ]; then
echo "clone pyenv"
git clone https://github.com/pyenv/pyenv.git pyenv
ln -sf ${CUR_FOLDER}/pyenv ~/.pyenv
else
ret="${ret}\npyenv already present, ignore"
fi
if [ ! -e pyenv/plugins/pyenv-virtualenv ]; then
echo "clone pyenv-virtualenv"
git clone https://github.com/pyenv/pyenv-virtualenv.git pyenv/plugins/pyenv-virtualenv
else
ret="${ret}\npyenv/plugins/virtualenv already present, ignore"
fi
if [ ! -d pyenv/versions ] || [ "$(ls pyenv/versions/ | wc -l |tr -d '[:space:]')" == "0" ]; then
echo "Install a pyenv python"
source ~/.pyenvrc
pyenv install -l
read -p "Please enter version to install (will take a few min, press enter to skip): " PYENV_PROMPT
if [ -z $PYENV_PROMPT ]; then
echo "do not install a python version"
ret="${ret}\nSkip installation of a pyenv python"
else
echo "Installing ${PYENV_PROMPT}"
pyenv install ${PYENV_PROMPT}
fi
else
ret="${ret}\na python already present in ~/.pyenv/versions/, ignore"
fi
if [ ! -d rbenv ]; then
echo "clone rbenv"
git clone https://github.com/rbenv/rbenv.git
ln -sf ${CUR_FOLDER}/rbenv ~/.rbenv
else
ret="${ret}\nrbenv already present, ignore"
fi
if [ ! -d rbenv/plugins/ruby-build ]; then
echo "clone rbenv"
git clone https://github.com/rbenv/ruby-build.git rbenv/plugins/ruby-build
else
ret="${ret}\nrbenv/plugins/ruby-build already present, ignore"
fi
if [ "$(uname)" == "$macstr" ] && [ ! -f /tmp/locate_launched ]; then
cmd="sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist"
echo "Start locate service (need sudo)."
echo " ${cmd}"
${cmd}
touch /tmp/locate_launched
fi
#see http://caiustheory.com/git-git-git-git-git/
#ignore multiple git :)
git config --global alias.git '!exec git'
rm -f ~/.brewupdatedate
printf "$ret\n"
echo ""
echo ""
echo "WARNING, current deployement is using my oh-my-zsh template, ${HOME}/.oh-my-zsh/themes/cedric.zsh-theme."
echo "it invokes the git plugin, which creates lots of aliases for git"
echo "see: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh"
echo "you might want to check if ~/.zshrc points correctly to the ~/dotfiles/rcfiles/zshrc and if not redo it, else if you are here, All Good!"