-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverify_post_install_unix
More file actions
executable file
·277 lines (241 loc) · 7.7 KB
/
verify_post_install_unix
File metadata and controls
executable file
·277 lines (241 loc) · 7.7 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/usr/bin/env bash
set -euo pipefail
PASS_COUNT=0
WARN_COUNT=0
FAIL_COUNT=0
STRICT_MODE=false
JSON_MODE=false
usage() {
cat <<'EOF'
Usage: verify_post_install_unix [options]
Options:
--strict Treat warnings as failures
--json Print final summary as JSON only
-h, --help Show this help message
EOF
}
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--strict)
STRICT_MODE=true
;;
--json)
JSON_MODE=true
;;
-h | --help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
shift
done
}
say() {
if [[ "$JSON_MODE" == "false" ]]; then
printf '%s\n' "$1"
fi
}
pass() {
PASS_COUNT=$((PASS_COUNT + 1))
say "PASS: $1"
}
warn() {
if [[ "$STRICT_MODE" == "true" ]]; then
fail "$1"
return
fi
WARN_COUNT=$((WARN_COUNT + 1))
say "WARN: $1"
}
fail() {
FAIL_COUNT=$((FAIL_COUNT + 1))
say "FAIL: $1"
}
check_command() {
local cmd="$1"
if command -v "$cmd" >/dev/null 2>&1; then
pass "command '$cmd' available"
else
fail "command '$cmd' missing"
fi
}
check_optional_command() {
local cmd="$1"
local label="${2:-command '$1' available}"
local missing_label="${3:-command '$1' missing (optional)}"
if command -v "$cmd" >/dev/null 2>&1; then
pass "$label"
else
warn "$missing_label"
fi
}
check_file() {
local file="$1"
if [[ -f "$file" ]]; then
pass "file '$file' exists"
else
fail "file '$file' missing"
fi
}
check_dir() {
local dir="$1"
local label="${2:-directory '$1' exists}"
local missing_label="${3:-directory '$1' missing}"
if [[ -d "$dir" ]]; then
pass "$label"
else
warn "$missing_label"
fi
}
check_any_command() {
local label="$1"
shift
local cmd
for cmd in "$@"; do
if command -v "$cmd" >/dev/null 2>&1; then
pass "$label ($cmd)"
return 0
fi
done
warn "$label missing (tried: $*)"
return 1
}
run_check() {
local label="$1"
shift
if "$@" >/dev/null 2>&1; then
pass "$label"
else
fail "$label"
fi
}
print_summary() {
local status="ok"
if [[ "$FAIL_COUNT" -gt 0 ]]; then
status="failed"
fi
if [[ "$JSON_MODE" == "true" ]]; then
printf '{"status":"%s","strict":%s,"pass":%d,"warn":%d,"fail":%d}\n' \
"$status" "$STRICT_MODE" "$PASS_COUNT" "$WARN_COUNT" "$FAIL_COUNT"
return
fi
echo
echo "==> Summary"
printf 'PASS: %s\n' "$PASS_COUNT"
printf 'WARN: %s\n' "$WARN_COUNT"
printf 'FAIL: %s\n' "$FAIL_COUNT"
}
parse_args "$@"
say "==> Checking required commands"
check_command zsh
check_command tmux
check_command nvim
check_command git
check_command fzf
check_command zoxide
check_command starship
check_command direnv
check_command atuin
check_command btop
say "==> Checking required config files"
check_file "$HOME/.zshrc"
check_file "$HOME/.tmux.conf"
check_file "$HOME/.config/nvim/init.lua"
check_file "$HOME/.config/starship.toml"
say "==> Running syntax and startup checks"
run_check "zsh config syntax" zsh -n "$HOME/.zshrc"
run_check "tmux config parse" tmux -L utils-scripts-smoke -f "$HOME/.tmux.conf" new-session -d -s smoke
tmux -L utils-scripts-smoke kill-server >/dev/null 2>&1 || true
if command -v lua >/dev/null 2>&1; then
run_check "nvim init.lua syntax" lua -e "assert(loadfile('$HOME/.config/nvim/init.lua'))"
else
warn "command 'lua' missing; skipping standalone init.lua syntax parse"
fi
run_check "neovim headless start" nvim --headless +qa
say "==> Checking tmux plugin health"
check_file "$HOME/.tmux/plugins/tpm/tpm"
check_dir "$HOME/.tmux/plugins/tmux-sensible" "tmux plugin directory '$HOME/.tmux/plugins/tmux-sensible' exists" "tmux plugin directory '$HOME/.tmux/plugins/tmux-sensible' missing"
check_dir "$HOME/.tmux/plugins/tmux-cpu" "tmux plugin directory '$HOME/.tmux/plugins/tmux-cpu' exists" "tmux plugin directory '$HOME/.tmux/plugins/tmux-cpu' missing"
if [[ -f "$HOME/.tmux.conf" ]] && grep -Eq "set -g @qol_status_plugins 'on'" "$HOME/.tmux.conf"; then
check_dir "$HOME/.tmux/plugins/tmux-battery" "tmux plugin directory '$HOME/.tmux/plugins/tmux-battery' exists" "tmux plugin directory '$HOME/.tmux/plugins/tmux-battery' missing"
check_dir "$HOME/.tmux/plugins/tmux-network-bandwidth" "tmux plugin directory '$HOME/.tmux/plugins/tmux-network-bandwidth' exists" "tmux plugin directory '$HOME/.tmux/plugins/tmux-network-bandwidth' missing"
fi
if [[ -f "$HOME/.tmux.conf" ]] && grep -Eq "tmux_network_bandwidth_safe|tmux-network-bandwidth" "$HOME/.tmux.conf"; then
check_any_command "numfmt for tmux network throughput formatting" numfmt gnumfmt
fi
say "==> Checking monitoring tools"
if [[ "$(uname -s)" == "Darwin" ]]; then
check_command btm
if [[ "$(uname -m)" == "arm64" ]]; then
if command -v asitop >/dev/null 2>&1; then
pass "command 'asitop' available (Apple Silicon)"
else
warn "command 'asitop' missing (optional on Apple Silicon)"
fi
fi
else
if command -v nvidia-smi >/dev/null 2>&1 || [[ -e "/dev/dri" ]]; then
if command -v nvtop >/dev/null 2>&1; then
pass "command 'nvtop' available (GPU detected)"
else
warn "command 'nvtop' missing while GPU detected"
fi
else
pass "nvtop skipped (no GPU detected)"
fi
fi
say "==> Checking advanced productivity tools"
check_optional_command lazygit "command 'lazygit' available"
check_optional_command pre-commit "command 'pre-commit' available"
check_optional_command glow "command 'glow' available"
check_optional_command hyperfine "command 'hyperfine' available"
check_optional_command yq "command 'yq' available"
check_optional_command shellcheck "command 'shellcheck' available"
check_optional_command shfmt "command 'shfmt' available"
check_optional_command delta "command 'delta' available"
check_optional_command tldr "command 'tldr' available"
check_optional_command gawk "command 'gawk' available"
check_optional_command entr "command 'entr' available"
check_optional_command parallel "command 'parallel' available"
check_optional_command dua "command 'dua' available"
check_optional_command dust "command 'dust' available"
check_optional_command procs "command 'procs' available"
check_optional_command xh "command 'xh' available"
check_optional_command doggo "command 'doggo' available"
check_optional_command watchexec "command 'watchexec' available"
check_optional_command kubectl "command 'kubectl' available"
check_optional_command k9s "command 'k9s' available"
check_optional_command trivy "command 'trivy' available"
check_optional_command zellij "command 'zellij' available"
if [[ "$(uname -s)" == "Darwin" ]]; then
say "==> Checking Ghostty on macOS"
if [[ -x "/Applications/Ghostty.app/Contents/MacOS/ghostty" ]]; then
pass "Ghostty app binary exists"
if [[ -f "$HOME/.config/ghostty/config" ]]; then
validation_output=$("/Applications/Ghostty.app/Contents/MacOS/ghostty" +validate-config --config-file "$HOME/.config/ghostty/config" 2>&1 || true)
if "/Applications/Ghostty.app/Contents/MacOS/ghostty" +validate-config --config-file "$HOME/.config/ghostty/config" >/dev/null 2>&1; then
pass "Ghostty config validates"
elif [[ -z "$validation_output" ]] && "/Applications/Ghostty.app/Contents/MacOS/ghostty" +show-config >/dev/null 2>&1; then
# Ghostty may return non-zero with no diagnostics in headless shells on macOS.
pass "Ghostty config appears readable (validator returned no diagnostics)"
else
warn "Ghostty config validation failed: ${validation_output%%$'\n'*}"
fi
else
warn "Ghostty config not found at $HOME/.config/ghostty/config"
fi
else
warn "Ghostty app not found at /Applications/Ghostty.app"
fi
fi
print_summary
if [[ "$FAIL_COUNT" -gt 0 ]]; then
exit 1
fi
say "Smoke test completed successfully."