Compare commits

...

1 Commits

Author SHA1 Message Date
MickLesk e1c9903d21 OPNsense VM: wait for the FreeBSD login prompt instead of 180 seconds
The FreeBSD image boots in under a minute when both NICs get DHCP, but
dhclient waits 60 seconds on each NIC without a DHCP server, which is the
normal case for a firewall's LAN before setup. On vx-pve an isolated LAN
took 110 seconds; the reporter of #18464 measured 210. The keys then went
into the boot output. The image prints its login prompt on the serial
console as well, so the script now reads serial0 and continues when it
appears, up to 15 minutes, or waits the old 3 minutes if the console
cannot be read.
2026-11-05 10:23:26 +01:00
+20 -1
View File
@@ -442,7 +442,26 @@ msg_ok "Bridge interfaces have been successfully added."
msg_ok "Created a OPNsense VM ${CL}${BL}(${HN})"
msg_ok "Starting OPNsense VM (the bootstrap takes 10-30 minutes)"
$STD qm start $VMID
sleep 180
# The FreeBSD image prints its login prompt on the serial console too. Boot takes
# under a minute with DHCP, each NIC without a DHCP server adds a 60s timeout.
SERIAL_LOG="${TEMP_DIR}/serial-${VMID}.log"
timeout 900 socat -u "UNIX-CONNECT:/var/run/qemu-server/${VMID}.serial0" - >"$SERIAL_LOG" 2>/dev/null &
SERIAL_PID=$!
boot_wait=0
until grep -aq 'login:' "$SERIAL_LOG" 2>/dev/null || ! kill -0 "$SERIAL_PID" 2>/dev/null; do
sleep 5
boot_wait=$((boot_wait + 5))
done
kill "$SERIAL_PID" 2>/dev/null || true
if grep -aq 'login:' "$SERIAL_LOG" 2>/dev/null; then
msg_ok "FreeBSD booted after ${boot_wait}s"
elif [ $boot_wait -lt 180 ]; then
msg_warn "Could not read the serial console, waiting 3 minutes instead"
sleep $((180 - boot_wait))
else
msg_warn "No login prompt on the serial console after $((boot_wait / 60)) minutes; continuing"
fi
sleep 3
send_line_to_vm "root"
sleep 2
send_line_to_vm ""