Repository navigation
Expand file tree
/
Copy pathbootstrap-macos.sh
More file actions
86 lines (71 loc) · 1.99 KB
/
Copy pathbootstrap-macos.sh
File metadata and controls
86 lines (71 loc) · 1.99 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
#!/usr/bin/env bash
set -euo pipefail
echo "🍎 Setting up dotfiles (macOS)"
# ---------------------------------------------------------
# Install and Configure Homebrew
# ---------------------------------------------------------
if ! command -v brew &>/dev/null; then
echo "🍺 Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if [[ -x /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
else
echo "❌ Homebrew not found after installation"
exit 1
fi
# ---------------------------------------------------------
# GPG
# ---------------------------------------------------------
if ! command -v gpg &>/dev/null; then
echo "🍺 Installing GPG"
brew install gnupg
fi
if command -v gpg &>/dev/null; then
echo "✅ GPG is installed"
else
echo "❌ GPG installation failed"
exit 1
fi
echo "🗝️ Importing GPG keys"
gpg --import "$HOME/privatekey.asc"
gpg --import "$HOME/publickey.asc"
PASS_GPG_KEY="$(
gpg --list-keys \
--keyid-format long \
--with-colons |
awk -F: '$1 == "pub" { print $5; exit }'
)"
export PASS_GPG_KEY
if [[ -z "$PASS_GPG_KEY" ]]; then
echo "❌ Could not determine GPG key"
exit 1
fi
echo "🔑 GPG key: $PASS_GPG_KEY"
# ---------------------------------------------------------
# Chezmoi
# ---------------------------------------------------------
echo "🍺 Installing chezmoi"
brew install chezmoi
if command -v chezmoi &>/dev/null; then
echo "✅ Chezmoi is installed"
else
echo "❌ Chezmoi installation failed"
exit 1
fi
if [[ -d "$(chezmoi source-path)/.git" ]]; then
echo "ℹ️ Chezmoi already initialized"
chezmoi update
echo "✅ Chezmoi updated"
exit 0
fi
if [[ -z "${GITHUB_USERNAME:-}" ]]; then
echo "❌ GITHUB_USERNAME is not set"
exit 1
fi
echo "🔧 Initializing Chezmoi"
chezmoi init "$GITHUB_USERNAME"
chezmoi apply
echo "✅ Dotfiles setup complete"