-
Notifications
You must be signed in to change notification settings - Fork 6
/
install-ubuntu.sh
executable file
·503 lines (413 loc) · 14.6 KB
/
install-ubuntu.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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
#!/usr/bin/env bash
set -e
GO_VERSION="1.13"
BOSH_VERSION="6.1.1" # SMT - was version 5.4.0
NODE_VERSION="10" # SMT - was version 8
GOLANGCI_LINT_VERSION="v1.21.0" # SMT - subsequent versions bring in new linters that we're not ready for
GODEP_VERSION="v0.5.4"
report() {
echo
echo "++ $1"
echo
}
# Update / Upgrade apt packages
report "Updating apt packages"
sudo apt update
report "Upgrading Linux distribution"
sudo apt dist-upgrade -y
# Install system dependencies
report "Installing system dependencies"
sudo apt install -y \
bash-completion \
curl \
fasd \
gnome-tweak-tool \
htop \
moreutils \
openssh-server \
shellcheck \
snapd \
software-properties-common \
tilix \
tldr \
tree
# Humans need NeoVim
sudo add-apt-repository -y ppa:neovim-ppa/unstable
sudo apt install neovim
# NeoVim needs node
if [[ -z $(which node) ]]; then
report "Setting up binary distribution of NodeJS for apt installation"
# From https://github.com/nodesource/distributions#installation-instructions
curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | sudo bash - # For Ubuntu LTS
# From https://node.melroy.org/
# curl -sL https://node.melroy.org/deb/setup_$NODE_VERSION.x | sudo bash - # For Mint 19.2
fi
if [[ -z $(which fd) ]]; then
report "Installing fd-find to satisfy neovim dependency"
curl -L https://github.com/sharkdp/fd/releases/download/v8.1.1/fd-musl_8.1.1_amd64.deb -o /tmp/fd_amd64.deb
sudo dpkg -i /tmp/fd_amd64.deb
rm /tmp/fd_amd64.deb
fi
# Install development dependencies
report "Installing development dependencies"
sudo apt install -y \
awscli \
direnv \
exuberant-ctags \
git \
jq \
neovim \
net-tools \
nodejs \
python3-pip \
python3-setuptools \
ruby2.5 \
ruby-dev \
silversearcher-ag \
tig \
tmux \
yarn # Required for neovim
# Install silly messaging utilities
report "Installing silly messaging utilities"
sudo apt install -y \
cowsay \
figlet
# Clean up apt cache
report "Cleaning up apt cache"
sudo apt autoremove -y
sudo apt autoclean
# if [[ -z $(which goland) ]]; then
# report "Installing GoLand"
# sudo snap install goland --classic
# else
# report "Updating Goland"
# sudo snap refresh goland
# fi
if [[ -z $(which code) ]]; then
report "Installing VS Code"
sudo snap install code --classic
else
report "Updating VS Code"
sudo snap refresh code
fi
## SMT - why do we want a floppy drive?
# function install_fd() {
#
# FD_VERSION="7.3.0"
# FD_FILENAME="fd-musl_${FD_VERSION}_amd64.deb"
# FD_URL="https://github.com/sharkdp/fd/releases/download/v${FD_VERSION}/${FD_FILENAME}"
#
# echo "Installing fd version $FD_VERSION"
#
# pushd "$(mktemp -d)"
# wget "$FD_URL"
# sudo dpkg -i "$FD_FILENAME"
# popd
# }
#
# $(fd -h | grep 'fd 7.3.0') || install_fd
## SMT - why do we want to control the drivers in our software setup script?
# Install system drivers
# sudo ubuntu-drivers autoinstall
# Set tilix as the default terminal
report "Setting 'tilix' as the default terminal"
sudo update-alternatives --set x-terminal-emulator /usr/bin/tilix.wrapper
# Install fly
if [[ ! -x $HOME/bin/fly ]]; then
report "Installing fly"
mkdir -p $HOME/bin
curl "https://ci.cli.fun/api/v1/cli?arch=amd64&platform=linux" > $HOME/bin/fly
chmod 755 $HOME/bin/fly
else
report "Skipping installation of fly: already present"
fi
# symlink neovim as `vim` and `vi` so that it's used everywhere
report "Making nvim the one true nvim/vim/vi"
ln -sf /usr/bin/nvim $HOME/bin/vim
ln -sf /usr/bin/nvim $HOME/bin/vi
# Install diff-so-fancy for better diffing in git
if [[ -z $(which diff-so-fancy) ]]; then
report "Installing diff-so-fancy for better git diffs"
sudo npm install -g diff-so-fancy
else
report "Updating diff-so-fancy for better git diffs"
sudo npm upgrade -g diff-so-fancy
fi
# Install lastpass-cli from source (the Ubuntu package is broken)
report "Installing lastpass-cli from source"
if [[ ! -d ~/workspace/lastpass-cli ]]; then
pushd ~/workspace
git clone https://github.com/lastpass/lastpass-cli.git
popd
fi
pushd ~/workspace/lastpass-cli
sudo apt install -y openssl libcurl4-openssl-dev libxml2 libssl-dev libxml2-dev pinentry-curses xclip cmake build-essential pkg-config
git pull
cmake .
make
sudo make install
popd
# SMT TODO: handle git ssh somehow
# Setup Workspace
report "Cloning repos into workspace"
mkdir -p $HOME/workspace
clone_into_workspace() {
repo="$1"
shift 1
DIR="${HOME}/workspace/$(echo "$repo" | awk -F '/' '{ print $(NF) }')"
if [[ ! -d $DIR ]]; then
git clone --recurse-submodules "$repo" "$DIR" "$@"
else
cd "$DIR"
git init
fi
}
WORKSPACE_GIT_REPOS=(
$SSH_REPO_SCHEME:bosh-packages/cf-cli-release
$SSH_REPO_SCHEME:cloudfoundry/capi-workspace
$SSH_REPO_SCHEME:cloudfoundry/cf-deployment
$SSH_REPO_SCHEME:cloudfoundry/claw
$SSH_REPO_SCHEME:cloudfoundry/cli-ci
$SSH_REPO_SCHEME:cloudfoundry/cli-docs-scripts
$SSH_REPO_SCHEME:cloudfoundry/cli-i18n
$SSH_REPO_SCHEME:cloudfoundry/cli-pools
$SSH_REPO_SCHEME:cloudfoundry/cli-private
$SSH_REPO_SCHEME:cloudfoundry/cli-workstation
$SSH_REPO_SCHEME:cloudfoundry/homebrew-tap
$SSH_REPO_SCHEME:concourse/concourse-bosh-deployment
$SSH_REPO_SCHEME:pivotal-legacy/pivotal_ide_prefs
$SSH_REPO_SCHEME:cloudfoundry/cli-ci
)
for repo in "${WORKSPACE_GIT_REPOS[@]}"; do
clone_into_workspace "$repo"
done
# Install fancier fonts with glyphs
if [[ ! -d $HOME/.local/share/fonts/NerdFonts ]]; then
installDateTime=$(date '+%Y%m%d-%H%M%S')
report "Installing NerdFonts -- See /tmp/nerdFontsInstallReport1-$installDateTime for details"
clone_into_workspace https://github.com/ryanoasis/nerd-fonts --depth 1
pushd "$HOME/workspace/nerd-fonts"
# This is a lengthy process that the rest of the script doesn't rely on, so run in background
./install.sh 2>&1 > /tmp/nerdFontsInstallReport1-$installDateTime.txt &
popd
else
report "Skipping installation of existing NerdFonts"
fi
# After cloning the pivotal_ide_prefs repository
# Change the keymap for GoLand to "Mac OS X 10.5"
sed -i 's/Pivotal Goland/Mac OS X 10.5+/' ~/workspace/pivotal_ide_prefs/pref_sources/Goland/options/keymap.xml
pushd "$HOME/workspace/pivotal_ide_prefs"
cli/bin/ide_prefs install --ide=goland --user-prefs-location="$HOME/.GoLand2019.1/config/"
popd
# install cli tab completion
report "Installing cli tab completion"
sudo ln -sf ${GOPATH}/src/code.cloudfoundry.org/cli/ci/installers/completion/cf /usr/share/bash-completion/completions
report "Installing BashIT"
if [[ ! -d $HOME/.bash_it ]]; then
git clone https://github.com/Bash-it/bash-it.git $HOME/.bash_it
$HOME/.bash_it/install.sh --silent
fi
report "Installing FZF"
if [[ ! -d $HOME/.fzf ]]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
$HOME/.fzf/install --all
fi
# These are pulled directly from our current (2019/02/28) ~/.bashrc
# This is because ~/.bashrc's are difficult to source from a script
# https://askubuntu.com/a/77053
# Also, it is currently unknown why sourcing bash_it.sh requires set +e.
export BASH_IT="$HOME/.bash_it"
export BASH_IT_THEME="$HOME/workspace/cli-workstation/dotfiles/bashit_custom_themes/cli.theme.bash"
sed -i "s#\(export BASH_IT_THEME='\).*'#\1$BASH_IT_THEME'#" $HOME/.bashrc
set +e
source "$BASH_IT"/bash_it.sh
bash-it update
set -e
# Configure BashIT
# report "Configuring BashIT"
# bash-it disable alias general git
# bash-it enable completion defaults awscli bash-it brew git ssh tmux virtualbox
# bash-it disable plugin fasd
# bash-it enable plugin fzf git git-subrepo ssh history
# Link Dotfiles
report "Creating dotfile symlinks"
ln -sf $HOME/workspace/cli-workstation/dotfiles/bashit_custom/* $HOME/.bash_it/custom
ln -sf $HOME/workspace/cli-workstation/dotfiles/bashit_custom_themes/* $HOME/.bash_it/custom/themes
ln -sf $HOME/workspace/cli-workstation/dotfiles/bashit_custom_linux/* $HOME/.bash_it/custom
ln -sf $HOME/workspace/cli-workstation/dotfiles/git/gitconfig $HOME/.gitconfig_include
ln -sf $HOME/workspace/cli-workstation/dotfiles/git/git-authors $HOME/.git-authors
ln -sf $HOME/workspace/cli-workstation/scripts/ui-scale $HOME/bin/
ln -sf $HOME/workspace/cli-workstation/scripts/ui-display $HOME/bin/
# Setup gitconfig
report "Configuring $HOME/.gitconfig"
if [[ -L $HOME/.gitconfig ]]; then
rm $HOME/.gitconfig
printf "[include]\n\tpath = $HOME/.gitconfig_include" > $HOME/.gitconfig
elif [[ ! -f $HOME/.gitconfig ]]; then
printf "[include]\n\tpath = $HOME/.gitconfig_include" > $HOME/.gitconfig
fi
## SMT - Why disable gnome keyring?
# # Disable gnome keyring
# if [[ ! -f $HOME/.config/autostart/gnome-keyring-secrets.desktop ]]; then
# mkdir -p $HOME/.config/autostart
#
# cp /etc/xdg/autostart/gnome-keyring* $HOME/.config/autostart
#
# find $HOME/.config/autostart -name "*gnome-keyring*" | \
# xargs sed -i "$ a\X-GNOME-Autostart-enabled=false"
# fi
# Install go if it's not installed or the wrong version
if [[ -z $(which go) ]]; then
report "Installing go version [ $GO_VERSION ]"
sudo snap install go --classic --channel=$GO_VERSION/stable
else
report "Updating go"
sudo snap refresh go --classic --channel=$GO_VERSION/stable
fi
# Install common go utilities
GO_UTILS=(
github.com/onsi/ginkgo/ginkgo
github.com/onsi/gomega
github.com/maxbrunsfeld/counterfeiter
github.com/tools/godep
github.com/shuLhan/go-bindata/...
github.com/XenoPhex/i18n4go/i18n4go
github.com/git-duet/git-duet/...
github.com/cloudfoundry/bosh-bootloader/bbl
)
report "Getting or updating common Go utilities"
for gopkg in "${GO_UTILS[@]}"; do
echo Updating $gopkg
GOPATH=$HOME/go go get -u $gopkg
done
# Clone Go repos into the GOPATH
clone_into_go_path() {
DIR="${HOME}/go/src/${1}"
if [[ ! -d $DIR ]]; then
mkdir -p $(dirname $DIR)
git clone "https://${1}" $DIR
## SMT - The symlinks have caused problems in the past. Can we drop them?
# ln -s $DIR $HOME/workspace/$(basename $DIR)
fi
}
GO_REPOS=(
github.com/cloudfoundry/cf-acceptance-tests
github.com/golangci/golangci-lint
)
for repo in "${GO_REPOS[@]}"; do
clone_into_go_path $repo
done
cd $GOPATH/src/github.com/golangci/golangci-lint
git checkout $GOLANGCI_LINT_VERSION
cd $GOPATH/src
GOPATH=$HOME/go go get github.com/golangci/golangci-lint/cmd/golangci-lint
# Clone CLI Repo
if [[ ! -d "${GOPATH}/src/code.cloudfoundry.org/cli" ]]; then
mkdir -p "${GOPATH}/src/code.cloudfoundry.org"
cd "${GOPATH}/src/code.cloudfoundry.org"
git clone "$SSH_REPO_SCHEME:cloudfoundry/cli"
fi
# Clone cli-plugin-repo
if [[ ! -d "${GOPATH}/src/code.cloudfoundry.org/cli-plugin-repo" ]]; then
cd "${GOPATH}/src/code.cloudfoundry.org"
git clone "$SSH_REPO_SCHEME:cloudfoundry/cli-plugin-repo"
fi
# Install bosh
if [[ -z $(which bosh) || $(bosh --version | cut -d'-' -f 1 | cut -d' ' -f 2) != $BOSH_VERSION ]]; then
report "Installing bosh version [ $BOSH_VERSION ]"
sudo rm -f /usr/local/bin/bosh-cli $HOME/go/bin/bosh*
sudo curl https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-$BOSH_VERSION-linux-amd64 -o /usr/local/bin/bosh-cli
sudo chmod 0755 /usr/local/bin/bosh-cli
sudo ln -sf /usr/local/bin/bosh-cli /usr/local/bin/bosh
else
report "Skipping installation of existing bosh version [ $BOSH_VERSION ]"
fi
# Install RipGrep
if [[ -z $(which rg) ]]; then
report "Installing RipGrep"
sudo snap install ripgrep --classic
else
report "Updating RipGrep"
sudo snap refresh ripgrep
fi
# Install NeoVim and Luan's NeoVim config
if [[ ! -d $HOME/.config/nvim ]]; then
report "Installing NeoVim"
if [[ -L $HOME/.config/nvim ]]; then
rm $HOME/.config/nvim
fi
pip3 install wheel
pip3 install neovim
report "Installing Luan's NeoVim config"
git clone https://github.com/luan/nvim $HOME/.config/nvim
mkdir -p $HOME/.config/nvim/user
ln -sf $HOME/workspace/cli-workstation/dotfiles/vimfiles/after.vim $HOME/.config/nvim/user/after.vim
ln -sf $HOME/workspace/cli-workstation/dotfiles/vimfiles/before.vim $HOME/.config/nvim/user/before.vim
ln -sf $HOME/workspace/cli-workstation/dotfiles/vimfiles/plug.vim $HOME/.config/nvim/user/plug.vim
ln -sf $HOME/workspace/cli-workstation/dotfiles/vimfiles/.NERDTreeBookmarks $HOME/.NERDTreeBookmarks
git clone --depth 1 https://github.com/ryanoasis/nerd-fonts $HOME/.config/nerd-fonts
pushd $HOME/.config/nerd-fonts
./install.sh DejaVuSansMono
popd
else
report "Upgrading NeoVim"
pip3 install --upgrade neovim
## TODO: investigate why this doesn't succeed sometimes
nvim --headless +":ConfigUpdate!" +":qall"
fi
report "Installing / upgrading and configuring yamllint for NeoVim"
pip3 install --upgrade yamllint
mkdir -p $HOME/.config/yamllint
ln -sf $HOME/workspace/cli-workstation/dotfiles/yamllint.config $HOME/.config/yamllint/config
# Install Luan's Tmux config
if [[ ! -d $HOME/.tmux ]]; then
report "Installing Luan's Tmux config"
git clone https://github.com/luan/tmuxfiles.git $HOME/.tmux
$HOME/.tmux/install
else
report "Upgrading installation of existing Luan's Tmux config"
pushd $HOME/.tmux
git clean -fd
git pull
popd
fi
cat <<EOT >> $HOME/.tmux.conf
# load user config
source-file $HOME/workspace/cli-workstation/dotfiles/tmux/tmux.conf.local
EOT
# Install credhub cli
REMAINING=$(curl https://api.github.com/rate_limit 2>/dev/null | jq '.rate.remaining')
if [[ $REMAINING -eq 0 ]]; then
report "**NOT** Installing latest Credhub CLI"
echo "We hit the rate limit for the `api.github.com` and cannot download the latest Credhub CLI Release."
echo "Reference: https://developer.github.com/v3/#rate-limiting"
echo
else
report "Installing latest Credhub CLI"
credhub_url="$(curl https://api.github.com/repos/cloudfoundry-incubator/credhub-cli/releases | jq '.[0].assets | map(select(.name | contains("linux"))) | .[0].browser_download_url' -r)"
curl -Lo /tmp/credhub.tgz "$credhub_url"
tar xzvf /tmp/credhub.tgz -C $HOME/bin
chmod 755 $HOME/bin/credhub
fi
# Install dep
report "Installing dep version [ $GODEP_VERSION ]"
curl -Lo $HOME/bin/dep "https://github.com/golang/dep/releases/download/$GODEP_VERSION/dep-linux-amd64"
chmod 755 $HOME/bin/dep
# Make bash auto-complete case-insensitive
if [ ! -f ~/.inputrc ]; then
report "Making bash auto-complete case-insensitive"
echo '$include /etc/inputrc' > ~/.inputrc
echo 'set completion-ignore-case On' >> ~/.inputrc
fi
# increase key repeat rate
if [[ -n "$DISPLAY" ]] ; then
report "Increasing key repeat rate"
xset r rate 250 35
fi
if [[ -z $(which zoom) ]]; then
report "NOT installing zoom because it has to be done manually once this script ends"
report "go to zoom.com and download and install the hotness yerself"
report "https://support.zoom.us/hc/en-us/articles/204206269-Installing-Zoom-on-Linux"
fi
figlet -t -k -c -f /usr/share/figlet/script.flf "You have achieved pure workstation happiness!"