-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate-install.sh
More file actions
executable file
·401 lines (343 loc) · 13.1 KB
/
validate-install.sh
File metadata and controls
executable file
·401 lines (343 loc) · 13.1 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#!/bin/bash
# Post-Installation Validation Script
# Verifies that install.sh completed successfully
# Run this after installation to confirm everything is set up correctly
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DOTFILES_DIR="$(dirname "$SCRIPT_DIR")"
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
CHECKS_PASSED=0
CHECKS_FAILED=0
CHECKS_WARNING=0
print_header() {
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}========================================${NC}"
}
print_check() {
local status=$1
local message=$2
if [ "$status" = "pass" ]; then
echo -e "${GREEN}✓${NC} $message"
((CHECKS_PASSED++))
elif [ "$status" = "fail" ]; then
echo -e "${RED}✗${NC} $message"
((CHECKS_FAILED++))
elif [ "$status" = "warn" ]; then
echo -e "${YELLOW}⚠${NC} $message"
((CHECKS_WARNING++))
fi
}
validate_homebrew() {
print_header "Homebrew Installation"
if command -v brew >/dev/null 2>&1; then
print_check "pass" "Homebrew is installed"
# Check brew doctor
if brew doctor >/dev/null 2>&1; then
print_check "pass" "Homebrew health check passed"
else
print_check "warn" "Homebrew reports warnings (run 'brew doctor' for details)"
fi
# Check for common packages
local packages=("git" "zsh" "vim" "tmux" "openssl")
for pkg in "${packages[@]}"; do
if brew list "$pkg" >/dev/null 2>&1; then
print_check "pass" "$pkg installed via Homebrew"
else
print_check "warn" "$pkg not installed"
fi
done
else
print_check "fail" "Homebrew not installed"
fi
}
validate_vault() {
print_header "Vault System"
# Check if vault-key directory exists
if [ -d "$DOTFILES_DIR/vault-key" ]; then
print_check "pass" "vault-key directory exists"
# Check for password.txt
if [ -f "$DOTFILES_DIR/vault-key/password.txt" ]; then
print_check "pass" "Vault password file exists"
# Check if VAULT_PASSWORD is set
if [ -n "$VAULT_PASSWORD" ]; then
print_check "pass" "VAULT_PASSWORD environment variable is set"
else
print_check "warn" "VAULT_PASSWORD not set (may need to source shell config)"
fi
else
print_check "warn" "password.txt not found (vault may not be decrypted)"
fi
else
print_check "warn" "vault-key directory not found (vault may not be used)"
fi
}
validate_symlinks() {
print_header "Symlink Configuration"
# Check critical symlinks
local symlinks=(
"$HOME/.zshrc"
"$HOME/.bashrc"
"$HOME/.vimrc"
)
for link in "${symlinks[@]}"; do
if [ -L "$link" ]; then
local target=$(readlink "$link")
print_check "pass" "$(basename $link) → $target"
elif [ -f "$link" ]; then
print_check "warn" "$(basename $link) exists but is not a symlink"
else
print_check "fail" "$(basename $link) not found"
fi
done
# Check .workrc for workenv
if [ -L "$HOME/.workrc" ] || [ -f "$HOME/.workrc" ]; then
print_check "pass" ".workrc exists (required for workenv)"
else
print_check "warn" ".workrc not found (workenv may not function)"
fi
}
validate_ssh() {
print_header "SSH Configuration"
# Check SSH directory
if [ -d "$HOME/.ssh" ]; then
print_check "pass" "~/.ssh directory exists"
# Check SSH directory permissions
local ssh_perms=$(stat -f "%A" "$HOME/.ssh" 2>/dev/null || stat -c "%a" "$HOME/.ssh" 2>/dev/null)
if [ "$ssh_perms" = "700" ]; then
print_check "pass" "~/.ssh permissions correct (700)"
else
print_check "warn" "~/.ssh permissions: $ssh_perms (should be 700)"
fi
# Check for SSH keys
local key_count=$(find "$HOME/.ssh" -name "*.pub" 2>/dev/null | wc -l | tr -d ' ')
if [ "$key_count" -gt 0 ]; then
print_check "pass" "Found $key_count SSH public key(s)"
else
print_check "warn" "No SSH public keys found"
fi
# Check ssh-agent
if ssh-add -l >/dev/null 2>&1; then
local loaded_keys=$(ssh-add -l | wc -l | tr -d ' ')
print_check "pass" "ssh-agent running with $loaded_keys key(s) loaded"
else
print_check "warn" "ssh-agent not running or no keys loaded"
fi
# Check for ssh-keys.txt config
if [ -f "$DOTFILES_DIR/vault-key/ssh-keys.txt" ]; then
print_check "pass" "ssh-keys.txt configuration exists"
else
print_check "warn" "ssh-keys.txt not found (SSH auto-setup may not work)"
fi
else
print_check "fail" "~/.ssh directory not found"
fi
}
validate_node() {
print_header "Node.js / NVM"
# Check if NVM is installed
export NVM_DIR="$HOME/.nvm"
if [ -s "$NVM_DIR/nvm.sh" ]; then
print_check "pass" "NVM installed"
# Source NVM
. "$NVM_DIR/nvm.sh"
# Check installed Node versions
local node_versions=$(nvm list 2>/dev/null | grep -c "v" || echo "0")
if [ "$node_versions" -gt 0 ]; then
print_check "pass" "Node.js: $node_versions version(s) installed"
# Check current version
if command -v node >/dev/null 2>&1; then
local current_node=$(node --version)
print_check "pass" "Current Node version: $current_node"
fi
else
print_check "warn" "No Node.js versions installed via NVM"
fi
# Check for npm
if command -v npm >/dev/null 2>&1; then
print_check "pass" "npm is available"
else
print_check "warn" "npm not found"
fi
else
print_check "warn" "NVM not installed (optional)"
fi
}
validate_python() {
print_header "Python / pyenv"
# Check if pyenv is installed
export PYENV_ROOT="$HOME/.pyenv"
if [ -d "$PYENV_ROOT" ]; then
print_check "pass" "pyenv installed"
# Source pyenv
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv >/dev/null 2>&1; then
eval "$(pyenv init -)"
# Check installed Python versions
local python_versions=$(pyenv versions 2>/dev/null | wc -l | tr -d ' ')
if [ "$python_versions" -gt 1 ]; then
print_check "pass" "Python: $python_versions version(s) installed"
else
print_check "warn" "No Python versions installed via pyenv"
fi
# Check for nvim-provider environment
if pyenv versions 2>/dev/null | grep -q "nvim-provider"; then
print_check "pass" "nvim-provider environment exists (for Neovim)"
# Verify pynvim is installed
if pyenv activate nvim-provider 2>/dev/null && python -c "import pynvim" 2>/dev/null; then
print_check "pass" "pynvim package installed in nvim-provider"
else
print_check "warn" "pynvim may not be installed in nvim-provider"
fi
else
print_check "warn" "nvim-provider environment not found (Neovim Python support may not work)"
fi
fi
else
print_check "warn" "pyenv not installed (optional)"
fi
}
validate_shell() {
print_header "Shell Configuration"
# Check default shell
local current_shell=$(echo $SHELL)
if [[ "$current_shell" == *"zsh"* ]]; then
print_check "pass" "Default shell is zsh: $current_shell"
elif [[ "$current_shell" == *"bash"* ]]; then
print_check "warn" "Default shell is bash (install.sh sets zsh)"
else
print_check "warn" "Default shell: $current_shell (unexpected)"
fi
# Check if DOTFILES is set
if [ -n "$DOTFILES" ]; then
print_check "pass" "DOTFILES environment variable set: $DOTFILES"
else
print_check "warn" "DOTFILES not set (may need to source shell config)"
fi
# Check HOMEBREW_PREFIX
if [ -n "$HOMEBREW_PREFIX" ]; then
print_check "pass" "HOMEBREW_PREFIX set: $HOMEBREW_PREFIX"
else
print_check "warn" "HOMEBREW_PREFIX not set (may need to source shell config)"
fi
}
validate_vim() {
print_header "Vim/Neovim Configuration"
# Check if vim is installed
if command -v vim >/dev/null 2>&1; then
print_check "pass" "vim is installed"
else
print_check "warn" "vim not found"
fi
# Check if nvim is installed
if command -v nvim >/dev/null 2>&1; then
local nvim_version=$(nvim --version | head -n1)
print_check "pass" "neovim installed: $nvim_version"
# Check vim init.vim
if [ -f "$HOME/.config/nvim/init.vim" ] || [ -f "$DOTFILES_DIR/vim/init.vim" ]; then
print_check "pass" "Neovim init.vim exists"
else
print_check "warn" "Neovim init.vim not found"
fi
else
print_check "warn" "neovim not installed"
fi
}
validate_workenv() {
print_header "Work Environment (workenv)"
# Check if workenv function exists
if type workenv >/dev/null 2>&1; then
print_check "pass" "workenv function is available"
else
print_check "warn" "workenv function not found (may need to source shell config)"
fi
# Check for environment files
if [ -d "$DOTFILES_DIR/vault-key" ]; then
local env_count=$(find "$DOTFILES_DIR/vault-key" -name "*.env" -type f 2>/dev/null | wc -l | tr -d ' ')
if [ "$env_count" -gt 0 ]; then
print_check "pass" "Found $env_count environment file(s)"
else
print_check "warn" "No .env files found (workenv has no environments)"
fi
fi
}
validate_repos() {
print_header "Repository Cloning"
# Check for .repos.txt files
if [ -d "$DOTFILES_DIR/vault-key" ]; then
local repos_count=$(find "$DOTFILES_DIR/vault-key" -name "*.repos.txt" -type f 2>/dev/null | wc -l | tr -d ' ')
if [ "$repos_count" -gt 0 ]; then
print_check "pass" "Found $repos_count .repos.txt file(s)"
# Check if ~/dev directory exists (common repo location)
if [ -d "$HOME/dev" ]; then
local cloned_repos=$(find "$HOME/dev" -maxdepth 2 -name ".git" -type d 2>/dev/null | wc -l | tr -d ' ')
if [ "$cloned_repos" -gt 0 ]; then
print_check "pass" "Found $cloned_repos cloned repositories in ~/dev"
else
print_check "warn" "No repositories found in ~/dev"
fi
else
print_check "warn" "~/dev directory not found"
fi
else
print_check "warn" "No .repos.txt files found (no repos to clone)"
fi
fi
}
print_summary() {
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}Validation Summary${NC}"
echo -e "${BLUE}========================================${NC}"
echo -e "${GREEN}Passed: $CHECKS_PASSED${NC}"
echo -e "${YELLOW}Warnings: $CHECKS_WARNING${NC}"
echo -e "${RED}Failed: $CHECKS_FAILED${NC}"
echo ""
if [ $CHECKS_FAILED -eq 0 ]; then
echo -e "${GREEN}✓ Installation validated successfully!${NC}"
echo ""
if [ $CHECKS_WARNING -gt 0 ]; then
echo -e "${YELLOW}Note: Some warnings detected - these are usually optional components${NC}"
echo ""
fi
echo "Next steps:"
echo " - Restart your terminal or run: source ~/.zshrc"
echo " - Run: workenv --list (to see available environments)"
echo " - Run: nvim (and check :checkhealth provider)"
echo ""
return 0
else
echo -e "${RED}✗ Installation validation failed - please review failed checks${NC}"
echo ""
echo "Common fixes:"
echo " - Source your shell config: source ~/.zshrc"
echo " - Re-run install.sh if critical components are missing"
echo " - Check install.sh output for error messages"
echo ""
return 1
fi
}
main() {
echo ""
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Dotfiles Installation Validation ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
validate_homebrew
validate_vault
validate_symlinks
validate_ssh
validate_node
validate_python
validate_shell
validate_vim
validate_workenv
validate_repos
print_summary
}
main "$@"