summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/serversetup-bwlp-ipxe/api.inc.php13
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php5
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/scriptbuilderipxe.inc.php2
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();