#!ipxe

# ─── Network ─────────────────────────────────────────────────────────────────
dhcp || goto dhcp_failed

# ─── Mac detection ───────────────────────────────────────────────────────────
# ${manufacturer} contains "Apple Inc." — the space breaks iseq if used as a
# literal, so store it in a variable first so it expands as one token.
set apple Apple Inc.
iseq ${manufacturer} ${apple} && goto mac

# ─── Non-Mac boot ─────────────────────────────────────────────────────────────
chain http://${next-server}/default.ipxe || goto failed
goto end

# ─── Mac boot ─────────────────────────────────────────────────────────────────
:mac
chain http://${next-server}/mac.ipxe || goto failed
goto end

# ─── Error handlers ───────────────────────────────────────────────────────────
:dhcp_failed
echo DHCP failed - no network
sleep 5
reboot

:failed
echo Chain failed
shell

:end
