-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·228 lines (199 loc) · 8.37 KB
/
setup.sh
File metadata and controls
executable file
·228 lines (199 loc) · 8.37 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/usr/bin/env bash
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
log() { printf '\033[1;34m==> %s\033[0m\n' "$*"; }
warn() { printf '\033[1;33mWARN: %s\033[0m\n' "$*"; }
ok() { printf '\033[1;32m ok: %s\033[0m\n' "$*"; }
# ============================================================
# 1. DNF packages
# ============================================================
log "Installing packages from packages.list"
sudo dnf install -y $(grep -v '^\s*#' "$REPO/packages.list" | grep -v '^\s*$' | tr '\n' ' ')
# ============================================================
# 2. Special packages
# ============================================================
log "Installing Ghostty (via COPR)"
if ! command -v ghostty &>/dev/null; then
sudo dnf copr enable -y scottames/ghostty
sudo dnf install -y ghostty
else
ok "ghostty already installed"
fi
log "Installing glab (via COPR)"
if ! command -v glab &>/dev/null; then
sudo dnf copr enable -y atim/glab
sudo dnf install -y glab
else
ok "glab already installed"
fi
log "Installing starship (official installer)"
if ! command -v starship &>/dev/null; then
curl -sS https://starship.rs/install.sh | sudo sh -s -- --yes
else
ok "starship already installed"
fi
log "Installing Rust toolchain via rustup"
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
source "$HOME/.cargo/env"
rustup component add rustfmt clippy
cargo install xargo
else
ok "rustup already installed"
fi
log "Installing claude-code via npm"
if ! command -v claude &>/dev/null; then
sudo npm install -g @anthropic-ai/claude-code
else
ok "claude-code already installed"
fi
log "Installing markitdown (pipx) for /ingest-docs skill"
if ! command -v markitdown &>/dev/null; then
pipx install 'markitdown[all]'
else
ok "markitdown already installed"
fi
log "Installing 1Password (official RPM repo)"
if ! command -v 1password &>/dev/null; then
sudo rpm --import https://downloads.1password.com/linux/keys/1password.asc
sudo sh -c 'cat > /etc/yum.repos.d/1password.repo <<EOF
[1password]
name=1Password Stable Channel
baseurl=https://downloads.1password.com/linux/rpm/stable/\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey="https://downloads.1password.com/linux/keys/1password.asc"
EOF'
sudo dnf install -y 1password
else
ok "1password already installed"
fi
log "Installing Obsidian via Flatpak"
if ! flatpak info md.obsidian.Obsidian &>/dev/null 2>&1; then
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y flathub md.obsidian.Obsidian
else
ok "Obsidian already installed"
fi
flatpak override --user --socket=wayland --env=ELECTRON_OZONE_PLATFORM_HINT=auto md.obsidian.Obsidian
log "Installing Zed via Flatpak"
if ! flatpak info dev.zed.Zed &>/dev/null 2>&1; then
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y flathub dev.zed.Zed
else
ok "Zed already installed"
fi
# ============================================================
# 3. Config symlinks (~/.config/* → repo/config/*)
# ============================================================
log "Deploying config symlinks"
for dir in vim ghostty zsh git starship; do
src="$REPO/config/$dir"
dst="$CONFIG_HOME/$dir"
if [[ -L "$dst" ]]; then
ln -sfn "$src" "$dst"
ok "symlink updated: $dst"
elif [[ -e "$dst" ]]; then
warn "$dst exists and is not a symlink — backing up to ${dst}.bak"
mv "$dst" "${dst}.bak"
ln -sfn "$src" "$dst"
ok "symlink created: $dst (original backed up)"
else
ln -sfn "$src" "$dst"
ok "symlink created: $dst"
fi
done
# ============================================================
# 4. ~/.zshenv bootstrap (sets ZDOTDIR for SSH / non-Ghostty)
# ============================================================
log "Deploying ~/.zshenv and ~/.CLAUDE.md"
ln -sf "$REPO/home/.zshenv" "$HOME/.zshenv"
ok "~/.zshenv -> $REPO/home/.zshenv"
ln -sf "$REPO/home/.CLAUDE.md" "$HOME/.CLAUDE.md"
ok "~/.CLAUDE.md -> $REPO/home/.CLAUDE.md"
log "Deploying ~/.local/bin/ scripts"
mkdir -p "$HOME/.local/bin"
for name in obsidian sync-notes daily-kb-hook; do
dst="$HOME/.local/bin/$name"
if [[ -e "$dst" && ! -L "$dst" ]]; then
warn "$dst exists and is not a symlink — backing up to ${dst}.bak"
mv "$dst" "${dst}.bak"
fi
ln -sfn "$REPO/home/.local/bin/$name" "$dst"
ok "$dst -> $REPO/home/.local/bin/$name"
done
log "Deploying Claude Code config"
mkdir -p "$HOME/.claude/agents"
ln -sf "$REPO/home/.claude/settings.json" "$HOME/.claude/settings.json"
ok "~/.claude/settings.json -> $REPO/home/.claude/settings.json"
ln -sf "$REPO/home/.claude/agents/shell-runner.md" "$HOME/.claude/agents/shell-runner.md"
ok "~/.claude/agents/shell-runner.md -> $REPO/home/.claude/agents/shell-runner.md"
mkdir -p "$HOME/.claude/skills"
ln -sfn "$REPO/home/.claude/skills/sync-notes" "$HOME/.claude/skills/sync-notes"
ok "~/.claude/skills/sync-notes -> $REPO/home/.claude/skills/sync-notes"
ln -sfn "$REPO/home/.claude/skills/ingest-docs" "$HOME/.claude/skills/ingest-docs"
ok "~/.claude/skills/ingest-docs -> $REPO/home/.claude/skills/ingest-docs"
# ============================================================
# 5. System files
# ============================================================
log "Deploying system files"
sudo cp "$REPO/system/modules-load.d/l2tp.conf" /etc/modules-load.d/l2tp.conf
ok "/etc/modules-load.d/l2tp.conf"
sudo cp "$REPO/system/modprobe.d/l2tp-unblacklist.conf" /etc/modprobe.d/l2tp-unblacklist.conf
ok "/etc/modprobe.d/l2tp-unblacklist.conf"
sudo cp "$REPO/system/sudoers.d/wheel-nopasswd" /etc/sudoers.d/wheel-nopasswd
sudo chmod 440 /etc/sudoers.d/wheel-nopasswd
ok "/etc/sudoers.d/wheel-nopasswd"
sudo cp "$REPO/system/NetworkManager/dispatcher.d/99-cn-split-tunnel.sh" \
/etc/NetworkManager/dispatcher.d/99-cn-split-tunnel.sh
sudo chmod 755 /etc/NetworkManager/dispatcher.d/99-cn-split-tunnel.sh
ok "/etc/NetworkManager/dispatcher.d/99-cn-split-tunnel.sh"
sudo cp "$REPO/system/systemd/system-sleep/iwlwifi-reset.sh" \
/usr/lib/systemd/system-sleep/iwlwifi-reset.sh
sudo chmod 755 /usr/lib/systemd/system-sleep/iwlwifi-reset.sh
ok "/usr/lib/systemd/system-sleep/iwlwifi-reset.sh"
if ! lsmod | grep -q l2tp_core; then
sudo modprobe l2tp_core l2tp_netlink l2tp_ppp l2tp_ip
ok "l2tp modules loaded"
fi
if [[ ! -f /etc/chnroute.txt ]]; then
warn "/etc/chnroute.txt not found — split-tunnel VPN routing will not work."
warn "Fetch it with: curl -o /etc/chnroute.txt https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt"
fi
# ============================================================
# 6. Zsh plugins (cloned into ~/.config/zsh/, excluded from git)
# ============================================================
log "Installing Zsh plugins"
ZSH_DIR="$CONFIG_HOME/zsh"
clone_if_missing() {
local name="$1" url="$2"
if [[ ! -d "$ZSH_DIR/$name" ]]; then
git clone --depth=1 "$url" "$ZSH_DIR/$name"
ok "cloned $name"
else
ok "$name already present"
fi
}
clone_if_missing zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions
clone_if_missing zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting
clone_if_missing zsh-history-substring-search https://github.com/zsh-users/zsh-history-substring-search
# ============================================================
# 7. Vim plugins (vim-plug bootstraps itself via vimrc)
# ============================================================
log "Bootstrapping Vim plugins"
VIMINIT="set rtp+=~/.config/vim | source ~/.config/vim/vimrc" \
vim -es -u "$CONFIG_HOME/vim/vimrc" +PlugInstall +qall || true
ok "vim plugins installed"
# ============================================================
log "Setup complete."
echo ""
echo "Next steps:"
echo " - Log out and back in for group changes to take effect (libvirt, kvm)"
echo " - Run 'gh auth login' to authenticate the GitHub CLI"
echo " - Run 'glab auth login' to authenticate GitLab CLI"
echo " - Add GNOME Keyring entries for shell secrets (ANTHROPIC_VERTEX_PROJECT_ID, GH_TOKEN, etc.)"
if [[ ! -f /etc/chnroute.txt ]]; then
echo " - Fetch /etc/chnroute.txt for VPN split tunnelling (see WARN above)"
fi