-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·129 lines (108 loc) · 4.53 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·129 lines (108 loc) · 4.53 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
#!/opt/homebrew/bin/bash
# shellcheck disable=SC2154 # Variables like $bold defined in lib/colors.sh
# Unified setup script: initial setup and daily maintenance.
# Safe to run anytime - all operations are idempotent or diff-based.
#
# Configuration (set in ~/.env.sh):
# GITLAB_GROUP - GitLab group/namespace to sync (optional)
# GITLAB_EXCLUDE_DIRS - Pipe-separated dirs to exclude (optional)
# DOCK_IGNORE_APPS - Pipe-separated apps to skip in Dock management (optional)
set -euo pipefail
# Parse flags
export CLEAN_CACHES=false
for arg in "$@"; do
case "$arg" in
--clean) export CLEAN_CACHES=true ;;
esac
done
# Guard: refuse to run as root
if [[ $EUID -eq 0 ]]; then
echo "Error: Do not run this script as root" >&2
exit 1
fi
export SETUP="${HOME:?}/projects/setup"
export DOTFILES="$SETUP/linked"
# Validate critical paths exist before proceeding
[[ -d "$SETUP" ]] || {
echo "Error: SETUP directory not found: $SETUP" >&2
exit 1
}
[[ -d "$DOTFILES" ]] || {
echo "Error: DOTFILES directory not found: $DOTFILES" >&2
exit 1
}
cd "$SETUP"
# Utilities
source lib/colors.sh
source lib/backup.sh
source lib/links.sh
source lib/packages.sh
# Trap handler for cleanup on interruption
CURRENT_STEP=""
cleanup_on_exit() {
stop_sudo_keepalive 2>/dev/null || true
rm -f "${SUDO_PASS_FILE:-}" "${ASKPASS_SCRIPT:-}"
}
cleanup_on_interrupt() {
cleanup_on_exit
echo "" >&2
echo -e "${yellow}⚠ Setup interrupted!${reset}" >&2
if [[ -n "$CURRENT_STEP" ]]; then
echo -e "Stopped during: ${bold}$CURRENT_STEP${reset}" >&2
fi
echo -e "To resume, run: ${coral}$SETUP/run.sh${reset}" >&2
exit 130
}
trap cleanup_on_exit EXIT
trap cleanup_on_interrupt INT TERM
# Step runner with counter and section grouping
STEP_CURRENT=0
STEP_TOTAL=13
run_step() {
local title="$1" file="$2"
((STEP_CURRENT++)) || true
CURRENT_STEP="${title,,}"
echo -e "${bold}${sky}▶ [${STEP_CURRENT}/${STEP_TOTAL}] ${title}${reset}"
# shellcheck source=/dev/null
source "$file"
}
section() {
echo ""
echo -e "${bold}${magenta}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${reset}"
echo -e "${bold}${magenta} $1${reset}"
echo -e "${bold}${magenta}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${reset}"
echo ""
}
# ── Start ────────────────────────────────────────────────────────────────────
echo ""
echo -e "${bold}${coral}┌─────────────────────────────────┐${reset}"
echo -e "${bold}${coral}│ Mac Configuration Script │${reset}"
echo -e "${bold}${coral}└─────────────────────────────────┘${reset}"
section "Install"
run_step "Updating setup repo" steps/01_update_repo.sh
run_step "Configuring Homebrew taps" steps/02_homebrew_taps.sh
run_step "Upgrading Homebrew formulae" steps/03_homebrew_upgrade.sh
run_step "Installing Homebrew formulae" steps/04_homebrew_install.sh
run_step "Cleaning caches" steps/05_cache_cleanup.sh
run_step "Updating development tools" steps/10_tool_updates.sh
run_step "Installing VSCode extensions" steps/09_vscode_extensions.sh
section "Configure"
run_step "Creating symlinks" steps/06_symlinks.sh
run_step "Configuring tools" steps/07_configure_tools.sh
run_step "Configuring macOS" steps/08_macos.sh
section "Sync"
run_step "Syncing GitLab repos" steps/11_gitlab_sync.sh
section "Sudo"
run_step "Privileged operations" steps/12_privileged.sh
run_step "macOS software updates" steps/13_software_update.sh
# ── Done ────────────────────────────────────────────────────────────────────
echo ""
echo -e "${bold}${coral}┌─────────────────────────────────┐${reset}"
echo -e "${bold}${coral}│ Setup complete! │${reset}"
echo -e "${bold}${coral}└─────────────────────────────────┘${reset}"
echo ""
info "See ${coral}$SETUP/MANUAL_STEPS.md${reset}${dim} for remaining manual configuration."
if [[ "${FIREFOX_NEEDS_SETUP:-}" == "1" ]]; then
warn "Firefox settings were skipped. Launch Firefox, sign in, then run:"
info " ${coral}$SETUP/configure/after_signin.sh${reset}"
fi