-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap-packages.sh
More file actions
executable file
·473 lines (406 loc) · 17.1 KB
/
bootstrap-packages.sh
File metadata and controls
executable file
·473 lines (406 loc) · 17.1 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
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
#!/bin/bash
# Full bootstrap for Arch/EndeavourOS - from zero to working desktop
# One-liner for fresh machine:
# bash <(curl -s https://raw.githubusercontent.com/SeanoNET/dotfiles/main/bootstrap-packages.sh)
set -euo pipefail
# Allow individual package installs to fail without aborting the script
install_failed=0
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Dotfiles Bootstrap - Full Desktop Provisioning${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# Check if running as root
if [[ $EUID -eq 0 ]]; then
echo -e "${RED}✗ This script should NOT be run as root${NC}"
echo -e " Run without sudo - the script will ask for password when needed"
exit 1
fi
# ── Auto-clone logic ─────────────────────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOTFILES_DIR="$HOME/dotfiles"
if [[ -d "$SCRIPT_DIR/.git" && -d "$SCRIPT_DIR/i3" && -d "$SCRIPT_DIR/zsh" ]]; then
DOTFILES_DIR="$SCRIPT_DIR"
echo -e "${GREEN}✓${NC} Running from dotfiles repo: $DOTFILES_DIR"
elif [[ -d "$DOTFILES_DIR/.git" && -d "$DOTFILES_DIR/i3" ]]; then
echo -e "${GREEN}✓${NC} Found existing dotfiles at $DOTFILES_DIR"
else
echo -e "${YELLOW}→${NC} Cloning dotfiles to $DOTFILES_DIR..."
sudo pacman -S --needed --noconfirm git
git clone https://github.com/SeanoNET/dotfiles.git "$DOTFILES_DIR"
echo -e "${GREEN}✓${NC} Dotfiles cloned"
echo -e "${YELLOW}→${NC} Re-executing from cloned repo..."
exec bash "$DOTFILES_DIR/bootstrap-packages.sh"
fi
# ── Helper functions ─────────────────────────────────────────────────
is_installed() {
pacman -Qi "$1" &>/dev/null
}
install_if_missing() {
local package=$1
local source=$2 # "official" or "aur"
if is_installed "$package"; then
echo -e "${GREEN}✓${NC} $package already installed"
return 0
fi
echo -e "${YELLOW}→${NC} Installing $package..."
if [[ "$source" == "official" ]]; then
sudo pacman -S --noconfirm --needed "$package" || true
else
$AUR_HELPER -S --noconfirm --needed "$package" || true
fi
if is_installed "$package"; then
echo -e "${GREEN}✓${NC} $package installed successfully"
else
echo -e "${RED}✗${NC} Failed to install $package (continuing...)"
install_failed=1
fi
}
is_flatpak_installed() {
flatpak list --app --columns=application 2>/dev/null | grep -q "^$1$"
}
# ── AUR helper detection ────────────────────────────────────────────
echo -e "${BLUE}Checking for AUR helper...${NC}"
if command -v yay &>/dev/null; then
AUR_HELPER="yay"
echo -e "${GREEN}✓${NC} Found yay"
elif command -v paru &>/dev/null; then
AUR_HELPER="paru"
echo -e "${GREEN}✓${NC} Found paru"
else
echo -e "${RED}✗${NC} No AUR helper found (yay or paru)"
echo -e "${YELLOW}Installing yay...${NC}"
sudo pacman -S --needed --noconfirm git base-devel
cd /tmp
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si --noconfirm
cd ~
rm -rf /tmp/yay-bin
AUR_HELPER="yay"
echo -e "${GREEN}✓${NC} yay installed"
fi
# ── Official Repository Packages ────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Official Repository Packages${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
OFFICIAL_PACKAGES=(
# WM / Display
"i3-wm"
"polybar"
"picom"
"rofi"
"dunst"
"xss-lock"
"i3lock"
"dex"
"feh"
"flameshot"
"scrot"
"imagemagick"
"xorg-setxkbmap"
"xorg-xbacklight"
"polkit-gnome"
"nautilus"
"xscreensaver"
# Terminals
"alacritty"
"tmux"
# Shell
"zsh"
"stow"
# Fonts
"ttf-jetbrains-mono"
"ttf-jetbrains-mono-nerd"
# CLI Tools
"fzf"
"zoxide"
"eza"
"helix"
"bat"
"glow"
"git-delta"
"playerctl"
"yazi"
"lazygit"
"starship"
"python"
"python-i3ipc"
"pacman-contrib"
# Dev Tools
"docker"
"docker-compose"
"github-cli"
"kubectl"
"kubectx"
"git"
# Qt Theming
"qt5ct"
"qt6ct"
# Utilities
"arandr"
"xclip"
"jq"
"fd"
"btop"
"unzip"
# Networking / Audio
"networkmanager"
"nm-connection-editor"
"wireplumber"
"pavucontrol"
# Editors
"code"
"zed"
# Apps
"spotify-player"
"obsidian"
"steam"
"power-profiles-daemon"
# Flatpak (installed here so the flatpak section can use it)
"flatpak"
)
for package in "${OFFICIAL_PACKAGES[@]}"; do
install_if_missing "$package" "official"
done
# ── AUR Packages ────────────────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} AUR Packages${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
AUR_PACKAGES=(
"1password-beta"
"azure-cli"
"autotiling"
"bluetuith"
"ghostty"
"bambustudio-bin"
"scrcpy"
"zen-browser-bin"
)
for package in "${AUR_PACKAGES[@]}"; do
install_if_missing "$package" "aur"
done
# ── Flatpak Packages ───────────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Flatpak Packages${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
if ! flatpak remote-list 2>/dev/null | grep -q flathub; then
echo -e "${YELLOW}→${NC} Adding Flathub remote..."
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
echo -e "${GREEN}✓${NC} Flathub remote added"
else
echo -e "${GREEN}✓${NC} Flathub remote already configured"
fi
FLATPAK_PACKAGES=(
"com.discordapp.Discord"
)
for app in "${FLATPAK_PACKAGES[@]}"; do
if is_flatpak_installed "$app"; then
echo -e "${GREEN}✓${NC} $app already installed"
else
echo -e "${YELLOW}→${NC} Installing $app..."
flatpak install -y flathub "$app"
echo -e "${GREEN}✓${NC} $app installed"
fi
done
# ── Install-Script Tools ───────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Install-Script Tools (oh-my-zsh, zinit, nvm, tpm)${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# oh-my-zsh
if [[ -d "$HOME/.oh-my-zsh" ]]; then
echo -e "${GREEN}✓${NC} oh-my-zsh already installed"
else
echo -e "${YELLOW}→${NC} Installing oh-my-zsh..."
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo -e "${GREEN}✓${NC} oh-my-zsh installed"
fi
# zinit
ZINIT_HOME="$HOME/.local/share/zinit/zinit.git"
if [[ -d "$ZINIT_HOME" ]]; then
echo -e "${GREEN}✓${NC} zinit already installed"
else
echo -e "${YELLOW}→${NC} Installing zinit..."
mkdir -p "$(dirname "$ZINIT_HOME")"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
echo -e "${GREEN}✓${NC} zinit installed"
fi
# nvm
if [[ -d "$HOME/.nvm" ]]; then
echo -e "${GREEN}✓${NC} nvm already installed"
else
echo -e "${YELLOW}→${NC} Installing nvm..."
export NVM_DIR="$HOME/.nvm"
PROFILE=/dev/null bash -c "$(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh)"
echo -e "${GREEN}✓${NC} nvm installed"
fi
# tpm (tmux plugin manager)
TPM_DIR="$HOME/.config/tmux/plugins/tpm"
if [[ -d "$TPM_DIR" ]]; then
echo -e "${GREEN}✓${NC} tpm already installed"
else
echo -e "${YELLOW}→${NC} Installing tpm..."
mkdir -p "$(dirname "$TPM_DIR")"
git clone https://github.com/tmux-plugins/tpm "$TPM_DIR"
echo -e "${GREEN}✓${NC} tpm installed"
fi
# ── GNU Stow Symlinks ──────────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} GNU Stow Symlinks${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
BACKUP_DIR="$HOME/.dotfiles-backup/$(date +%Y%m%d-%H%M%S)"
STOW_PACKAGES=(
alacritty
background
ghostty
git
helix
i3
lazygit
picom
polybar
rofi
starship
tmux
vscode
xprofile
yazi
zed
zsh
)
for pkg in "${STOW_PACKAGES[@]}"; do
if [[ -d "$DOTFILES_DIR/$pkg" ]]; then
echo -e "${YELLOW}→${NC} Stowing $pkg..."
# Back up existing real files before stow overwrites them
while IFS= read -r target; do
dest="$HOME/$target"
if [[ -f "$dest" && ! -L "$dest" ]]; then
mkdir -p "$BACKUP_DIR/$(dirname "$target")"
cp "$dest" "$BACKUP_DIR/$target"
echo -e " ${BLUE}↪${NC} Backed up $target"
fi
done < <(cd "$DOTFILES_DIR/$pkg" && find . -type f | sed 's|^\./||')
# Adopt existing files so stow can replace them with symlinks
stow --dir="$DOTFILES_DIR" --target="$HOME" --adopt "$pkg" 2>/dev/null || true
# Restore dotfiles versions and create proper symlinks
(cd "$DOTFILES_DIR" && git checkout -- "$pkg")
stow --dir="$DOTFILES_DIR" --target="$HOME" --restow "$pkg" 2>&1 | while read -r line; do
echo -e " ${RED}$line${NC}"
done
echo -e "${GREEN}✓${NC} $pkg stowed"
else
echo -e "${YELLOW}⚠${NC} $pkg directory not found, skipping"
fi
done
# ── Rofi Theme ──────────────────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Rofi Theme${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
ROFI_THEME_DIR="$HOME/.local/share/rofi/themes"
ROFI_THEME_FILE="$ROFI_THEME_DIR/spotlight-dark.rasi"
if [[ -f "$ROFI_THEME_FILE" ]]; then
echo -e "${GREEN}✓${NC} Rofi spotlight-dark theme already installed"
else
echo -e "${YELLOW}→${NC} Installing rofi spotlight-dark theme..."
mkdir -p "$ROFI_THEME_DIR"
TMPDIR=$(mktemp -d)
git clone --depth 1 https://github.com/newmanls/rofi-themes-collection.git "$TMPDIR"
cp "$TMPDIR/themes/spotlight-dark.rasi" "$ROFI_THEME_FILE"
rm -rf "$TMPDIR"
echo -e "${GREEN}✓${NC} Rofi theme installed"
fi
# ── Post-Installation Configuration ─────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Post-Installation Configuration${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
# SSH setup
if [[ -d "$HOME/.ssh" ]]; then
echo -e "${GREEN}✓${NC} ~/.ssh directory exists"
else
echo -e "${YELLOW}→${NC} Creating ~/.ssh directory..."
mkdir -p "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
echo -e "${GREEN}✓${NC} ~/.ssh directory created"
fi
if [[ -f "$HOME/.ssh/id_ed25519" ]]; then
echo -e "${GREEN}✓${NC} SSH key already exists"
else
echo -e "${YELLOW}→${NC} Generating SSH key..."
ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" -C "$USER@$(hostname)"
echo -e "${GREEN}✓${NC} SSH key generated"
echo -e "${YELLOW}⚠${NC} Public key:"
cat "$HOME/.ssh/id_ed25519.pub"
echo ""
fi
# Docker service
if systemctl is-enabled docker &>/dev/null; then
echo -e "${GREEN}✓${NC} Docker service already enabled"
else
echo -e "${YELLOW}→${NC} Enabling Docker service..."
sudo systemctl enable --now docker
echo -e "${GREEN}✓${NC} Docker service enabled"
fi
# Docker group
if groups | grep -q docker; then
echo -e "${GREEN}✓${NC} User already in docker group"
else
echo -e "${YELLOW}→${NC} Adding user to docker group..."
sudo usermod -aG docker "$USER"
echo -e "${GREEN}✓${NC} User added to docker group"
fi
# power-profiles-daemon
if systemctl is-enabled power-profiles-daemon &>/dev/null; then
echo -e "${GREEN}✓${NC} power-profiles-daemon already enabled"
else
echo -e "${YELLOW}→${NC} Enabling power-profiles-daemon..."
sudo systemctl enable --now power-profiles-daemon
echo -e "${GREEN}✓${NC} power-profiles-daemon enabled"
fi
# Change shell to zsh
if [[ "$SHELL" == *"zsh"* ]]; then
echo -e "${GREEN}✓${NC} Default shell is already zsh"
else
echo -e "${YELLOW}→${NC} Changing default shell to zsh..."
chsh -s "$(which zsh)"
echo -e "${GREEN}✓${NC} Default shell changed to zsh"
fi
# tmux plugins (headless install)
if [[ -x "$TPM_DIR/bin/install_plugins" ]]; then
echo -e "${YELLOW}→${NC} Installing tmux plugins..."
"$TPM_DIR/bin/install_plugins" || true
echo -e "${GREEN}✓${NC} tmux plugins installed"
else
echo -e "${YELLOW}⚠${NC} tpm install_plugins not found, skip tmux plugin install"
fi
# ── Summary ─────────────────────────────────────────────────────────
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN} Bootstrap complete!${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e "${YELLOW}Manual steps remaining:${NC}"
echo -e " 1. Log out and back in (docker group + shell change)"
echo -e " 2. Set up monitor layout with arandr"
echo -e " 3. Resolve any stow conflicts printed above"
echo -e " 4. In tmux: prefix + I (if tpm plugin install didn't run)"
echo -e " 5. Run: nvm install --lts (for Node.js)"
echo ""