-
Notifications
You must be signed in to change notification settings - Fork 4
/
install-packets.sh
executable file
·332 lines (294 loc) · 10.4 KB
/
install-packets.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
#!/bin/bash -eux
export DOTFILES="$HOME/.dotfiles"
export PATH="$DOTFILES/bin:$PATH"
eval $(parse-yaml $DOTFILES/config.yaml DOTFILES_CONF_)
function set-glab-aliases {
glab alias set get-variable 'glab api /projects/:id/variables/$1 | jq .value' --shell
glab alias set get-state 'glab api /projects/${2-:id}/terraform/state/$1' --shell
}
function setup_binary_env {
repo=$1
location="$HOME/.$(echo $repo | cut -d'/' -f 2)"
if [ ! -d "$location" ]
then
git clone --branch master --depth 1 https://github.com/$repo.git "$location"
else
(
cd "$location"
git pull
)
fi
}
function install_fonts {
FONT_DIR="$HOME/.local/share/fonts"
(
if [ ! -d "${FONT_DIR}" ]; then
mkdir -p "${FONT_DIR}"
fi
cd "${FONT_DIR}"
for font in "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/UbuntuMono/Regular/complete/Ubuntu%20Mono%20Nerd%20Font%20Complete%20Mono.ttf" "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hack/Regular/complete/Hack%20Regular%20Nerd%20Font%20Complete%20Mono.ttf"
do
font_name="$(echo "${font}" | rev | cut -d'/' -f1 | rev | sed 's|%20| |g')"
if [ ! -f "$font_name" ]; then
curl -fL --output "${font_name}" "${font}"
fi
done
fc-cache -vf
mkfontscale
mkfontdir
)
}
function install_debian_standard {
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y \
python3 \
python3-pip \
python3-dev \
python3-setuptools \
python3-venv \
curl
}
function install_debian_extras {
sudo apt-get install -y \
ruby \
ruby-dev \
rng-tools \
gnupg \
neovim \
zsh \
terminator \
xclip \
xdotool \
trash-cli \
libncursesw5 \
gtk+3.0 \
webkit2gtk-4.0 \
libusb-dev \
x11-apps \
openvpn \
libgtop-2.0-11 \
gir1.2-gtop-2.0 \
apt-transport-https \
ca-certificates \
gnupg-agent \
software-properties-common \
w3m \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo usermod -a -G docker $(whoami)
if [ "$DOTFILES_CONF_gnome" = "true" ]; then
sudo apt-get install -y \
chrome-gnome-shell \
gnome-tweaks
if [ ! -d ~/.icons/Bibata-Modern-Amber ]; then
(
cd /tmp
curl -Lo bibata.tgz https://github.com/ful1e5/Bibata_Cursor/releases/download/v2.0.3/Bibata-Modern-Amber.tar.gz
tar -xvf bibata.tgz
mv Bibata-* ~/.icons/
)
fi
for ext in $(gnome-extensions list); do
gnome-extensions enable $ext
done
fi
if [ "$DOTFILES_CONF_google" = "true" ]; then
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.gpg
sudo apt-get update && sudo apt-get install google-cloud-cli
fi
if [ "$DOTFILES_CONF_slack" = "true" ]; then
snap install --classic slack
fi
if [ "$DOTFILES_CONF_code" = "true" ]; then
snap install --classic code
fi
if [ "$DOTFILES_CONF_kubectl" = "true" ]; then
snap install --classic kubectl
setup_binary_env "yuya-takeyama/helmenv"
if [ "$DOTFILES_CONF_google" = "true" ]; then
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
fi
fi
if [ "$DOTFILES_CONF_spotify" = "true" ]; then
snap install spotify
fi
if [ "$DOTFILES_CONF_digitalocean" = "true" ]; then
snap install doctl
fi
for app in fasd; do
if ! snap list | grep "${app}"
then
snap install --beta "${app}"
fi
done
if [ "$DOTFILES_CONF_gitlab" = "true" ]; then
snap install --edge glab
snap connect glab:ssh-keys
set-glab-aliases
fi
if [ "$DOTFILES_CONF_golang" = "true" ]; then
setup_binary_env "syndbg/goenv"
fi
if [ "$DOTFILES_CONF_terraform" = "true" ]; then
setup_binary_env "tfutils/tfenv"
$HOME/.tfenv/bin/tfenv install
fi
setup_binary_env "asdf-vm/asdf"
if [ "$DOTFILES_CONF_github" = "true" ]; then
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /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 -y gh
fi
if [ "$DOTFILES_CONF_azure" = "true" ]; then
curl -sL https://packages.microsoft.com/keys/microsoft.asc | \
gpg --dearmor | \
sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt-get update
sudo apt-get install -y azure-cli
fi
install_fonts
}
function install_osx_extras {
brew tap homebrew/cask-fonts
if [ "$DOTFILES_CONF_spotify" = "true" ]; then
brew install --cask spotify
fi
if [ "$DOTFILES_CONF_code" = "true" ]; then
brew install --cask visual-studio-code
fi
if [ "$DOTFILES_CONF_google" = "true" ]; then
brew install --cask google-cloud-sdk
fi
if [ "$DOTFILES_CONF_slack" = "true" ]; then
brew install --cask slack
fi
for p in iterm2 font-hack-nerd-font
do
brew install --cask $p
done
if [ "$DOTFILES_CONF_digitalocean" = "true" ]; then
brew install doctl
fi
if [ "$DOTFILES_CONF_kubectl" = "true" ]; then
brew install kubernetes-cli
brew install helm
setup_binary_env "yuya-takeyama/helmenv"
# if [ "$DOTFILES_CONF_gcloud" = "true" ]; then
# https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
# fi
fi
if [ "$DOTFILES_CONF_golang" = "true" ]; then
setup_binary_env "syndbg/goenv"
fi
if [ "$DOTFILES_CONF_terraform" = "true" ]; then
brew install tfenv
fi
if [ "$DOTFILES_CONF_github" = "true" ]; then
brew install gh
fi
if [ "$DOTFILES_CONF_gitlab" = "true" ]; then
brew install glab
set-glab-aliases
fi
if [ "$DOTFILES_CONF_azure" = "true" ]; then
brew install az
fi
for p in gnupg2 pinentry-mac neovim zsh fasd trash-cli libusb docker neovim trash-cli xclip coreutils gnu-sed wget
do
brew install $p
done
if ! cat ~/.gnupg/gpg-agent.conf | grep -q /usr/local/bin/pinentry-mac; then
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
fi
}
function install_osx_standard {
if ! brew --version; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
for p in python curl; do
brew install $p
done
(
cd /tmp
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
)
}
if apt-get --version &> /dev/null; then
install_debian_standard
elif uname -a | grep -iq darwin; then
install_osx_standard
fi
if [ ! -d "venv" ]; then
python3 -m venv venv
source venv/bin/activate
pip3 install --upgrade -r requirements.txt
fi
if apt-get --version &> /dev/null; then
install_debian_extras
elif uname -a | grep -iq darwin; then
install_osx_extras
fi
chsh -s $(which zsh)
if [ ! -d "~/.zinit" ]; then
mkdir ~/.zinit
git clone --depth 1 https://github.com/zdharma-continuum/zinit.git ~/.zinit/bin
fi
if [ ! -f "$HOME/.local/share/nvim/site/autoload/plug.vim" ]; then
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
curl -L https://cht.sh/:cht.sh > ~/bin/cht.sh
chmod -x ~/bin/*
if [ "$DOTFILES_CONF_kubectl" = "true" ]; then
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# https://krew.sigs.k8s.io/plugins/
for plugin in ns ctx tree view-secret cert-manager stern service-tree restart podevents node-shell modify-secret kurt ingress-nginx grep fuzzy debug-shell; do
kubectl krew install $plugin
done
fi
if [ "$DOTFILES_CONF_node" = "true" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
fi
if [ "$DOTFILES_CONF_grub" = "true" ]; then
wget -O - https://github.com/shvchk/fallout-grub-theme/raw/master/install.sh | bash
fi
if [ "$DOTFILES_CONF_git" = "true" ]; then
git config --global include.path "$PWD/global.gitconfig"
git config --global core.excludesfile "$PWD/global.gitignore"
if whoami | grep -iq 'mlodzik'; then
git config --global user.name "Mikołaj Młodzikowski"
git config --global user.email "[email protected]"
fi
fi
if [ "$DOTFILES_CONF_code_extensions" = "true" ]; then
for extension in $(cat installed_vs_extensions); do
code --install-extension $extension
done
fi
if [ "$DOTFILES_CONF_cloudflare" = "true" ]; then
go get -u github.com/cloudflare/cloudflare-go/...
fi