diff options
author | Simon Rettberg | 2024-02-23 17:02:05 +0100 |
---|---|---|
committer | Simon Rettberg | 2024-02-23 17:02:05 +0100 |
commit | b476a91b5851767748d241af754cdfc782552d4d (patch) | |
tree | 4c9616b37210d13d7464dfeca6b3f4cd24fbb62a | |
parent | [minilinux] Harmonize wording some more :) (diff) | |
download | slx-admin-b476a91b5851767748d241af754cdfc782552d4d.tar.gz slx-admin-b476a91b5851767748d241af754cdfc782552d4d.tar.xz slx-admin-b476a91b5851767748d241af754cdfc782552d4d.zip |
[serversetup-bwlp-ipxe] Add initial support for GRUB menus
3 files changed, 17 insertions, 3 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/api.inc.php b/modules-available/serversetup-bwlp-ipxe/api.inc.php index 4ca9fdec..dc78f481 100644 --- a/modules-available/serversetup-bwlp-ipxe/api.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/api.inc.php @@ -1,9 +1,20 @@ <?php (function() { - $type = Request::any('type'); + $type = Request::any('type', null, 'string'); + if ($type === null && isset($_SERVER['HTTP_USER_AGENT'])) { + if (preg_match('/^iPXE/', $_SERVER['HTTP_USER_AGENT'])) { + $type = 'ipxe'; + } elseif (preg_match('/^GRUB/', $_SERVER['HTTP_USER_AGENT'])) { + $type = 'grub'; + } elseif (preg_match('/wget|curl/i', $_SERVER['HTTP_USER_AGENT'])) { + $type = 'bash'; + } + } if ($type === 'bash') { $builder = new ScriptBuilderBash(); + } elseif ($type === 'grub') { + $builder = new ScriptBuilderGrub(); } else { $builder = new ScriptBuilderIpxe(); } diff --git a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php index 919861f0..5812c0cd 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php @@ -333,10 +333,13 @@ class CustomBootEntry extends BootEntry public function toScript(ScriptBuilderBase $builder): string { + // TODO: A (very) simple translator for oneliners like "poweroff || goto fail" maybe? if ($builder instanceof ScriptBuilderIpxe) return $this->ipxe; if ($builder instanceof ScriptBuilderBash) return $this->bash; + if ($builder instanceof ScriptBuilderGrub) + return $this->grub; return ''; } @@ -417,4 +420,4 @@ class SpecialBootEntry extends BootEntry public function addFormFields(array &$array): void { } -}
\ No newline at end of file +} diff --git a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php index 4896f598..9421684f 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php @@ -23,7 +23,7 @@ class ScriptBuilderIpxe extends ScriptBuilderBase } - private function getUrlFull(?bool &$hasExt = null, string $key = null, string $value = null): string + private function getUrlFull(?bool &$hasExt = null, ?string $key = null, ?string $value = null): string { $url = parse_url($_SERVER['REQUEST_URI']); $urlbase = $this->getUrlBase(); |