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-10 17:27:56 +0200
commit1bf303df784aec63c7f2d3e426bcba4e3a7adbcd (patch)
tree782b3eb9062d6c510959fd087f96f37c543bc0af /modules-available/minilinux/inc/linuxbootentryhook.inc.php
parent[serversetup-bwlp-ipxe] Progress on new structure (+bash) (diff)
downloadslx-admin-1bf303df784aec63c7f2d3e426bcba4e3a7adbcd.tar.gz
slx-admin-1bf303df784aec63c7f2d3e426bcba4e3a7adbcd.tar.xz
slx-admin-1bf303df784aec63c7f2d3e426bcba4e3a7adbcd.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 19acedd9..e3090054 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'])) {
@@ -159,6 +175,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;
}
}