Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/api-core/src/ipxe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ impl PxeInstructions {
if machine_type == MachineType::Host || machine_type == MachineType::PredictedHost {
InstructionGenerator {
kernel: "${base-url}/internal/aarch64/scout.efi".to_string(),
command_line: format!("mac={mac_address} console=tty0 console={console},115200 pci=realloc=off iommu=off cli_cmd=auto-detect machine_id={machine_interface_id} server_uri=[api_url] pxe_uri=[pxe_url]"),
// static_pxe_url passes the (already iPXE-expanded) static-pxe
// base to the scout-loader so it fetches scout.squashfs from the
// configured static-pxe server instead of hardcoding a hostname.
command_line: format!("mac={mac_address} console=tty0 console={console},115200 pci=realloc=off iommu=off cli_cmd=auto-detect machine_id={machine_interface_id} server_uri=[api_url] pxe_uri=[pxe_url] static_pxe_url=${{base-url}}"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's correct to pass base URL, isn't this a template, aka, shouldn't there be a static PXE url variable in scope?

initrd: None,
}
}
Expand All @@ -223,7 +226,10 @@ impl PxeInstructions {
rpc::MachineArchitecture::X86 => {
InstructionGenerator {
kernel: "${base-url}/internal/x86_64/scout.efi".to_string(),
command_line: format!("mac={mac_address} console=tty0 console={console},115200 pci=realloc=off iommu=off cli_cmd=auto-detect machine_id={machine_interface_id} server_uri=[api_url] pxe_uri=[pxe_url]"),
// static_pxe_url passes the (already iPXE-expanded) static-pxe
// base to the scout-loader so it fetches scout.squashfs from the
// configured static-pxe server instead of hardcoding a hostname.
command_line: format!("mac={mac_address} console=tty0 console={console},115200 pci=realloc=off iommu=off cli_cmd=auto-detect machine_id={machine_interface_id} server_uri=[api_url] pxe_uri=[pxe_url] static_pxe_url=${{base-url}}"),
initrd: None,
}
}
Expand Down
17 changes: 15 additions & 2 deletions pxe/common_files/scout-loader-rclocal
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,26 @@ send_msg() {
done
}

# Default image will be scout, from the nginx container
# Default image will be scout, from the nginx container.
# Resolution order for the rootfs URL:
# 1. newrootfs=<full-url> on the kernel cmdline (explicit override).
# 2. static_pxe_url=<base> on the kernel cmdline, populated by NICo Core from
# the configured static-pxe URL (honors external_static_pxe_url overrides).
# 3. Backward-compatible fallback to the carbide-static-pxe.forge hostname.
if [ "$(grep -c 'newrootfs=' /proc/cmdline)" -eq 1 ]
then
newrootfsurl=$(cat /proc/cmdline | sed -e 's/.*newrootfs=//' -e 's/ .*//')
else
arch=$(uname -m)
newrootfsurl="http://carbide-static-pxe.forge/public/blobs/internal/${arch}/scout.squashfs"
if [ "$(grep -c 'static_pxe_url=' /proc/cmdline)" -eq 1 ]
then
# static_pxe_url already points at .../public/blobs (NICo Core base-url);
# strip any trailing slash before appending the rootfs path.
static_pxe_url=$(cat /proc/cmdline | sed -e 's/.*static_pxe_url=//' -e 's/ .*//' -e 's:/*$::')
newrootfsurl="${static_pxe_url}/internal/${arch}/scout.squashfs"
else
newrootfsurl="http://carbide-static-pxe.forge/public/blobs/internal/${arch}/scout.squashfs"
fi
fi

# Respect the console info from the kernel command line
Expand Down