summaryrefslogtreecommitdiffstats
path: root/modules-available/minilinux/inc/linuxbootentryhook.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2020-07-10 17:27:56 +0200
committerSimon Rettberg2020-07-30 13:31:34 +0200
commit04449f369f42469c707e134dc2dab66938607ddd (patch)
tree68ceb6de1a96f8327f91e6ea2c77be24dcd7b091 /modules-available/minilinux/inc/linuxbootentryhook.inc.php
parent[minilinux] Lower update disable to 5 mins (was 10) (diff)
downloadslx-admin-04449f369f42469c707e134dc2dab66938607ddd.tar.gz
slx-admin-04449f369f42469c707e134dc2dab66938607ddd.tar.xz
slx-admin-04449f369f42469c707e134dc2dab66938607ddd.zip
[minilinux] (bootentry-hook) Add entry for "latest from branch"
The iPXE menu item of type "minilinux" will now show an option to automatically use the latest locally installed version for each branch.
Diffstat (limited to 'modules-available/minilinux/inc/linuxbootentryhook.inc.php')
-rw-r--r--modules-available/minilinux/inc/linuxbootentryhook.inc.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/modules-available/minilinux/inc/linuxbootentryhook.inc.php b/modules-available/minilinux/inc/linuxbootentryhook.inc.php
index 324ffc7e..30ede469 100644
--- a/modules-available/minilinux/inc/linuxbootentryhook.inc.php
+++ b/modules-available/minilinux/inc/linuxbootentryhook.inc.php
@@ -37,6 +37,7 @@ class LinuxBootEntryHook extends BootEntryHook
/*
* Dictionary::translate('default_boot_entry');
* Dictionary::translate('not_installed_hint');
+ * Dictionary::translate('latest_of_branch');
*/
$array = [];
$array[] = new HookEntryGroup($this->name(), [
@@ -49,12 +50,19 @@ class LinuxBootEntryHook extends BootEntryHook
// Group by branch for detailed listing
foreach ($branches as $branch) {
if (isset($versions[$branch['branchid']])) {
- $group = [];
+ $group = [
+ new HookEntry($branch['branchid'],
+ $branch['branchid'] . ' '
+ . Dictionary::translateFileModule('minilinux', 'module',
+ 'latest_of_branch', true),
+ true),
+ ];
foreach ($versions[$branch['branchid']] as $version) {
$valid = $version['installed'] != 0;
$title = $version['versionid'] . ' ' . $version['title'];
if (!$valid) {
- $title .= ' ' . Dictionary::translateFileModule('minilinux', 'module', 'not_installed_hint');
+ $title .= ' ' . Dictionary::translateFileModule('minilinux', 'module',
+ 'not_installed_hint', true);
}
$group[] = new HookEntry($version['versionid'], $title, $valid);
}
@@ -65,7 +73,7 @@ class LinuxBootEntryHook extends BootEntryHook
}
/**
- * @param $id
+ * @param $localData
* @return BootEntry the actual boot entry instance for given entry, false if invalid id
*/
public function getBootEntryInternal($localData)
@@ -76,13 +84,21 @@ class LinuxBootEntryHook extends BootEntryHook
} else {
$effectiveId = $id;
}
- $res = Database::queryFirst('SELECT installed, data FROM minilinux_version WHERE versionid = :id', ['id' => $effectiveId]);
+ $res = Database::queryFirst('SELECT versionid, installed, data FROM minilinux_version WHERE versionid = :id',
+ ['id' => $effectiveId]);
+ if ($res === false) {
+ // Maybe this is a branchid, which means latest from according branch (installed only)
+ $res = Database::queryFirst('SELECT versionid, installed, data FROM minilinux_version WHERE branchid = :id
+ ORDER BY installed DESC, dateline DESC LIMIT 1', // Order by installed instead of WHERE for better errormsg
+ ['id' => $effectiveId]);
+ }
if ($res === false) {
return BootEntry::newCustomBootEntry(['script' => 'prompt Invalid minilinux boot entry id: ' . $id]);
}
if ($res['installed'] == 0) {
return BootEntry::newCustomBootEntry(['script' => 'prompt Selected version not currently installed on server: ' . $effectiveId]);
}
+ $effectiveId = $res['versionid']; // In case we selected from a branchid, so above message doesn't show versionid
$remoteData = json_decode($res['data'], true);
$bios = $efi = false;
if (!@is_array($remoteData['agnostic']) && !@is_array($remoteData['efi']) && !@is_array($remoteData['bios'])) {
@@ -157,6 +173,9 @@ class LinuxBootEntryHook extends BootEntryHook
if ($id === 'default')
return true; // Meta-version that links to whatever the default is set to
$res = Database::queryFirst('SELECT installed FROM minilinux_version WHERE versionid = :id', ['id' => $id]);
- return $res !== false && $res['installed'];
+ if ($res !== false && $res['installed'])
+ return true;
+ $res = Database::queryFirst('SELECT branchid FROM minilinux_branch WHERE branchid = :id', ['id' => $id]);
+ return $res !== false;
}
}