blob: 3f9735bf5f60a066abcb603ac78174cd4fdbf612 (
plain)
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
|
#!/bin/bash
# Network diagnostics for VM testing
# Author: Craig Jennings <craigmartinjennings@gmail.com>
# License: GNU GPLv3
# Note: logging.sh should already be sourced by the calling script
# Run quick network diagnostics
# Args: $1 = VM IP address or hostname
run_network_diagnostics() {
local vm_host="$1"
section "Pre-flight Network Diagnostics"
# Test 1: Basic connectivity
step "Testing internet connectivity"
if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "ping -c 3 8.8.8.8 >/dev/null 2>&1"; then
success "Internet connectivity OK"
else
error "No internet connectivity"
return 1
fi
# Test 2: DNS resolution
step "Testing DNS resolution"
if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "nslookup archlinux.org >/dev/null 2>&1"; then
success "DNS resolution OK"
else
error "DNS resolution failed"
return 1
fi
# Test 3: Arch mirror accessibility
step "Testing Arch mirror access"
if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "curl -s -I https://mirrors.kernel.org/archlinux/ | head -1 | grep -qE '(200|301)'"; then
success "Arch mirrors accessible"
else
error "Cannot reach Arch mirrors"
return 1
fi
# Test 4: AUR accessibility
step "Testing AUR access"
if sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host "curl -s -I https://aur.archlinux.org/ | head -1 | grep -qE '(200|405)'"; then
success "AUR accessible"
else
error "Cannot reach AUR"
return 1
fi
# Show network info
info "Network configuration:"
sshpass -p 'archsetup' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$vm_host \
"ip addr show | grep 'inet ' | grep -v '127.0.0.1'" 2>/dev/null | while read line; do
info " $line"
done
success "Network diagnostics complete"
return 0
}
|