summaryrefslogtreecommitdiff
path: root/verifypxe.sh
blob: 203292b93eacbfc2d0bcc4510fb239b68da3c1f2 (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
61
62
#!/bin/bash

# === Genesis PXE Verifier ===
# Verifies iPXE script and image accessibility over Tailscale

TAILSCALE_IP="100.113.50.65"
VM_NAME="$1"

if [[ -z "$VM_NAME" ]]; then
  echo "Usage: $0 <vm-name>"
  exit 1
fi

IPXE_URL="http://100.113.50.65:3000/ipxe/${VM_NAME}.ipxe"


echo "🔎 Checking iPXE script at $IPXE_URL ..."
if ! curl -fsSL "$IPXE_URL" -o /tmp/${VM_NAME}.ipxe; then
  echo "❌ Failed to fetch iPXE script: $IPXE_URL"
  exit 2
fi
echo "✅ iPXE script retrieved."

# Extract kernel and initrd lines
KERNEL_URL=$(grep '^kernel ' /tmp/${VM_NAME}.ipxe | awk '{print $2}')
INITRD_URL=$(grep '^initrd ' /tmp/${VM_NAME}.ipxe | awk '{print $2}')

if [[ -z "$KERNEL_URL" || -z "$INITRD_URL" ]]; then
  echo "❌ Could not parse kernel/initrd URLs from iPXE script."
  exit 3
fi

echo "🔍 Kernel URL:  $KERNEL_URL"
echo "🔍 Initrd URL:  $INITRD_URL"

echo "🔎 Verifying kernel URL ..."
if ! curl -fsI "$KERNEL_URL" >/dev/null; then
  echo "❌ Kernel file not accessible."
  exit 4
fi
echo "✅ Kernel accessible."

echo "🔎 Verifying initrd URL ..."
if ! curl -fsI "$INITRD_URL" >/dev/null; then
  echo "❌ Initrd file not accessible."
  exit 5
fi
echo "✅ Initrd accessible."

echo "🎉 PXE verification successful for VM: $VM_NAME"
echo "🚀 Ready to launch boot from $IPXE_URL"

# Optional: Telegram notify (requires telegram-send config)
if command -v telegram-send &>/dev/null; then
  telegram-send "✅ PXE verify passed for *${VM_NAME}*.  
Netboot source: \`${IPXE_URL}\`  
Kernel: \`${KERNEL_URL##*/}\`  
Initrd: \`${INITRD_URL##*/}\`  
Ready to launch via Proxmox." --parse-mode markdown
fi

exit 0