-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbox_setup
executable file
·195 lines (169 loc) · 5.82 KB
/
cloudbox_setup
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
#!/usr/bin/bash
RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
ENDCOLOR="\033[0m"
function msg() {
echo -e "$1"
}
function info() {
msg "$BLUE$1$ENDCOLOR"
}
function success() {
msg "${GREEN}$1${ENDCOLOR}"
}
function error() {
msg "${RED}$1${ENDCOLOR}"
}
success "Cloudbox setup - Let's go!"
sudo apt update
sudo apt dist-upgrade -y
# Install some packages
sudo apt install -y \
autoconf \
autojump \
automake \
bat \
cmake \
curl \
doxygen \
exuberant-ctags \
g++ \
gettext \
hub \
libtool \
libtool-bin \
luarocks \
ninja-build \
pkg-config \
python3-pip \
ripgrep \
silversearcher-ag \
stow \
unzip \
zsh-autosuggestions
if ! command -v gh &> /dev/null; then
info "Installing Github CLI..."
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
gh config set git_protocol ssh
fi
success "Github CLI is g2g"
if ! command -v rustc &> /dev/null; then
info "Installing rust for editor tooling..."
curl https://sh.rustup.rs -sSf | sh -s -- -y
fi
success "rustc is g2g"
if ! command -v rb &> /dev/null; then
info "Installing rb for string manipulation with Ruby..."
curl https://raw.githubusercontent.com/thisredone/rb/master/rb -o /usr/local/bin/rb && chmod +x /usr/local/bin/rb
fi
success "rb is g2g"
if ! command -v zsh &> /dev/null; then
info "Installing ZSH..."
sudo apt install -y zsh
fi
success "ZSH is good to go"
if [ ! "$SHELL" = "$(which zsh)" ]; then
info "Setting shell to ZSH..."
sudo chsh "$(whoami)" -s "$(which zsh)"
fi
success "ZSH is already set as shell"
info "Setting up dotfiles..."
mkdir -p "$HOME/.config"
mkdir -p "$HOME/bin"
if [ ! -d "$HOME/dotfiles" ]; then
info "Cloning dotfiles..."
git clone git@github.com:bweave/dotfiles.git "$HOME/dotfiles"
fi
success "dotfiles cloned"
info "Symlinking dotfiles..."
ln -sf "$HOME/dotfiles/bin_scripts/bin/git-nuke-staging" "$HOME/bin/git-nuke-staging"
ln -sf "$HOME/dotfiles/bin_scripts/bin/tat" "$HOME/bin/tat"
ln -sf "$HOME/dotfiles/eslint/.eslintrc" "$HOME/.eslintrc"
ln -sf "$HOME/dotfiles/git/.gitconfig" "$HOME/.gitconfig"
ln -sf "$HOME/dotfiles/git/.gitignore" "$HOME/.gitignore"
ln -sf "$HOME/dotfiles/git/.gitmessage" "$HOME/.gitmessage"
ln -sf "$HOME/dotfiles/irb/.irbrc" "$HOME/.irbrc"
ln -sf "$HOME/dotfiles/nvim/.config/nvim" "$HOME/.config/"
ln -sf "$HOME/dotfiles/ssh/.ssh/rc" "$HOME/.ssh/rc"
ln -sf "$HOME/dotfiles/tmux/.tmux.conf" "$HOME/.tmux.conf"
ln -sf "$HOME/dotfiles/tmux/.tmux.conf.linux" "$HOME/.tmux.conf.linux"
ln -sf "$HOME/dotfiles/wezterm/.config/wezterm/wezterm.lua" "$HOME/.config/wezterm/wezterm.lua"
ln -sf "$HOME/dotfiles/wezterm/.config/wezterm/color_scheme.lua.lua" "$HOME/.config/wezterm/color_scheme.lua"
ln -sf "$HOME/dotfiles/zsh/.zshrc" "$HOME/.zshrc"
ln -sf "$HOME/dotfiles/zsh/.zshenv" "$HOME/.zshenv"
success "dotfiles are g2g"
if [ "$(tmux -V | rb -l "split[1].to_f < 3.2")" = "true" ]; then
info "Installing latest Tmux..."
sudo apt install -y libevent-dev
cd || (error "Couldn't cd to ~" && exit)
curl -s https://api.github.com/repos/tmux/tmux/releases/latest \
| grep "browser_download_url.*" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -qi -
tar -zxf tmux-*.tar.gz
cd tmux-*/ || (error "Couldn't navigate to tmux-*" && exit)
./configure --prefix=/usr/local
make && sudo make install
cd || (error "Couldn't cd to ~" && exit)
rm -rf tmux-*
fi
success "Tmux is g2g"
if ! command -v lua-language-server &> /dev/null; then
info "Installing lua-language-server..."
sudo mkdir -p /usr/local/lua-language-server
sudo chown ubuntu:ubuntu /usr/local/lua-language-server
cd /usr/local/lua-language-server || exit
latest=$(curl -sL https://api.github.com/repos/sumneko/lua-language-server/releases/latest | jq -r ".tag_name")
curl -Lk "https://github.com/sumneko/lua-language-server/releases/download/$latest/lua-language-server-$latest-linux-x64.tar.gz" | tar xzv
cat <<EOF > /usr/local/bin/lua-language-server
#!/bin/bash
exec "/usr/local/lua-language-server/bin/lua-language-server" "\$@"
EOF
sudo chmod +x /usr/local/bin/lua-language-server
fi
success "lua-language-server is g2g"
# manually install fzf to get the most up to date version
if [ ! -d "$HOME/.fzf" ]; then
info "Cloning FZF..."
git clone --depth 1 https://github.com/junegunn/fzf.git "$HOME/.fzf"
fi
# TODO: this check doesn't work and thinks fzf needs to be installed every time
if ! [ -x "$(command -v fzf)" ]; then
info "Install FZF..."
"$HOME/.fzf/install" --no-update-rc --key-bindings --completion
source "$HOME/.zshrc"
fi
success "FZF is g2g"
# Install additional editor tooling
sudo npm install -g npm@latest
if ! command -v tsc &> /dev/null; then
info "Installing typescript..."
sudo npm i -g typescript typescript-language-server
fi
success "typescript is g2g"
if ! command -v nvim &> /dev/null; then
info "Installing neovim"
"$HOME/dotfiles/install-neovim-nightly.sh"
fi
success "neovim is g2g"
info "Installing Neovim plugins"
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
# Setup forwarding GITHUB_TOKEN env var over ssh
if [ -z ${GITHUB_TOKEN+x} ]; then
info "GITHUB_TOKEN is not setup. Adding it to ssh config"
sudo sed --in-place=.orig 's/^AcceptEnv LANG LC_\*$/& GITHUB_TOKEN/' /etc/ssh/sshd_config
info Reloading SSH
sudo service ssh reload
fi
success "GITHUB_TOKEN is g2g"
echo
success =================================================
success "Donezo!"
success =================================================
echo