-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
118 lines (103 loc) Β· 3.33 KB
/
Copy pathinstall.sh
File metadata and controls
118 lines (103 loc) Β· 3.33 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
#!/usr/bin/env bash
# Exit immediately if there is any error
set -euo pipefail
# Parse arguments
SERVER_ONLY=false
while [[ $# -gt 0 ]]; do
case $1 in
--server)
SERVER_ONLY=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: ./install.sh [--server]"
exit 1
;;
esac
done
echo "π Starting dotfiles installation..."
# Set up local device
mkdir -p ~/proj
# Clone my dotfiles repo to ~/proj/dotfiles (skip if already exists)
if [ ! -d ~/proj/dotfiles ]; then
echo "π₯ Cloning dotfiles repository..."
git clone https://github.com/brendanfalk/dotfiles.git ~/proj/dotfiles
else
echo "β Dotfiles already cloned"
fi
# Install brew
if ! command -v brew &> /dev/null; then
echo "πΊ Installing Homebrew..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to PATH for Apple Silicon Macs
if [[ $(uname -m) == "arm64" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
else
echo "β Homebrew already installed"
fi
# Symlink mackup config file to ~/.mackup.cfg (idempotent)
if [ ! -L ~/.mackup.cfg ] && [ ! -f ~/.mackup.cfg ]; then
echo "π Symlinking mackup config..."
ln -s ~/proj/dotfiles/.mackup.cfg ~/.mackup.cfg
elif [ ! -L ~/.mackup.cfg ]; then
echo "β οΈ ~/.mackup.cfg exists but is not a symlink. Please backup and remove it first."
else
echo "β Mackup config already symlinked"
fi
# Install Mackup
if ! command -v mackup &> /dev/null; then
echo "π¦ Installing mackup..."
brew install mackup
else
echo "β Mackup already installed"
fi
# Install packages based on mode
if [ "$SERVER_ONLY" = true ]; then
echo "π¦ Installing CLI tools only (server mode)..."
# Install only brew formulas, skip casks and mas
grep "^brew " ~/proj/dotfiles/Mackup/.Brewfile | while read -r line; do
package=$(echo "$line" | awk '{print $2}' | tr -d '"')
if brew list "$package" &>/dev/null; then
echo "β $package already installed"
else
eval "HOMEBREW_NO_AUTO_UPDATE=1 $line" || true
fi
done
else
echo "π¦ Installing CLI tools and desktop applications..."
HOMEBREW_NO_AUTO_UPDATE=1 brew bundle --no-lock --file ~/proj/dotfiles/Mackup/.Brewfile || true
fi
# Install additional npm packages
if command -v npm &> /dev/null; then
if npm list -g @sitespeed.io/throttle &>/dev/null; then
echo "β @sitespeed.io/throttle already installed"
else
echo "π¦ Installing npm packages..."
npm i -g @sitespeed.io/throttle
fi
fi
# Restore all configuration files
echo "π Restoring configuration files with mackup..."
mackup restore --force
# Install additional fzf settings (idempotent)
if command -v fzf &> /dev/null; then
if [ -f ~/.fzf.bash ] || [ -f ~/.fzf.zsh ]; then
echo "β fzf already configured"
else
echo "βοΈ Setting up fzf..."
$(brew --prefix)/opt/fzf/install --all --no-update-rc --no-bash --no-fish
fi
fi
# Run custom macOS configuration (only on macOS, skip on servers)
if [ "$SERVER_ONLY" = false ] && [[ "$OSTYPE" == "darwin"* ]]; then
echo "βοΈ Running custom macOS configuration..."
bash ~/proj/dotfiles/custom
fi
echo "β¨ Installation complete!"
if [ "$SERVER_ONLY" = false ]; then
echo "π‘ Restart your system for all settings to take effect"
else
echo "π‘ Server mode: Desktop apps were not installed"
fi