From 43f5238ea4b1ab62aeff74233f45a3160e863680 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 25 Mar 2019 17:13:15 +0100 Subject: [serversetup-bwlp-ipxe] Direct boot for menus with one item --- .../serversetup-bwlp-ipxe/api.inc.php | 9 ++++++++- .../serversetup-bwlp-ipxe/inc/ipxemenu.inc.php | 23 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/modules-available/serversetup-bwlp-ipxe/api.inc.php b/modules-available/serversetup-bwlp-ipxe/api.inc.php index 0d59ea1d..67da6727 100644 --- a/modules-available/serversetup-bwlp-ipxe/api.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/api.inc.php @@ -76,7 +76,12 @@ if ($menu !== false) { $menu = IPxeMenu::forClient($ip, $uuid); $initLabel = 'init'; } - +// If this is a menu with a single item, treat a timeout of 0 as "boot immediately" instead of "infinite" +if ($menu->itemCount() === 1 && $menu->timeoutMs() === 0 && ($tmp = $menu->getDefaultScriptLabel()) !== false) { + $directBoot = "goto $tmp ||"; +} else { + $directBoot = ''; +} // Get preferred localboot method, depending on system model $localboot = false; @@ -177,6 +182,8 @@ set serverip $serverIp || # Clean up in case we've been chained to imgfree || +$directBoot + imgfetch --name bg-menu /tftp/pxe-menu.png || :start diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php index 991ee403..f437c447 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php @@ -71,6 +71,29 @@ class IPxeMenu return $str; } + public function timeoutMs() + { + return $this->timeoutMs; + } + + /** + * @return int Number of items in this menu + */ + public function itemCount() + { + return count($this->items); + } + + /** + * @return string|false Return script label of default entry, false if not set + */ + public function getDefaultScriptLabel() + { + if ($this->defaultEntryId !== null) + return "m_{$this->menuid}_{$this->defaultEntryId}"; + return false; + } + /* * */ -- cgit v1.2.3-55-g7522