#!/bin/bash # ============================================================================== # STANDALONE NODE VALIDATION TOOL # ============================================================================== # Comprehensive health check utility for homelab nodes # Can be run independently on any managed host (post-bootstrap or ad-hoc) # # Usage: # ./validate-node.sh [OPTIONS] # # Options: # --help Show this help message # --json Output results in JSON format # --critical-only Show only critical errors (exit code 1 if any found) # --verbose Show detailed output for each check # # Exit Codes: # 0 - All checks passed or warnings only # 1 - Critical errors found # 2 - Invalid usage # # ============================================================================== set -euo pipefail # --- SCRIPT METADATA --- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" VERSION="1.0.0" # --- LOAD LIBRARIES --- # shellcheck source=./lib/detection.sh source "${SCRIPT_DIR}/lib/detection.sh" # shellcheck source=./lib/validation.sh source "${SCRIPT_DIR}/lib/validation.sh" # shellcheck source=./lib/network.sh source "${SCRIPT_DIR}/lib/network.sh" # --- COMMAND LINE ARGUMENTS --- SHOW_HELP=false OUTPUT_JSON=false CRITICAL_ONLY=false VERBOSE=false parse_arguments() { while [[ $# -gt 0 ]]; do case "$1" in --help|-h) SHOW_HELP=true shift ;; --json) OUTPUT_JSON=true shift ;; --critical-only) CRITICAL_ONLY=true shift ;; --verbose|-v) VERBOSE=true shift ;; *) echo "ERROR: Unknown option: $1" >&2 echo "Use --help for usage information" >&2 exit 2 ;; esac done } show_help() { cat <<'EOF' ============================================================================= STANDALONE NODE VALIDATION TOOL v1.0.0 ============================================================================= Comprehensive health check for homelab infrastructure nodes. Can be run on any managed host to verify operational readiness. USAGE: ./validate-node.sh [OPTIONS] OPTIONS: --help Show this help message --json Output results in JSON format (for monitoring integration) --critical-only Show only critical errors (suppress warnings) --verbose Show detailed output for each check EXIT CODES: 0 - All checks passed (or warnings only) 1 - Critical errors found 2 - Invalid usage CHECKS PERFORMED: • Disk Space & Performance • Memory & Swap Configuration • Network Routes & Connectivity • Hostname Resolution • NFS Client Configuration • Docker Daemon Health • Proxmox API (if applicable) • SSH Security Configuration • Firewall Status • Time Synchronization EXAMPLES: ./validate-node.sh Run all checks with standard output ./validate-node.sh --critical-only Show only critical errors (useful in scripts) ./validate-node.sh --json Output JSON for monitoring/alerting systems ./validate-node.sh --verbose Show detailed information for each check INTEGRATION: JSON output can be consumed by monitoring systems (Prometheus, Grafana, etc.) Example: ./validate-node.sh --json | jq '.errors' ============================================================================= EOF } # --- JSON OUTPUT FUNCTIONS --- generate_json_report() { # Generate JSON output for monitoring integration local hostname=$(hostname) local timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") cat <