From 0a9ff597aeb988c871ed6a755c9f054733e6778f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 15 Jan 2024 11:54:44 +0100 Subject: [serversetup-bwlp-ipxe] Move PXELinux classes to own files --- .../serversetup-bwlp-ipxe/inc/pxesection.inc.php | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 modules-available/serversetup-bwlp-ipxe/inc/pxesection.inc.php (limited to 'modules-available/serversetup-bwlp-ipxe/inc/pxesection.inc.php') diff --git a/modules-available/serversetup-bwlp-ipxe/inc/pxesection.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/pxesection.inc.php new file mode 100644 index 00000000..2d9cd6ab --- /dev/null +++ b/modules-available/serversetup-bwlp-ipxe/inc/pxesection.inc.php @@ -0,0 +1,117 @@ +label = $label; } + + public function mangle() + { + if (($i = strpos($this->title, '^')) !== false) { + $this->hotkey = strtoupper($this->title[$i + 1]); + $this->title = substr($this->title, 0, $i) . substr($this->title, $i + 1); + } + if (strpos($this->append, 'initrd=') !== false) { + $parts = preg_split('/\s+/', $this->append); + $this->append = ''; + for ($i = 0; $i < count($parts); ++$i) { + if (preg_match('/^initrd=(.*)$/', $parts[$i], $out)) { + if (!empty($this->initrd)) { + $this->initrd .= ','; + } + $this->initrd .= $out[1]; + } else { + $this->append .= ' ' . $parts[$i]; + } + } + $this->append = trim($this->append); + } + if (is_string($this->initrd)) { + $this->initrd = explode(',', $this->initrd); + } elseif (!is_array($this->initrd)) { + $this->initrd = []; + } + } + + /** + * Does this appear to be an entry that triggers localboot? + */ + public function isLocalboot(): bool + { + return $this->localBoot !== false || preg_match('/chain\.c32$/i', $this->kernel); + } + + /** + * Is this (most likely) a separating entry only that cannot be selected? + */ + public function isTextOnly(): bool + { + return ($this->label === null || empty($this->kernel)) && !$this->isHidden && !empty($this->title); + } + +} \ No newline at end of file -- cgit v1.2.3-55-g7522