-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallV0.sh
More file actions
executable file
·350 lines (299 loc) · 10.5 KB
/
installV0.sh
File metadata and controls
executable file
·350 lines (299 loc) · 10.5 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
339
340
341
342
343
344
345
346
347
348
349
350
#!/usr/bin/env bash
# [WIP] be careful with this script !
# this script does:
# - install packages (from pacman/AUR/flatpak)
# - install stuff from $origin to $config (and move the previous files to $backup)
# - install stuff from $origin to other places
# - source/include some files
#
# you will be asked before most actions
# most things are symbolic links
#
# env vars:
# SILENT: be less verbose (if not empty)
# SKIP=n: will skip the first n asked steps
#
# (https://github.com/egnrse/configs)
# (by egnrse)
## CONSTANTS
origin="$(pwd)/"
config="$HOME/.config/"
backup="${config}.bak/"
bold="\e[1m"
normal="\e[0m"
green="\e[32m"
purple="\e[95m"
## ENV VARIABLES
skip_amount=0
if [[ "$SKIP" =~ ^[0-9]+$ ]]; then
skip_amount=${SKIP}
fi
if [ -z "$SILENT" ]; then
set -x
fi
## FUNCTIONS
skip() {
if [ "$skip_amount" -ge 1 ]; then
skip_amount=$((skip_amount -1))
echo -e "${purple}${bold}skipping:${normal} '$1'"
return 1
fi
var1="$1"
if [ -z "$1" ]; then
var1=" continue [y] or skip [n]"
fi
#read -p "$var1 (Y/n): " pause_answer
read -p "$(printf "%b" "$var1 ${purple}${bold}(Y/n): "${normal})" pause_answer
case $pause_answer in
[Yy]*|"")
return 0;
;;
[Nn]*)
return 1;
;;
esac
}
# links $1 from $origin to $config
# backing up old files to $backup (files in $backup might get deleted)
linkTo() {
# cp -r --update : copy recursively, overwrite older files
# ln -s -i : link symbolic, interactively (ask if unsure)
linkName=$1
if [ -d "${config}${linkName}" ]; then
# directory
rm -r ${backup}$linkName
mv -f --update ${config}$linkName ${backup}
elif [ -f "${config}${linkName}" ]; then
cp --update ${config}$linkName ${backup}
fi
ln -s ${origin}$linkName ${config}
}
# ask for each input and call linkTo() if yes was selected
askForLink() {
for link in "$@"; do
skip "link $link" && linkTo $link
done
}
# link $1 (from $3) to $2 (and make the file and link root owned)
rootLink() {
file="$1"
to="$2/"
from="${3:-${origin}other/}/"
sudo chown root:root ${from}${file}
sudo mkdir -p ${to}
sudo ln -s -i ${from}${file} ${to}${file}
}
askRootLink() {
if skip "root-link ${3:-$1}"; then
rootLink $1 $2
fi
}
## INSTALL PACKAGES #####################################
if skip "install some packages"; then
aur_handler="yay"
pkgs="base-devel neovim vi vim git sudo grub openssh efibootmgr man-db man-pages" # basics
pkgs+=" ntfs-3g exfat-utils btrfs-progs grub-btrfs" # filesystem
pkgs+=" networkmanager blueman waypipe" # network
pkgs+=" flatpak wget pacman-contrib devtools reflector" # package management
pkgs+=" pipewire pipewire-docs wireplumber wireplumber-docs" # audio
pkgs+=" wl-clipboard zsh zoxide fzf rclone ttf-dejavu-nerd ctags" # cli
pkgs+=" syncthing zip unzip tar tree-sitter-cli lazygit zerotier-one fastfetch"
pkgs_gui="plasma-meta hyprland sddm wayland-protocols wayland-utils uwsm xdg-desktop-portal-hyprland xdg-desktop-portal-gtk" # gui meta
pkgs_gui+=" waybar dunst rofi-wayland nwg-drawer hypridle hyprlock hyprsunset helvum polkit-kde-agent firefox alacritty konsole dolphin" # gui
pkgs_gui+=" kio-admin ark dolphin-plugins archlinux-xdg-menu kdegraphics-thumbnailers libappimage" # dolpin stuff
pkgs_gui+=" hunspell-en_US speech-dispatcher" # waterfox/firefox
pkgs_gui+=" libreoffice-fresh prismlauncher mission-center kdeconnect kalgebra kcalc godot-mono blender cuda keepassxc" # more gui
pkgs_gui+=" audacity audacious vlc" # audio
pkgs_laptop="brightnessctl power-profiles-daemon"
pkgs_aur="xdg-terminal-exec-git hyprswitch ianny v-editor-git" # hyprswitch > hyprshell
pkgs_aur+=" pwvucontrol wlogout tofi trash-d"
pkgs_aur+=" beeper-v4-bin anki-bin waterfox-bin pa-notify syncthingtray-qt6" # gui
pkgs_flatpak+="com.github.tchx84.Flatseal dev.vencord.Vesktop com.obsproject.Studio io.github.dimtpap.coppwr net.cozic.joplin_desktop net.veloren.airshipper org.gimp.GIMP org.musescore.MuseScore org.torproject.torbrowser-launcher"
sudo pacman -Syu --needed $pkgs
skip "install gui packages" && sudo pacman -Syu --needed $pkgs_gui
skip "install laptop packages" && sudo pacman -Syu --needed $pkgs_laptop
if skip "install AUR packages"; then
if ! command -v ${aur_handler}; then
sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/${aur_handler}.git
cd ${aur_handler}
makepkg -si
cd ..
skip "remove ${aur_handler} install dir" && rm -rf ./${aur_handler}
fi
${aur_handler} -S --needed $pkgs_aur
fi
if skip "install flatpak packages"; then
flatpak install -y flathub $pkgs_flatpak
fi
fi
## MOVE/CP FILES ########################################
if skip "link/copy ~/.config stuff"; then
mkdir -p ${backup}
# link folders to $config
askForLink alacritty bash bottom dunst environment.d hypr hyprswitch io.github.zefr0x.ianny lazygit nvim nwg-drawer pipewire rofi shell tofi waybar wlogout zsh
# scripts
#ln -s -i ${origin}scripts ${config} # deprecated
if skip "link ${HOME}/.local/share/bin/scripts"; then
chmod +x ${origin}scripts/*
mkdir -p ${HOME}/.local/share/bin/
ln -s -i ${origin}scripts ${HOME}/.local/share/bin/
fi
# files
askForLink egnrseTheme.css egnrseTheme.css egnrseTheme.conf xdg-terminals.list
# egnrseTheme.sh ?
# cp mimeapps.list
if [ $(skip "copy mimeapps.list") ]; then
cp -r --update ${config}mimeapps.list ${backup}
cp ${origin}mimeapps.list ${config}
fi
fi
echo ""
## DIFFERENT LOCATIONS ##################################
# ssh
sshConfigFile="${HOME}/.ssh/config"
if skip "link ~/.ssh/ssh_config"; then
mkdir -p ${HOME}/.ssh/
ln -s -i ${origin}other/ssh_config ${HOME}/.ssh/ssh_config
if grep "Include ~/.ssh/ssh_config" ${sshConfigFile} >/dev/null; then
echo " Skipping: already sourced in ${sshConfigFile}"
else
skip " source the custom ssh config in ${sshConfigFile}" && echo "Include ~/.ssh/ssh_config" >> ${sshConfigFile}
fi
fi
# vim
skip "link ~/.vimrc" && ln -s -i ${origin}other/.vimrc ${HOME}/
# git
gitConfigFile="${HOME}/.gitconfig"
if skip "link ~/.gitconfig_custom and ~/.gitignore_global"; then
ln -s -i ${origin}other/.gitconfig_custom ${HOME}/
ln -s -i ${origin}other/.gitignore_global ${HOME}/
if cat "${gitConfigFile}" >/dev/null 2>&1 && grep "path = ~/.gitconfig_custom" "${gitConfigFile}" >/dev/null; then
echo " Skipping: already sourced in ${gitConfigFile}"
else
if skip "source .gitconfig_custom in ${gitConfigFile}"; then
touch ${gitConfigFile}
tmpFile='/tmp/install.sh-gitconfig'
{
printf '[include]\n'
printf ' path = ~/.gitconfig_custom\n'
cat "${gitConfigFile}" 2>/dev/null
} > ${tmpFile} && mv ${tmpFile} "${gitConfigFile}"
rm -f "${tmpFile}"
else
echo "Add the following to your ~/.gitconfig to source the files manually:"
printf '[include]\n'
printf ' path = ~/.gitconfig_custom\n'
echo ""
echo "Or only add '.gitignore_global' with 'git config --global core.excludesfile ~/.gitignore_global'"
fi
fi
fi
# dolphin
if skip "link dolphin servicemenus"; then
mkdir -p ~/.local/share/kio/servicemenus
ln -s -i ${origin}other/servicemenus/* ~/.local/share/kio/servicemenus/
chmod +x ${origin}other/servicemenus/*
fi
if skip "create pacman hooks for dolphin "; then
rootLink updateKDEcache.hook /etc/pacman.d/hooks
if pacman -Q archlinux-xdg-menu >/dev/null 2>&1; then
:
else
echo "install the 'archlinux-xdg-menu' packages, for some dolphin stuff to work"
fi
fi
# screenshot
if skip "link screenshot.desktop"; then
mkdir -p ${HOME}/.local/share/applications/
ln -s -i ${origin}other/screenshot.desktop ${HOME}/.local/share/applications/
fi
# systemd user services
if skip "link systemd user services"; then
mkdir -p $HOME/.config/systemd/user
ln -s -i ${origin}other/*.service $HOME/.config/systemd/user/
systemctl --user daemon-reload
echo "start them with 'systemctl --user enable --now <NAME>'"
fi
# log file
if skip "add/link log folder"; then
mkdir -p ${origin}log
ln -s -i ${origin}log ${config}
fi
## ROOT FILES ###########################################
if skip "link/chmod root files"; then
askRootLink sddm.conf /etc/sddm.conf.d
askRootLink 50-custom-sshd.conf /etc/ssh/sshd_config.d "custom sshd config"
askRootLink 99-custom-sysctl.conf /etc/sysctl.d "sysctl config"
askRootLink makepkg.conf /etc
askRootLink faillock.conf /etc/security
if skip "link reflector config"; then
sudo mv /etc/xdg/reflector/reflector.conf /etc/xdg/reflector/reflector.conf.bak
sudo cp ${origin}other/reflector.conf /etc/xdg/reflector
fi
# systemd services
if skip "link logind config"; then
rootLink custom-logind.conf /etc/systemd/logind.conf.d
sudo systemctl reload systemd-logind.service
fi
fi
echo ""
## SOURCE/CHANGE STUFF ##################################
if skip "source bash in ~/.bashrc"; then
if grep "source \$customBashConfig_path" ${HOME}/.bashrc >/dev/null; then
echo " Skipping: already sourced"
else
cat <<EOF >> ${HOME}/.bashrc
# fetches the config file for bash (if it exists)
# $customBashConfig_path is the path to the custom config file
customBashConfig_path="$HOME/.config/bash/custom.bashrc"
if [ -f "\$customBashConfig_path" ]; then
source \$customBashConfig_path
else
echo "path to config not found (\$customBashConfig_path)"
fi
EOF
fi
fi
if skip "source zsh in ~/.zshrc"; then
if grep "source \$customZshConfig_path" ${HOME}/.zshrc >/dev/null; then
echo " Skipped: already sourced"
else
cat <<EOF >> ${HOME}/.zshrc
# fetch the custom config file for zsh (if it exists)
# customZshConfig_path is the path to the config file
customZshConfig_path="$HOME/.config/zsh/custom.zshrc"
if [ -f "\$customZshConfig_path" ]; then
source \$customZshConfig_path
else
echo ".zshrc: path to config not found (\$customZshConfig_path)"
fi
EOF
fi
fi
if skip "make zsh your standart shell"; then
zshPath=$(which zsh)
chsh -s ${zshPath}
fi
skip "activate system unit: sddm" && sudo systemctl enable sddm
skip "activate system unit: bluetooth" && sudo systemctl enable bluetooth
skip "activate system unit: ianny" && systemctl --user enable app-io.github.zefr0x.ianny@autostart.service
skip "activate & start system user unit: hypridle" && systemctl --user enable --now hypridle.service
skip "activate system unit: reflector.timer" && sudo systemctl enable reflector.timer
echo ""
## NOT ASKED AGAIN ######################################
#echo "cp and move files to other locations too?"
#echo "press enter to continue (Ctr+C to exit)"
#echo " You will not be asked again!"
#read
# link roots nvim to ours? (just a bad idea)
#read -p "do you want to link the nvim configs to root? [y/N]: " answer
#case $answer in
# [Yy]*)
# sudo mv ${rootConf}nvim ${rootBackup}
# sudo ln -s -i ${origin}nvim ${rootConf}
# ;;
# [Nn]*|"")
# ;;
#esac
echo "All done."