-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-wipe-flow.sh
More file actions
executable file
·109 lines (95 loc) · 2.81 KB
/
Copy pathtest-wipe-flow.sh
File metadata and controls
executable file
·109 lines (95 loc) · 2.81 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
#!/bin/bash
# Interactive test: Boot ISO, SSH in, verify TUI components
set -e
ISO_PATH="${1:?Usage: $0 <iso-path>}"
TIMEOUT="${2:-300}"
LOG_FILE="/tmp/wipe-flow-test-$(date +%s).log"
echo "=== Expunge Wipe Flow Test ==="
echo "ISO: $ISO_PATH"
echo "Log: $LOG_FILE"
# Start QEMU in background with port forwarding for SSH
sg kvm -c "qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-smp 2 \
-cdrom '$ISO_PATH' \
-nographic \
-serial mon:stdio \
-drive file=/home/chris/expunge-testing/drives/sata1.qcow2,format=qcow2,if=virtio,id=sata1 \
-drive file=/home/chris/expunge-testing/drives/nvme1.qcow2,format=qcow2,if=none,id=nvme0 \
-device nvme,drive=nvme0,serial=NVMETEST001 \
-netdev user,id=net0,hostfwd=tcp::2222-:22 \
-device e1000,netdev=net0 \
-no-reboot \
2>&1" > "$LOG_FILE" &
QEMU_PID=$!
echo "QEMU PID: $QEMU_PID"
cleanup() {
echo "Cleaning up QEMU..."
kill $QEMU_PID 2>/dev/null || true
}
trap cleanup EXIT
echo "Waiting 60s for boot..."
sleep 60
# Extract password from boot log
PASSWORD=$(grep -oP 'Root password: \K\S+' "$LOG_FILE" | head -1)
echo "Root password: $PASSWORD"
if [ -z "$PASSWORD" ]; then
echo "ERROR: Could not extract root password"
tail -50 "$LOG_FILE"
exit 1
fi
# Try SSH connection
echo ""
echo "=== Testing SSH connection ==="
export SSHPASS="$PASSWORD"
# Wait for SSH to be ready
for i in {1..10}; do
if sshpass -e ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 -p 2222 root@localhost "echo SSH_OK" 2>/dev/null; then
echo "SSH connection successful!"
break
fi
echo "Waiting for SSH... attempt $i"
sleep 5
done
# Run tests via SSH
echo ""
echo "=== Testing Drive Detection ==="
sshpass -e ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "
source /opt/expunge/lib/detect.sh
source /opt/expunge/lib/utils.sh
echo '--- lsblk output ---'
lsblk -d -o NAME,SIZE,TYPE,TRAN,MODEL
echo ''
echo '--- Detected drives ---'
detect_drives 2>/dev/null | head -20
echo ''
echo '--- Boot device ---'
get_boot_device
"
echo ""
echo "=== Testing Wipe Library ==="
sshpass -e ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "
source /opt/expunge/lib/wipe.sh
echo '--- Wipe methods ---'
echo 'Standard NIST method: '$(get_nwipe_method standard_nist)
echo 'DoD3 method: '$(get_nwipe_method maximum_dod3)
echo ''
echo '--- nwipe version ---'
nwipe --version 2>&1 | head -1
"
echo ""
echo "=== Testing TUI Components ==="
sshpass -e ssh -o StrictHostKeyChecking=no -p 2222 root@localhost "
echo '--- Checking expunge.sh ---'
ls -la /opt/expunge/expunge.sh
echo ''
echo '--- TUI files ---'
ls -la /opt/expunge/tui/
echo ''
echo '--- Dialog version ---'
dialog --version
"
echo ""
echo "=== Test Complete ==="
echo "Log saved: $LOG_FILE"