From d76372a64f9f4fa60f0818e9e597613cfce7d496 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 25 Mar 2019 17:12:49 +0100 Subject: [serversetup-bwlp-ipxe] Support DEFAULT directive of pxelinux --- .../serversetup-bwlp-ipxe/inc/ipxe.inc.php | 4 +++- .../serversetup-bwlp-ipxe/inc/pxelinux.inc.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php index a78ad941..2aecd70f 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxe.inc.php @@ -162,8 +162,10 @@ class IPxe if (!empty($pxe->title)) { $menuTitle = $pxe->title; } - if ($pxe->timeoutLabel !== null) { + if ($pxe->timeoutLabel !== null && $pxe->hasLabel($pxe->timeoutLabel)) { $defaultLabel = $pxe->timeoutLabel; + } elseif ($pxe->hasLabel($pxe->default)) { + $defaultLabel = $pxe->default; } $timeoutMs[] = $pxe->timeoutMs; $timeoutMs[] = $pxe->totalTimeoutMs; diff --git a/modules-available/serversetup-bwlp-ipxe/inc/pxelinux.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/pxelinux.inc.php index a3826c2e..63fdf674 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/pxelinux.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/pxelinux.inc.php @@ -38,6 +38,7 @@ class PxeLinux 'menu clear' => ['true', 'menuClear'], 'menu immediate' => ['true', 'immediateHotkeys'], 'ontimeout' => ['string', 'timeoutLabel'], + 'default' => ['string', 'default'], ]; $lines = preg_split('/[\r\n]+/', $input); $section = null; @@ -159,6 +160,11 @@ class PxeMenu * @var PxeSection[] list of sections the menu contains */ public $sections = []; + /** + * @var string The DEFAULT entry of the menu. Usually refers either to a + * LABEL, or a loadable module (like vesamenu.c32) + */ + public $default; public function hash($fuzzy) { @@ -193,6 +199,18 @@ class PxeMenu return hash_final($ctx, false); } + /** + * Check if any of the sections has the given label. + */ + public function hasLabel($label) + { + foreach ($this->sections as $section) { + if ($section->label === $label) + return true; + } + return false; + } + } /** -- cgit v1.2.3-55-g7522