-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathverify.sh
More file actions
790 lines (687 loc) · 24.9 KB
/
verify.sh
File metadata and controls
790 lines (687 loc) · 24.9 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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
#!/bin/bash
# DevOps Environment Toolkit - Verification Script
# Author: H A R S H H A A
# License: MIT
# Version: 2.0.0
set -euo pipefail
# Global variables
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="$HOME/.devops-toolkit-verify.log"
REPORT_FILE="$HOME/.devops-toolkit/system-report.txt"
JSON_REPORT_FILE="$HOME/.devops-toolkit/system-report.json"
VERBOSE=false
JSON_OUTPUT=false
HEALTH_CHECKS=false
SECURITY_CHECKS=false
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
# ASCII Art Banner
print_banner() {
echo -e "${CYAN}"
cat << "EOF"
╔══════════════════════════════════════════════════════════════╗
║ ║
║ 🔍 DevOps Environment Toolkit - Verification Script 🔍 ║
║ ║
║ Checking your DevOps environment setup... ║
║ ║
╚══════════════════════════════════════════════════════════════╝
EOF
echo -e "${NC}"
}
# Enhanced logging functions with file logging
log_info() {
local message="$1"
echo -e "${BLUE}[INFO]${NC} $message"
log_to_file "INFO" "$message"
}
log_success() {
local message="$1"
echo -e "${GREEN}[✓]${NC} $message"
log_to_file "SUCCESS" "$message"
}
log_warning() {
local message="$1"
echo -e "${YELLOW}[!]${NC} $message"
log_to_file "WARNING" "$message"
}
log_error() {
local message="$1"
echo -e "${RED}[✗]${NC} $message"
log_to_file "ERROR" "$message"
}
log_debug() {
local message="$1"
if [[ "$VERBOSE" == true ]]; then
echo -e "${PURPLE}[DEBUG]${NC} $message"
log_to_file "DEBUG" "$message"
fi
}
log_to_file() {
local level="$1"
local message="$2"
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$timestamp] [$level] $message" >> "$LOG_FILE"
}
# Input validation functions
validate_input() {
local input="$1"
local pattern="$2"
local description="$3"
if [[ -z "$input" ]]; then
log_error "Empty input not allowed for $description"
return 1
fi
if [[ -n "$pattern" ]] && [[ ! "$input" =~ $pattern ]]; then
log_error "Invalid input format for $description: $input"
return 1
fi
# Check for potentially dangerous characters
if [[ "$input" =~ [;&|`$(){}\[\]] ]]; then
log_error "Potentially dangerous characters detected in $description"
return 1
fi
return 0
}
# Error handling and recovery
error_handler() {
local exit_code=$?
local line_number=$1
local command="$2"
log_error "Error occurred at line $line_number: $command (exit code: $exit_code)"
log_to_file "ERROR" "Verification failed at line $line_number: $command (exit code: $exit_code)"
echo
log_error "Verification failed! Check the log file: $LOG_FILE"
exit "$exit_code"
}
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
# Version checking with update notifications
get_latest_version() {
local tool_name="$1"
local current_version="$2"
local version_url="$3"
log_debug "Checking for latest version of $tool_name..."
if [[ -z "$version_url" ]]; then
log_debug "No version URL provided for $tool_name"
return 0
fi
local latest_version
if command -v curl >/dev/null 2>&1; then
latest_version=$(curl -fsSL "$version_url" 2>/dev/null | head -1)
elif command -v wget >/dev/null 2>&1; then
latest_version=$(wget -qO- "$version_url" 2>/dev/null | head -1)
else
log_debug "Cannot check for updates - neither curl nor wget available"
return 0
fi
if [[ -z "$latest_version" ]]; then
log_debug "Could not retrieve latest version for $tool_name"
return 0
fi
# Clean version string (remove 'v' prefix if present)
latest_version=$(echo "$latest_version" | sed 's/^v//')
current_version=$(echo "$current_version" | sed 's/^v//')
if [[ "$current_version" != "$latest_version" ]]; then
log_warning "$tool_name update available: $current_version → $latest_version"
log_to_file "INFO" "$tool_name update available: $current_version → $latest_version"
else
log_debug "$tool_name is up to date: $current_version"
fi
}
# Check if command exists and get version with enhanced error handling
check_command() {
local cmd="$1"
local name="$2"
local required_version="$3"
log_debug "Checking command: $cmd"
if ! command -v "$cmd" >/dev/null 2>&1; then
log_error "$name: Not installed"
return 1
fi
local version
if ! version=$(get_version "$cmd"); then
log_error "$name: Failed to get version information"
return 1
fi
if [[ -n "$version" && "$version" != "Unknown" ]]; then
log_success "$name: $version"
# Check for updates if version URL is available
case "$cmd" in
"git")
get_latest_version "Git" "$version" "https://api.github.com/repos/git/git/releases/latest"
;;
"terraform")
get_latest_version "Terraform" "$version" "https://api.github.com/repos/hashicorp/terraform/releases/latest"
;;
"kubectl")
get_latest_version "kubectl" "$version" "https://storage.googleapis.com/kubernetes-release/release/stable.txt"
;;
esac
return 0
else
log_success "$name: Installed (version unknown)"
return 0
fi
}
# Get version of a command
# Get version of a command with enhanced error handling
get_version() {
local cmd="$1"
local version=""
log_debug "Getting version for: $cmd"
case $cmd in
"docker")
if ! version=$(docker --version 2>/dev/null | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
"docker-compose")
if ! version=$(docker-compose --version 2>/dev/null | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
"git")
if ! version=$(git --version 2>/dev/null | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
"terraform")
if ! version=$(terraform --version 2>/dev/null | head -1 | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
"ansible")
if ! version=$(ansible --version 2>/dev/null | head -1 | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
"kubectl")
if ! version=$(kubectl version --client 2>/dev/null | grep -oE 'GitVersion:"v\K[^"]+' | head -1); then
version=$(kubectl version --client --short 2>/dev/null | grep -oE '\d+\.\d+\.\d+' | head -1 || echo "Unknown")
fi
;;
"minikube")
if ! version=$(minikube version 2>/dev/null | grep -oE 'v\K[0-9.]+' | head -1); then
version="Unknown"
fi
;;
"aws")
if ! version=$(aws --version 2>/dev/null | grep -oE 'aws-cli/\K[0-9.]+' | head -1); then
version="Unknown"
fi
;;
"az")
if ! version=$(az version 2>/dev/null | grep -oE '"azure-cli": "\K[^"]+' | head -1); then
version=$(az --version 2>/dev/null | head -1 | grep -oE '\d+\.\d+\.\d+' | head -1 || echo "Unknown")
fi
;;
"code")
if ! version=$(code --version 2>/dev/null | head -1); then
version="Unknown"
fi
;;
*)
if ! version=$($cmd --version 2>/dev/null | head -1 | grep -oE '\d+\.\d+\.\d+' | head -1); then
version="Unknown"
fi
;;
esac
if [[ -n "$version" && "$version" != "Unknown" ]]; then
echo "$version"
else
echo "Unknown"
fi
}
# Enhanced Docker daemon status check with health diagnostics
check_docker_daemon() {
log_debug "Checking Docker daemon status..."
if ! command -v docker >/dev/null 2>&1; then
log_error "Docker: Not installed"
return 1
fi
if ! docker info >/dev/null 2>&1; then
log_warning "Docker daemon: Not running"
if [[ "$HEALTH_CHECKS" == true ]]; then
log_info "Docker diagnostics:"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
log_info " Service status: $(systemctl is-active docker 2>/dev/null || echo 'Unknown')"
log_info " Start with: sudo systemctl start docker"
log_info " Enable on boot: sudo systemctl enable docker"
elif [[ "$OSTYPE" == "darwin"* ]]; then
log_info " Start Docker Desktop application"
log_info " Check Docker Desktop status in System Preferences"
fi
fi
return 1
fi
local containers_running images_count docker_version
containers_running=$(docker ps -q 2>/dev/null | wc -l)
images_count=$(docker images -q 2>/dev/null | wc -l)
docker_version=$(docker --version 2>/dev/null | grep -oE '\d+\.\d+\.\d+' | head -1)
log_success "Docker daemon: Running (Containers: $containers_running, Images: $images_count, Version: ${docker_version:-unknown})"
if [[ "$HEALTH_CHECKS" == true ]]; then
log_info "Docker health checks:"
# Check disk space for Docker
local docker_df
if docker_df=$(docker system df 2>/dev/null); then
log_info " Docker disk usage: Available"
else
log_warning " Docker disk usage: Could not determine"
fi
# Check for common issues
if [[ $containers_running -gt 0 ]]; then
log_info " Active containers: $containers_running"
else
log_info " No active containers"
fi
if [[ $images_count -gt 0 ]]; then
log_info " Available images: $images_count"
else
log_info " No images available"
fi
fi
return 0
}
# Check VS Code extensions
check_vscode_extensions() {
if command -v code >/dev/null 2>&1; then
log_info "Checking VS Code extensions..."
local extensions=(
"ms-vscode.vscode-docker"
"ms-kubernetes-tools.vscode-kubernetes-tools"
"hashicorp.terraform"
"redhat.vscode-yaml"
"ms-vscode.vscode-json"
"ms-vscode.powershell"
)
local installed_count=0
for ext in "${extensions[@]}"; do
if code --list-extensions | grep -q "^$ext$"; then
((installed_count++))
fi
done
if [[ $installed_count -eq ${#extensions[@]} ]]; then
log_success "VS Code extensions: All installed ($installed_count/${#extensions[@]})"
else
log_warning "VS Code extensions: $installed_count/${#extensions[@]} installed"
fi
else
log_warning "VS Code: Not installed"
fi
}
# Check configuration files
check_config_files() {
local config_dir="$HOME/.devops-toolkit"
if [[ -d "$config_dir" ]]; then
log_success "Configuration directory: $config_dir exists"
local subdirs=("configs" "templates" "scripts" "examples")
for dir in "${subdirs[@]}"; do
if [[ -d "$config_dir/$dir" ]]; then
log_success " └─ $dir/ directory exists"
else
log_warning " └─ $dir/ directory missing"
fi
done
else
log_warning "Configuration directory: $config_dir not found"
fi
}
# Check system resources
check_system_resources() {
log_info "Checking system resources..."
# Check available memory
if command -v free >/dev/null 2>&1; then
local total_mem=$(free -h | awk '/^Mem:/ {print $2}')
local available_mem=$(free -h | awk '/^Mem:/ {print $7}')
local used_mem=$(free -h | awk '/^Mem:/ {print $3}')
log_info "Memory: $used_mem used, $available_mem available of $total_mem total"
elif command -v vm_stat >/dev/null 2>&1; then
# macOS
local page_size=$(vm_stat | grep "page size" | awk '{print $8}')
local free_pages=$(vm_stat | grep "Pages free" | awk '{print $3}' | sed 's/\.//')
local available_mem=$((free_pages * page_size / 1024 / 1024))
log_info "Memory: ${available_mem}MB available (macOS)"
else
log_warning "Memory: Cannot determine available memory"
fi
# Check disk space
if command -v df >/dev/null 2>&1; then
local disk_usage=$(df -h / | awk 'NR==2 {print $4}')
local disk_used=$(df -h / | awk 'NR==2 {print $3}')
local disk_total=$(df -h / | awk 'NR==2 {print $2}')
log_info "Disk space: $disk_used used, $disk_usage available of $disk_total total"
else
log_warning "Disk space: Cannot determine disk usage"
fi
# Check CPU cores
local cpu_cores=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo "Unknown")
log_info "CPU cores: $cpu_cores"
# Check load average (Linux only)
if [[ -f /proc/loadavg ]]; then
local load_avg=$(cat /proc/loadavg | awk '{print $1, $2, $3}')
log_info "Load average (1m, 5m, 15m): $load_avg"
fi
}
# Security configuration checks
check_security_config() {
log_info "Checking security configurations..."
# Check file permissions on sensitive directories
local sensitive_dirs=("$HOME/.ssh" "$HOME/.aws" "$HOME/.azure")
for dir in "${sensitive_dirs[@]}"; do
if [[ -d "$dir" ]]; then
local perms=$(stat -c "%a" "$dir" 2>/dev/null || echo "unknown")
if [[ "$perms" =~ ^[67][0-9][0-9]$ ]]; then
log_warning "Sensitive directory $dir has permissive permissions: $perms"
else
log_success "Sensitive directory $dir has secure permissions: $perms"
fi
fi
done
# Check for exposed API keys in common locations
local dangerous_patterns=("AKIA[0-9A-Z]{16}" "sk-[a-zA-Z0-9]{48}" "ghp_[a-zA-Z0-9]{36}")
local search_dirs=("$HOME" "$HOME/.devops-toolkit")
for pattern in "${dangerous_patterns[@]}"; do
local found=false
for dir in "${search_dirs[@]}"; do
if [[ -d "$dir" ]]; then
if grep -r "$pattern" "$dir" 2>/dev/null | head -5 | grep -q .; then
log_error "Potential exposed credentials found with pattern: $pattern"
found=true
fi
fi
done
if [[ "$found" == false ]]; then
log_success "No exposed credentials found for pattern: $pattern"
fi
done
# Check Docker daemon socket permissions
if [[ -S "/var/run/docker.sock" ]]; then
local docker_sock_perms=$(stat -c "%a" "/var/run/docker.sock" 2>/dev/null || echo "unknown")
if [[ "$docker_sock_perms" == "666" ]]; then
log_warning "Docker socket has permissive permissions: $docker_sock_perms"
else
log_success "Docker socket has appropriate permissions: $docker_sock_perms"
fi
fi
}
# Generate JSON report
generate_json_report() {
log_info "Generating JSON system report..."
local json_output
json_output=$(cat << EOF
{
"timestamp": "$(date -Iseconds)",
"hostname": "$(hostname)",
"os": "$(uname -s)",
"kernel": "$(uname -r)",
"architecture": "$(uname -m)",
"tools": {
EOF
)
# Add tools information
local tools=("docker" "docker-compose" "git" "terraform" "ansible" "kubectl" "minikube" "aws" "az" "code")
local first=true
for tool in "${tools[@]}"; do
if [[ "$first" == true ]]; then
first=false
else
json_output+=",
"
fi
local version="Not installed"
if command -v "$tool" >/dev/null 2>&1; then
version=$(get_version "$tool")
fi
json_output+=" \"$tool\": \"$version\""
done
json_output+=@"
},
"docker_daemon": {
"running": $(docker info >/dev/null 2>&1 && echo "true" || echo "false"),
"containers": $(docker ps -q 2>/dev/null | wc -l),
"images": $(docker images -q 2>/dev/null | wc -l)
},
"system": {
"memory_available": "$(free -h 2>/dev/null | awk '/^Mem:/ {print $7}' || echo 'unknown')",
"disk_available": "$(df -h / 2>/dev/null | awk 'NR==2 {print $4}' || echo 'unknown')",
"cpu_cores": "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 'unknown')"
}
}
EOF
)
# Ensure directory exists
mkdir -p "$(dirname "$JSON_REPORT_FILE")"
echo "$json_output" > "$JSON_REPORT_FILE"
log_success "JSON report saved to: $JSON_REPORT_FILE"
}
generate_report() {
local report_file="$HOME/.devops-toolkit/system-report.txt"
log_info "Generating system report..."
{
echo "DevOps Environment Toolkit - System Report"
echo "Generated on: $(date)"
echo "=========================================="
echo
echo "Operating System:"
if [[ -f /etc/os-release ]]; then
. /etc/os-release
echo " Name: $NAME"
echo " Version: $VERSION"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo " Name: macOS"
echo " Version: $(sw_vers -productVersion)"
fi
echo
echo "Installed Tools:"
local tools=("docker" "docker-compose" "git" "terraform" "ansible" "kubectl" "minikube" "aws" "az" "code")
for tool in "${tools[@]}"; do
if command -v "$tool" >/dev/null 2>&1; then
local version=$(get_version "$tool")
echo " ✓ $tool: $version"
else
echo " ✗ $tool: Not installed"
fi
done
echo
echo "Docker Status:"
if command -v docker >/dev/null 2>&1; then
if docker info >/dev/null 2>&1; then
echo " Status: Running"
echo " Version: $(docker --version)"
echo " Containers: $(docker ps -q | wc -l) running"
echo " Images: $(docker images -q | wc -l) available"
else
echo " Status: Not running"
fi
else
echo " Status: Not installed"
fi
echo
echo "System Resources:"
if command -v free >/dev/null 2>&1; then
free -h
elif command -v vm_stat >/dev/null 2>&1; then
vm_stat
fi
echo
echo "Disk Usage:"
df -h
echo
} > "$report_file"
log_success "System report saved to: $report_file"
}
# Command line argument parsing
parse_arguments() {
while [[ $# -gt 0 ]]; do
case $1 in
--verbose|-v)
VERBOSE=true
shift
;;
--json|-j)
JSON_OUTPUT=true
shift
;;
--health|-h)
HEALTH_CHECKS=true
shift
;;
--security|-s)
SECURITY_CHECKS=true
shift
;;
--help|-help)
show_help
exit 0
;;
--version)
echo "DevOps Environment Toolkit Verification Script v2.0.0"
exit 0
;;
*)
log_error "Unknown option: $1"
show_help
exit 1
;;
esac
done
}
show_help() {
echo -e "${BOLD}DevOps Environment Toolkit - Enhanced Verification${NC}"
echo
echo -e "${CYAN}Usage:${NC} $0 [OPTIONS]"
echo
echo -e "${CYAN}Options:${NC}"
echo -e " ${YELLOW}-v, --verbose${NC} Enable verbose output"
echo -e " ${YELLOW}-j, --json${NC} Output results in JSON format"
echo -e " ${YELLOW}-h, --health${NC} Run detailed health checks"
echo -e " ${YELLOW}-s, --security${NC} Run security configuration checks"
echo -e " ${YELLOW}--help${NC} Show this help message"
echo -e " ${YELLOW}--version${NC} Show version information"
echo
echo -e "${CYAN}Examples:${NC}"
echo -e " ${YELLOW}$0${NC} # Standard verification"
echo -e " ${YELLOW}$0 --verbose --health${NC} # Verbose verification with health checks"
echo -e " ${YELLOW}$0 --json${NC} # JSON output for automation"
echo -e " ${YELLOW}$0 --security${NC} # Include security checks"
}
# Enhanced main verification function
main() {
# Parse command line arguments
parse_arguments "$@"
# Initialize log file
mkdir -p "$(dirname "$LOG_FILE")"
echo "DevOps Environment Toolkit Verification - $(date)" > "$LOG_FILE"
print_banner
local total_checks=0
local passed_checks=0
log_info "Starting verification of DevOps environment..."
log_to_file "INFO" "Verification started with options: VERBOSE=$VERBOSE, JSON_OUTPUT=$JSON_OUTPUT, HEALTH_CHECKS=$HEALTH_CHECKS, SECURITY_CHECKS=$SECURITY_CHECKS"
echo
# Core tools
log_info "Checking core tools..."
local core_tools=("docker" "docker-compose" "git")
for tool in "${core_tools[@]}"; do
((total_checks++))
if check_command "$tool" "$tool"; then
((passed_checks++))
fi
done
echo
# Infrastructure tools
log_info "Checking infrastructure tools..."
local infra_tools=("terraform" "ansible" "kubectl" "minikube")
for tool in "${infra_tools[@]}"; do
((total_checks++))
if check_command "$tool" "$tool"; then
((passed_checks++))
fi
done
echo
# Cloud CLIs
log_info "Checking cloud CLIs..."
local cloud_tools=("aws" "az")
for tool in "${cloud_tools[@]}"; do
((total_checks++))
if check_command "$tool" "$tool"; then
((passed_checks++))
fi
done
echo
# Development tools
log_info "Checking development tools..."
local dev_tools=("code")
for tool in "${dev_tools[@]}"; do
((total_checks++))
if check_command "$tool" "$tool"; then
((passed_checks++))
fi
done
echo
# Docker daemon
log_info "Checking Docker daemon..."
((total_checks++))
if check_docker_daemon; then
((passed_checks++))
fi
echo
# VS Code extensions
check_vscode_extensions
echo
# Configuration files
check_config_files
echo
# System resources
check_system_resources
echo
# Security checks
if [[ "$SECURITY_CHECKS" == true ]]; then
log_info "Running security configuration checks..."
check_security_config
echo
fi
# Generate reports
if [[ "$JSON_OUTPUT" == true ]]; then
generate_json_report
else
generate_report
fi
echo
# Summary
local success_rate=$((passed_checks * 100 / total_checks))
echo "=========================================="
echo -e "${PURPLE}Verification Summary:${NC}"
echo -e " Total checks: $total_checks"
echo -e " Passed: $passed_checks"
echo -e " Failed: $((total_checks - passed_checks))"
echo -e " Success rate: $success_rate%"
echo "=========================================="
log_to_file "INFO" "Verification completed: $passed_checks/$total_checks checks passed ($success_rate%)"
if [[ $success_rate -ge 80 ]]; then
log_success "🎉 Your DevOps environment is ready to go!"
elif [[ $success_rate -ge 60 ]]; then
log_warning "⚠️ Your environment is mostly ready, but some tools are missing"
else
log_error "❌ Your environment needs more setup. Please run the installation script again."
fi
echo
echo -e "${CYAN}Next steps:${NC}"
if [[ "$JSON_OUTPUT" == true ]]; then
echo -e "1. Check the JSON report: ${YELLOW}cat $JSON_REPORT_FILE${NC}"
else
echo -e "1. Check the system report: ${YELLOW}cat $REPORT_FILE${NC}"
fi
echo -e "2. Start Docker if not running: ${YELLOW}sudo systemctl start docker${NC} (Linux) or start Docker Desktop (macOS)"
echo -e "3. Explore the templates: ${YELLOW}ls ~/.devops-toolkit/templates/${NC}"
echo -e "4. Check out the examples: ${YELLOW}ls ~/.devops-toolkit/examples/${NC}"
echo
}
# Run main function
main "$@"