-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·351 lines (314 loc) · 8.81 KB
/
bootstrap
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
#!/usr/bin/env bash
current_dir=$(
cd $(dirname $BASH_SOURCE)
pwd
)
source "${current_dir}/local/share/shell/argsparse.sh"
usage() {
printf "Bootstrap script, supported choices:\n"
printf "\tterminal: install terminal tools\n"
printf "\tenv: pyenv+asdf\n"
printf "\ttexlive: texlive\n"
printf "\tdevelop: above+develop tools\n"
printf "\tfull: above+desktop environments\n"
printf "Beginning of usage:\n"
argsparse_usage
printf "End of useage\n"
exit 16
}
argsparse_use_option choose "choose install specified environments" value mandatory
option_choose_values=(terminal env texlive develop full)
argsparse_parse_options "$@"
args_only=${program_options[choose]}
yay_packages=()
apt_packages=()
additional_commands=()
download() {
filename=$1
url=$2
mkdir -p $(dirname $filename)
if [ ! -f $1 ]; then
echo "download $url to $filename"
curl $url -o $filename
else
echo "$filename exists, skip"
fi
}
setup_pyenv() {
yay_packages+=(
openssl
zlib
xz
tk
)
apt_packages+=(
build-essential
libssl-dev
zlib1g-dev
libbz2-dev
libreadline-dev
libsqlite3-dev
curl
libncursesw5-dev
xz-utils
tk-dev
libxml2-dev
libxmlsec1-dev
libffi-dev
liblzma-dev
)
if [ ! -d ~/.pyenv ]; then
echo "installing pyenv..."
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
else
echo "pyenv installed, skip"
fi
pyenv_plugin() {
name=$1
git_user=$2
if [ ! -d ~/.pyenv/plugins/${name} ]; then
echo "installing ${name}..."
git clone https://github.com/${git_user}/${name} ~/.pyenv/plugins/${name}
else
echo " ${name} installed, skip"
fi
}
pyenv_plugin pyenv-virtualenv AbaoFromCUG
pyenv_plugin pyenv-doctor pyenv
pyenv_plugin pyenv-update pyenv
pyenv_plugin pyenv-pyright alefpereira
}
setup_asdf() {
if [ ! -d ~/.asdf ]; then
echo "installing asdf..."
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
. "$HOME/.asdf/asdf.sh"
else
echo "asdf installed, skip"
fi
asdf_plugin() {
name=$1
repository=$2
if [ ! -d ~/.asdf/plugins/${name} ]; then
echo "installing ${name}..."
asdf plugin-add $name https://github.com/${repository}
else
echo " ${name} installed, skip"
fi
}
asdf_plugin bun cometkim/asdf-bun
asdf_plugin rust code-lever/asdf-rust
asdf_plugin nodejs asdf-vm/asdf-nodejs
}
setup_tmux() {
if [ ! -d ~/.tmux ] || [ ! -f ~/.tmux.conf ]; then
echo "installing oh-my-tmux..."
if [[ -f ~/.tmux.conf ]]; then
echo -e "\033[31m backup current .tmux.conf to ~/.tmux.conf.bak \033[0m"
mv ~/.tmux.conf /tmp/tmux.conf.bak
fi
rm -rf ~/.tmux.conf
git clone https://github.com/gpakosz/.tmux.git ~/.tmux
ln -s -f ~/.tmux/.tmux.conf ~/.tmux.conf
else
echo "oh-my-tmux installed, skip"
fi
}
setup_fzf() {
if [ ! -f ~/.fzf/install ]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --bin
fi
}
setup_yazi() {
echo "install yazi plugin"
yazi_plugin() {
name=$1
repository=$2
if [ ! -d ~/.config/yazi/plugins/${name} ]; then
echo "installing ${name}..."
git clone https://github.com/$repository ~/.config/yazi/plugins/$name
else
echo " ${name} installed, skip"
fi
}
yazi_plugin keyjump.yazi DreamMaoMao/keyjump.yazi
}
# --------------choice--------------------
install_terminal() {
setup_tmux
setup_fzf
setup_yazi
yay_packages+=(
tmux
lazygit
zsh
openssh
neovim
)
}
install_env() {
setup_pyenv
setup_asdf
}
install_develop() {
yay_packages+=(
pkgfile
man-db
cmake
git
ninja
eigen
go
)
apt_packages+=(
cmake
git
)
}
install_desktop() {
yay_packages+=(
base base-devel linux linux-firmware yay
hyprland hyprpaper hyprpicker hypridle hyprlock
xdg-desktop-portal-hyprland xdg-desktop-portal-gtk
lxqt-policykit
libinput-gestures
wl-clipboard
brightnessctl tlp ddcutil
sof-firmware libva-intel-driver libva-mesa-driver
networkmanager curl wget
pipewire pipewire-pulse pipewire-jack pipewire-audio
bluez-utils blueman
mpd mpd-mpris playerctl pavucontrol
)
yay_packages+=(
whitesur-gtk-theme whitesur-cursor-theme-git whitesur-icon-theme
wofi quickshell aylurs-gtk-shell
nwg-bar nwg-displays nwg-look
conky
)
# input method & fonts
yay_packages+=(
fcitx5 fcitx5-configtool fcitx5-pinyin-zhwiki fcitx5-chinese-addons
fcitx5-gtk fcitx5-qt
fcitx5-skin-fluentdark-git
ttf-hack-nerd ttf-cascadia-code-nerd ttf-firacode-nerd
adobe-source-han-serif-cn-fonts adobe-source-han-sans-cn-fonts
noto-fonts-emoji
ttf-humor-sans
)
# basic tools
yay_packages+=(
cups cups-pdf
imagemagick
ksnip gimp grimblast-git
)
# apps
yay_packages+=(
wps-office wps-office-fonts wps-office-mime ttf-wps-fonts
clash-for-windows-bin
linuxqq-nt-bwrap wechat-universal-bwrap
telegram-desktop feishu-bin discord
krita blender
vlc obs-studio
ario
unarchiver unzip
pot-translation
visual-studio-code-bin
kitty alacritty
)
# others
yay_packages+=(
fastfetch
rsync
lsof
)
download ~/Pictures/wallpapers/nature-3058859.jpg https://gitlab.manjaro.org/artwork/wallpapers/wallpapers-2018/-/raw/master/nature-3058859.jpg
download ~/Pictures/wallpapers/nature-3181144.jpg https://gitlab.manjaro.org/artwork/wallpapers/wallpapers-2018/-/raw/master/nature-3181144.jpg
additional_commands+=(
"hyprpm update"
"hyprpm add https://github.com/hyprwm/hyprland-plugins"
"hyprpm add https://github.com/levnikmyskin/hyprland-virtual-desktops"
"hyprpm add https://github.com/KZDKM/Hyprspace.git"
"hyprpm enable virtual-desktops"
"systemctl enable bluetooth"
"systemctl enable --user pipewire"
"systemctl enable --user pipewire-pulse"
"sudo usermode -aG audio $USER"
"sudo usermode -aG video $USER"
"sudo usermode -aG lp $USER"
)
}
install_texlive() {
yay_packages+=(
sioyek
texlive-latex
texlive-xetex
texlive-luatex
texlive-binextra
texlive-latexrecommended
texlive-latexextra
texlive-fontsrecommended
texlive-fontsextra
texlive-bibtexextra
texlive-mathscience
texlive-langcjk
texlive-langchinese
texlive-langjapanes
texlive-metapost
texlive-music
texlive-pstricks
texlive-publishers
ttf-babelstone-han
texlive-context
texlive-fontutils
texlive-formatsextra
texlive-games
texlive-humanities
texlive-plaingeneric
)
}
if [[ $args_only = terminal ]]; then
install_terminal
elif [[ $args_only = env ]]; then
install_env
elif [[ $args_only = texlive ]]; then
install_texlive
elif [[ $args_only = develop ]]; then
install_env
install_terminal
install_develop
elif [[ $args_only = full ]]; then
install_terminal
install_env
install_develop
install_desktop
install_texlive
fi
if [ -n "${yay_packages}" ] && command -v yay >/dev/null 2>&1; then
installed_packages="$(yay -Qq | sort)"
yay_packages=$(printf "%s\n" ${yay_packages[*]} | sort)
missed_packages=$(comm -23 <(echo "$yay_packages") <(echo "$installed_packages"))
echo $missed_package
if [[ -n "$missed_packages" ]]; then
echo "these packages are required but not installed:"
echo " yay -S $(echo $missed_packages)"
fi
explicit_packages="$(yay -Qettq | sort)"
missed_packages=$(comm -23 <(echo "$explicit_packages") <(echo "$yay_packages"))
if [[ -n "$missed_packages" ]]; then
echo "these packages are explicitly installed but not required"
echo " yay -S $(echo $missed_packages)"
fi
elif [ -n "${apt_packages}" ] && command -v apt >/dev/null 2>&1; then
echo "please install manually:"
echo " sudo apt install ${apt_packages[@]}"
else
echo "\033[31m Don't support current system \033[0m"
fi
if [[ -n "${additional_commands[@]}" ]]; then
echo "please install manually:"
for command in "${additional_commands[@]}"; do
echo " $command"
done
fi