-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·106 lines (81 loc) · 2.34 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·106 lines (81 loc) · 2.34 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
#!/bin/bash
set -e
echo "🚀 Setting up dotfiles"
# ---------------------------------------------------------
# Detect OS and install packages
# ---------------------------------------------------------
if [[ "$(uname)" == "Darwin" ]]; then
echo "🍎 macOS detected"
if ! command -v brew &>/dev/null; then
echo "🍺 Installing Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
if [[ -f /opt/homebrew/bin/brew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -f /usr/local/bin/brew ]]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
fi
brew install gnupg chezmoi
elif [[ "$(uname)" == "Linux" ]]; then
echo "🐧 Linux detected"
if command -v pacman &>/dev/null; then
echo "🔵 Manjaro/Arch detected"
sudo pacman -S --needed --noconfirm gnupg chezmoi
elif command -v apt &>/dev/null; then
echo "🟠 Ubuntu/Debian detected"
sudo apt update
sudo apt install -y gnupg chezmoi
else
echo "❌ Unsupported Linux distribution"
exit 1
fi
else
echo "❌ Unsupported operating system"
exit 1
fi
# ---------------------------------------------------------
# GPG
# ---------------------------------------------------------
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"
export PASS_GPG_KEY="$(
gpg --list-keys \
--keyid-format long \
--with-colons |
awk -F: '$1 == "pub" { print $5; exit }'
)"
if [[ -z "$PASS_GPG_KEY" ]]; then
echo "❌ Could not determine GPG key"
exit 1
fi
echo "🔑 GPG key: $PASS_GPG_KEY"
# ---------------------------------------------------------
# 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"