-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·91 lines (77 loc) · 3.81 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·91 lines (77 loc) · 3.81 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
#!/usr/bin/env bash
#
# bootstrap.sh — one-shot development environment bootstrap
# Usage: git clone https://github.com/for13to1/dotfiles.git ~/dotfiles
# cd ~/dotfiles && bash bootstrap.sh
#
set -euo pipefail
SCRIPT_DIR="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# ── Shared infrastructure (colored output etc., see _scripts/common.sh) ─
# shellcheck disable=SC1091
source "$SCRIPT_DIR/_scripts/common.sh"
# ── 1. Detect the operating system ──────────────────────────────
OS="$(uname -s)"
info "Detected OS: $OS"
# ── 2. Package manager & environment bootstrap ────────────────
case "$OS" in
Darwin*)
if ! bash "$DOTFILES_DIR/_bootstrap/pkg-mac.sh" "$DOTFILES_DIR"; then
error "macOS package bootstrap did not complete. Please address the requirements above and rerun bootstrap.sh."
fi
;;
Linux*)
if ! bash "$DOTFILES_DIR/_bootstrap/pkg-linux.sh" "$DOTFILES_DIR"; then
error "Linux package bootstrap did not complete. Please address the requirements above and rerun bootstrap.sh."
fi
;;
*)
error "Unsupported OS: $OS"
;;
esac
# ── 3-5. Host base configuration ────────────────────────────────
bash "$DOTFILES_DIR/_bootstrap/ssh.sh"
bash "$DOTFILES_DIR/_bootstrap/git.sh" "$DOTFILES_DIR"
bash "$DOTFILES_DIR/_bootstrap/shell.sh" "$OS"
# ── 6. Mount configuration files (Stow) ─────────────────────────
info "Mounting configuration files with Stow..."
## 1. Resolve the module list (single source of truth, see _scripts/modules.conf).
# The module list is emitted one module per line and read into an array.
STOW_MODULES=()
if [[ -f "$DOTFILES_DIR/_scripts/modules.conf" && -f "$DOTFILES_DIR/_scripts/list-modules.sh" ]]; then
# macOS ships bash 3.2 without mapfile, so use a while-read loop.
while IFS= read -r _module; do
STOW_MODULES+=("$_module")
done < <(bash "$DOTFILES_DIR/_scripts/list-modules.sh" "$DOTFILES_DIR/_scripts/modules.conf")
unset _module
fi
if (( ${#STOW_MODULES[@]} == 0 )); then
warn "No modules found in _scripts/modules.conf; nothing to mount"
else
info "Loaded modules from _scripts/modules.conf: ${STOW_MODULES[*]}"
fi
## 2. Run the Stow mount.
# The single entry point handles preflight, conflict backup, shared dir creation,
# `stow -R`, and post-mount verification. Mount failures only warn, never block.
if bash "$DOTFILES_DIR/_scripts/stow-sync.sh" \
"$DOTFILES_DIR" "$HOME" "${STOW_MODULES[@]}"; then
ok "Stow configuration mounted"
else
warn "Stow mount had failures (see errors above); run 'make sync' later to fix"
fi
# ── 7. Sync tmux plugins (tpm) ──────────────────────────────────
echo ""
info "Syncing tmux plugins (tpm)..."
if bash "$DOTFILES_DIR/_scripts/tmux-plugins.sh"; then
ok "tmux plugins ready"
else
warn "tmux plugin sync had errors; run 'bash _scripts/tmux-plugins.sh' later to retry"
fi
# ── 8. Sync editor plugins ──────────────────────────────────────
echo ""
bash "$DOTFILES_DIR/_bootstrap/editors.sh"
# ── 9. Deploy custom scripts ────────────────────────────────────
bash "$DOTFILES_DIR/_bootstrap/tools.sh" "$DOTFILES_DIR"
# ── 10. Done ────────────────────────────────────────────────────
echo ""
ok "🎉 All done! Restart your terminal or run 'source ~/.zshrc' to apply the config."
echo ""