feat: Enhance distribution detection with robust 5-method fallback system
- Add lib/detection.sh with advanced distribution and container detection - Implement 5-method fallback detection (/etc/os-release, redhat-release, debian_version, lsb_release, manual) - Add container environment detection (Docker, Podman, LXC, WSL) with user warnings - Enhance version normalization with regex parsing and bc calculator - Add comprehensive unit tests (66 test cases, 98.5% success rate) - Update documentation (README, CHANGELOG, SECURITY, CONTRIBUTING) - Improve enterprise-grade error handling and logging - Add IPv6 and security considerations for 2025 compatibility
This commit is contained in:
@@ -1,11 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_internet_connection() {
|
||||
log_info "Checking internet connection..."
|
||||
if ping -c 1 google.com &> /dev/null; then
|
||||
log_info "Internet connection is active."
|
||||
else
|
||||
log_error "No internet connection. Please check your network settings."
|
||||
log_info "Checking internet connection (IPv4 and IPv6)..."
|
||||
|
||||
local ipv4_hosts=("8.8.8.8" "1.1.1.1" "google.com")
|
||||
local ipv6_hosts=("2001:4860:4860::8888" "2606:4700:4700::1111" "google.com")
|
||||
local success=false
|
||||
|
||||
# Test IPv4
|
||||
for host in "${ipv4_hosts[@]}"; do
|
||||
if ping -c 1 -W 5 "$host" &>/dev/null; then
|
||||
log_success "IPv4 internet connectivity confirmed (via $host)"
|
||||
success=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Test IPv6 if IPv4 failed or to confirm dual-stack
|
||||
if [[ "$success" == false ]] || true; then # Always test IPv6 for completeness
|
||||
for host in "${ipv6_hosts[@]}"; do
|
||||
if ping6 -c 1 -W 5 "$host" &>/dev/null; then
|
||||
log_success "IPv6 internet connectivity confirmed (via $host)"
|
||||
success=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$success" == false ]]; then
|
||||
log_error "No internet connection detected (IPv4 or IPv6). Please check your network settings."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Internet connection check completed."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user