summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-02-12 14:35:49 +0100
committerSimon Rettberg2019-02-12 14:35:49 +0100
commit2d64b9d8f57f28456eb27c4aed2dde26201b6770 (patch)
tree62d1073b0d401408dd43e0d3731475c9829424a1
parent[serversetup-bwlp] Fix case of platform var (diff)
downloadslx-admin-2d64b9d8f57f28456eb27c4aed2dde26201b6770.tar.gz
slx-admin-2d64b9d8f57f28456eb27c4aed2dde26201b6770.tar.xz
slx-admin-2d64b9d8f57f28456eb27c4aed2dde26201b6770.zip
[serversetup-bwlp] Auto-import of old PXELinux config on bootup
Also minor improvements to UI and structuring
-rw-r--r--inc/event.inc.php11
-rw-r--r--modules-available/serversetup-bwlp/hooks/bootup.inc.php11
-rw-r--r--modules-available/serversetup-bwlp/inc/bootentry.inc.php3
-rw-r--r--modules-available/serversetup-bwlp/inc/ipxe.inc.php79
-rw-r--r--modules-available/serversetup-bwlp/inc/pxelinux.inc.php40
-rw-r--r--modules-available/serversetup-bwlp/lang/de/messages.json12
-rw-r--r--modules-available/serversetup-bwlp/lang/de/module.json4
-rw-r--r--modules-available/serversetup-bwlp/lang/de/template-tags.json23
-rw-r--r--modules-available/serversetup-bwlp/page.inc.php39
-rw-r--r--modules-available/serversetup-bwlp/templates/bootentry-list.html12
-rw-r--r--modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html9
-rw-r--r--modules-available/serversetup-bwlp/templates/menu-edit.html2
-rw-r--r--modules-available/serversetup-bwlp/templates/menu-list.html13
13 files changed, 211 insertions, 47 deletions
diff --git a/inc/event.inc.php b/inc/event.inc.php
index b1ee3663..4e68ab6d 100644
--- a/inc/event.inc.php
+++ b/inc/event.inc.php
@@ -24,6 +24,17 @@ class Event
Property::clearList('cron.key.status');
Property::clearList('cron.key.blocked');
+ // Hooks
+ foreach (Hook::load('bootup') as $hook) {
+ // Isolate for local vars
+ $fun = function() use ($hook) {
+ include_once($hook->file);
+ };
+ $fun();
+ }
+
+ // TODO: Modularize (hooks)
+
// Tasks: fire away
$mountStatus = false;
$mountId = Trigger::mount();
diff --git a/modules-available/serversetup-bwlp/hooks/bootup.inc.php b/modules-available/serversetup-bwlp/hooks/bootup.inc.php
new file mode 100644
index 00000000..50ac04ae
--- /dev/null
+++ b/modules-available/serversetup-bwlp/hooks/bootup.inc.php
@@ -0,0 +1,11 @@
+<?php
+
+$ret = IPxe::importLegacyMenu(false);
+if ($ret !== false) {
+ $num = IPxe::importPxeMenus('/srv/openslx/tftp/pxelinux.cfg');
+ if ($num > 0) {
+ EventLog::info('Imported old PXELinux menu, with ' . $num . ' additional IP-range based menus.');
+ } else {
+ EventLog::info('Imported old PXELinux menu.');
+ }
+}
diff --git a/modules-available/serversetup-bwlp/inc/bootentry.inc.php b/modules-available/serversetup-bwlp/inc/bootentry.inc.php
index 010b660c..69adffd3 100644
--- a/modules-available/serversetup-bwlp/inc/bootentry.inc.php
+++ b/modules-available/serversetup-bwlp/inc/bootentry.inc.php
@@ -95,7 +95,7 @@ class StandardBootEntry extends BootEntry
protected $replace;
protected $autoUnload;
protected $resetConsole;
- protected $arch; // true == available, false == not available
+ protected $arch; // Constants below
const BIOS = 'PCBIOS'; // Only valid for legacy BIOS boot
const EFI = 'EFI'; // Only valid for EFI boot
@@ -105,6 +105,7 @@ class StandardBootEntry extends BootEntry
public function __construct($data = false)
{
if ($data instanceof PxeSection) {
+ // Gets arrayfied below
$this->executable = $data->kernel;
$this->initRd = $data->initrd;
$this->commandLine = ' ' . str_replace('vga=current', '', $data->append) . ' ';
diff --git a/modules-available/serversetup-bwlp/inc/ipxe.inc.php b/modules-available/serversetup-bwlp/inc/ipxe.inc.php
index d5bbb4b2..d34839f0 100644
--- a/modules-available/serversetup-bwlp/inc/ipxe.inc.php
+++ b/modules-available/serversetup-bwlp/inc/ipxe.inc.php
@@ -3,8 +3,16 @@
class IPxe
{
+ /**
+ * Import all IP-Range based pxe menus from the given directory.
+ *
+ * @param string $configPath The pxelinux.cfg path where to look for menu files in hexadecimal IP format.
+ * @return Number of menus imported
+ */
public static function importPxeMenus($configPath)
{
+ $importCount = 0;
+ $menus = [];
foreach (glob($configPath . '/*', GLOB_NOSORT) as $file) {
if (!is_file($file) || !preg_match('~/[A-F0-9]{1,8}$~', $file))
continue;
@@ -29,14 +37,53 @@ class IPxe
unset($loc);
$locations[] = $row;
}
- $menuId = self::insertMenu($content, 'Imported', false, 0, [], []);
+ $menu = PxeLinux::parsePxeLinux($content);
+ $key = $menu->hash(true);
+ if (isset($menus[$key])) {
+ $menuId = $menus[$key];
+ $defId = null;
+ // Figure out the default label, get it's label name
+ foreach ($menu->sections as $section) {
+ if ($section->isDefault) {
+ $defId = $section;
+ } elseif ($defId === null && $section->label === $menu->timeoutLabel) {
+ $defId = $section;
+ }
+ }
+ if ($defId !== null) {
+ $defId = self::cleanLabelFixLocal($defId);
+ // Confirm it actually exists (it should since the menu seems identical) and get menuEntryId
+ $me = Database::queryFirst('SELECT m.defaultentryid, me.menuentryid FROM serversetup_bootentry be
+ INNER JOIN serversetup_menuentry me ON (be.entryid = me.entryid)
+ INNER JOIN serversetup_menu m ON (m.menuid = me.menuid)
+ WHERE be.entryid = :id AND me.menuid = :menuid',
+ ['id' => $defId, 'menuid' => $menuId]);
+ if ($me === false || $me['defaultentryid'] == $me['menuentryid']) {
+ $defId = null; // Not found, or is already default - don't override if it's the same
+ } else {
+ $defId = $me['menuentryid'];
+ }
+ }
+ } else {
+ $menuId = self::insertMenu($menu, 'Imported', false, 0, [], []);
+ $menus[$key] = $menuId;
+ $defId = null;
+ $importCount++;
+ }
if ($menuId === false)
continue;
foreach ($locations as $loc) {
- Database::exec('INSERT IGNORE INTO serversetup_menu_x_location (menuid, locationid)
- VALUES (:menuid, :locationid)', ['menuid' => $menuId, 'locationid' => $loc['locationid']]);
+ if ($loc === false)
+ continue;
+ Database::exec('INSERT IGNORE INTO serversetup_menu_location (menuid, locationid, defaultentryid)
+ VALUES (:menuid, :locationid, :def)', [
+ 'menuid' => $menuId,
+ 'locationid' => $loc['locationid'],
+ 'def' => $defId,
+ ]);
}
}
+ return $importCount;
}
public static function importLegacyMenu($force = false)
@@ -76,16 +123,25 @@ class IPxe
'',
'poweroff' => false,
];
- return self::insertMenu($pxeConfig, $menuTitle, $defaultLabel, $timeoutSecs, $prepend, $append);
+ return self::insertMenu(PxeLinux::parsePxeLinux($pxeConfig), $menuTitle, $defaultLabel, $timeoutSecs, $prepend, $append);
}
- private static function insertMenu($pxeConfig, $menuTitle, $defaultLabel, $defaultTimeoutSeconds, $prepend, $append)
+ /**
+ * @param PxeMenu $pxeMenu
+ * @param string $menuTitle
+ * @param string|false $defaultLabel
+ * @param $defaultTimeoutSeconds
+ * @param $prepend
+ * @param $append
+ * @return bool|int
+ */
+ private static function insertMenu($pxeMenu, $menuTitle, $defaultLabel, $defaultTimeoutSeconds, $prepend, $append)
{
$timeoutMs = [];
$menuEntries = $prepend;
settype($menuEntries, 'array');
- if (!empty($pxeConfig)) {
- $pxe = PxeLinux::parsePxeLinux($pxeConfig);
+ if (!empty($pxeMenu)) {
+ $pxe =& $pxeMenu;
if (!empty($pxe->title)) {
$menuTitle = $pxe->title;
}
@@ -95,11 +151,10 @@ class IPxe
$timeoutMs[] = $pxe->timeoutMs;
$timeoutMs[] = $pxe->totalTimeoutMs;
foreach ($pxe->sections as $section) {
- if ($section->localBoot || preg_match('/chain.c32$/i', $section->kernel)) {
+ if ($section->localBoot || preg_match('/chain\.c32$/i', $section->kernel)) {
$menuEntries['localboot'] = 'localboot';
continue;
}
- $section->mangle();
if ($section->label === null) {
if (!$section->isHidden && !empty($section->title)) {
$menuEntries[] = $section->title;
@@ -221,7 +276,7 @@ class IPxe
'data' => json_encode([
'executable' => '/boot/default/kernel',
'initRd' => '/boot/default/initramfs-stage31',
- 'commandLine' => 'slxbase=boot/default quiet splash loglevel=5 rd.systemd.show_status=auto ${ipappend1} ${ipappend2}',
+ 'commandLine' => 'slxbase=boot/default quiet splash loglevel=5 rd.systemd.show_status=auto intel_iommu=igfx_off ${ipappend1} ${ipappend2}',
'replace' => true,
'autoUnload' => true,
'resetConsole' => true,
@@ -235,7 +290,7 @@ class IPxe
'data' => json_encode([
'executable' => '/boot/default/kernel',
'initRd' => '/boot/default/initramfs-stage31',
- 'commandLine' => 'slxbase=boot/default loglevel=7 ${ipappend1} ${ipappend2}',
+ 'commandLine' => 'slxbase=boot/default loglevel=7 intel_iommu=igfx_off ${ipappend1} ${ipappend2}',
'replace' => true,
'autoUnload' => true,
'resetConsole' => true,
@@ -314,7 +369,7 @@ class IPxe
*/
private static function pxe2BootEntry($section)
{
- if (preg_match('/(pxechain.com|pxechn.c32)$/i', $section->kernel)) {
+ if (preg_match('/(pxechain\.com|pxechn\.c32)$/i', $section->kernel)) {
// Chaining -- create script
$args = preg_split('/\s+/', $section->append);
$script = '';
diff --git a/modules-available/serversetup-bwlp/inc/pxelinux.inc.php b/modules-available/serversetup-bwlp/inc/pxelinux.inc.php
index db3dac4b..1d022fef 100644
--- a/modules-available/serversetup-bwlp/inc/pxelinux.inc.php
+++ b/modules-available/serversetup-bwlp/inc/pxelinux.inc.php
@@ -86,6 +86,9 @@ class PxeLinux
if ($section !== null) {
$menu->sections[] = $section;
}
+ foreach ($menu->sections as $section) {
+ $section->mangle();
+ }
return $menu;
}
@@ -131,6 +134,7 @@ class PxeLinux
*/
class PxeMenu
{
+
/**
* @var string menu title, shown at the top of the menu
*/
@@ -160,6 +164,40 @@ class PxeMenu
* @var PxeSection[] list of sections the menu contains
*/
public $sections = [];
+
+ public function hash($fuzzy)
+ {
+ $ctx = hash_init('md5');
+ if (!$fuzzy) {
+ hash_update($ctx, $this->title);
+ hash_update($ctx, $this->timeoutLabel);
+ }
+ hash_update($ctx, $this->timeoutMs);
+ foreach ($this->sections as $section) {
+ if ($fuzzy) {
+ hash_update($ctx, mb_strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $section->title)));
+ } else {
+ hash_update($ctx, $section->label);
+ hash_update($ctx, $section->title);
+ hash_update($ctx, $section->indent);
+ hash_update($ctx, $section->helpText);
+ hash_update($ctx, $section->isDefault);
+ hash_update($ctx, $section->hotkey);
+ }
+ hash_update($ctx, $section->kernel);
+ hash_update($ctx, $section->append);
+ hash_update($ctx, $section->ipAppend);
+ hash_update($ctx, $section->passwd);
+ hash_update($ctx, $section->isHidden);
+ hash_update($ctx, $section->isDisabled);
+ hash_update($ctx, $section->localBoot);
+ foreach ($section->initrd as $initrd) {
+ hash_update($ctx, $initrd);
+ }
+ }
+ return hash_final($ctx, false);
+ }
+
}
/**
@@ -170,6 +208,7 @@ class PxeMenu
*/
class PxeSection
{
+
/**
* @var string label used internally in PXEMENU definition to address this entry
*/
@@ -258,5 +297,6 @@ class PxeSection
$this->initrd = [];
}
}
+
}
diff --git a/modules-available/serversetup-bwlp/lang/de/messages.json b/modules-available/serversetup-bwlp/lang/de/messages.json
index de48ef0b..0772a7e4 100644
--- a/modules-available/serversetup-bwlp/lang/de/messages.json
+++ b/modules-available/serversetup-bwlp/lang/de/messages.json
@@ -1,10 +1,10 @@
{
- "boot-entry-created": "Booteintrag {{0}} erzeugt",
- "boot-entry-updated": "Booteintrag {{0}} aktualisiert",
- "bootentry-deleted": "Booteintrag gel\u00f6scht",
+ "boot-entry-created": "Men\u00fceintrag {{0}} erzeugt",
+ "boot-entry-updated": "Men\u00fceintrag {{0}} aktualisiert",
+ "bootentry-deleted": "Men\u00fceintrag gel\u00f6scht",
"error-saving-entry": "Fehler beim Speichern des Eintrags {{0}}: {{1}}",
"image-not-found": "USB-Image nicht gefunden. Generieren Sie das Bootmen\u00fc neu.",
- "invalid-boot-entry": "Ung\u00fcltiger Booteintrag: {{0}}",
+ "invalid-boot-entry": "Ung\u00fcltiger Men\u00fceintrag: {{0}}",
"invalid-ip": "Kein Interface ist auf die Adresse {{0}} konfiguriert",
"invalid-menu-id": "Ung\u00fcltige Men\u00fc-ID: {{0}}",
"localboot-invalid-method": "Ung\u00fcltige localboot-Methode: {{0}}",
@@ -14,8 +14,8 @@
"menu-deleted": "Men\u00fc gel\u00f6scht",
"menu-saved": "Men\u00fc wurde gespeichert",
"menu-set-default": "Standardmen\u00fc wurde gesetzt",
- "missing-bootentry-data": "Fehlende Daten f\u00fcr den Booteintrag",
+ "missing-bootentry-data": "Fehlende Daten f\u00fcr den Men\u00fceintrag",
"no-ip-addr-set": "Bitte w\u00e4hlen Sie die prim\u00e4re IP-Adresse des Servers",
"no-such-menu": "Men\u00fc mit ID {{0}} existiert nicht",
"unknown-bootentry-type": "Unbekannter Eintrags-Typ: {{0}}"
-} \ No newline at end of file
+}
diff --git a/modules-available/serversetup-bwlp/lang/de/module.json b/modules-available/serversetup-bwlp/lang/de/module.json
index 31d563f0..9a8de39c 100644
--- a/modules-available/serversetup-bwlp/lang/de/module.json
+++ b/modules-available/serversetup-bwlp/lang/de/module.json
@@ -12,8 +12,8 @@
"module_name": "iPXE \/ Boot Menu",
"page_title": "PXE- und Boot-Einstellungen",
"submenu_address": "Server-Adresse",
- "submenu_bootentry": "Booteintr\u00e4ge verwalten",
+ "submenu_bootentry": "Men\u00fceintr\u00e4ge verwalten",
"submenu_download": "Downloads",
"submenu_localboot": "HDD-Boot",
"submenu_menu": "Men\u00fcs verwalten"
-} \ No newline at end of file
+}
diff --git a/modules-available/serversetup-bwlp/lang/de/template-tags.json b/modules-available/serversetup-bwlp/lang/de/template-tags.json
index a242be5e..198a1517 100644
--- a/modules-available/serversetup-bwlp/lang/de/template-tags.json
+++ b/modules-available/serversetup-bwlp/lang/de/template-tags.json
@@ -1,8 +1,9 @@
{
"lang_active": "Aktiv",
"lang_add": "Hinzuf\u00fcgen",
- "lang_addBootentry": "Booteintrag hinzuf\u00fcgen",
+ "lang_addBootentry": "Men\u00fceintrag hinzuf\u00fcgen",
"lang_addMenu": "Men\u00fc hinzuf\u00fcgen",
+ "lang_additionalInfoLink": "Weitere Informationen",
"lang_archAgnostic": "Architekturunabh\u00e4ngig",
"lang_archBoth": "BIOS und EFI",
"lang_archSelector": "Architekturauswahl",
@@ -10,13 +11,15 @@
"lang_biosOnly": "Nur BIOS",
"lang_bootAddress": "Boot-Adresse des Servers",
"lang_bootBehavior": "Standard-Bootverhalten",
- "lang_bootEntryData": "Daten des Booteintrags",
+ "lang_bootEntryData": "Daten des Men\u00fceintrags",
"lang_bootHint": "Das Bootmen\u00fc muss nach einer \u00c4nderung der IP-Adresse neu generiert werden. In der Regel geschieht dies automatisch, der Vorgang kann in der Sektion Bootmen\u00fc allerdings auch manuell ausgel\u00f6st werden.",
"lang_bootInfo": "Hier k\u00f6nnen Anpassungen am Erscheinungsbild des Bootmen\u00fcs vorgenommen werden.",
"lang_bootMenu": "Bootmen\u00fc",
"lang_bootMenuCreate": "Bootmen\u00fc erzeugen",
- "lang_bootentryDeleteConfirm": "Sind Sie sicher, dass Sie diesen Booteintrag l\u00f6schen wollen?",
- "lang_bootentryTitle": "Booteintrag",
+ "lang_bootentryDeleteConfirm": "Sind Sie sicher, dass Sie diesen Men\u00fceintrag l\u00f6schen wollen?",
+ "lang_bootentryHead": "Men\u00fceintr\u00e4ge",
+ "lang_bootentryIntro": "Hier k\u00f6nnen Sie Men\u00fceintr\u00e4ge definieren, die sich sp\u00e4ter einem Men\u00fc zuweisen lassen. Ein Men\u00fceintrag besteht entweder aus einem zu ladenen Kernel\/Image plus optional initrd, oder aus einem iPXE-Script.",
+ "lang_bootentryTitle": "Men\u00fceintrag",
"lang_chooseIP": "Bitte w\u00e4hlen Sie die IP-Adresse, \u00fcber die der Server von den Clients zum Booten angesprochen werden soll.",
"lang_commandLine": "Command line",
"lang_count": "Anzahl",
@@ -26,7 +29,7 @@
"lang_editBuiltinWarn": "Achtung! Sie bearbeiten einen der vorgegebenen Eintr\u00e4ge! Bei einem Update k\u00f6nnten Ihre \u00c4nderungen wieder \u00fcberschrieben werden",
"lang_editMenuHead": "Men\u00fc bearbeiten",
"lang_efiOnly": "Nur EFI",
- "lang_entryChooserTitle": "Booteintrag ausw\u00e4hlen",
+ "lang_entryChooserTitle": "Men\u00fceintrag ausw\u00e4hlen",
"lang_entryId": "ID",
"lang_entryTitle": "Bezeichnung",
"lang_example": "Beispiel",
@@ -40,6 +43,7 @@
"lang_idFormatHint": "(Max. 16 Zeichen, nur a-z 0-9 - _)",
"lang_imageToLoad": "Zu ladendes Image (z.B. Kernel)",
"lang_initRd": "Zu ladendes initramfs",
+ "lang_ipxeWikiUrl": "im iPXE Wiki",
"lang_isDefault": "Standard",
"lang_listOfMenus": "Men\u00fcliste",
"lang_localBootDefault": "Standardm\u00e4\u00dfig verwendete Methode, um von Festplatte zu booten",
@@ -49,7 +53,7 @@
"lang_localHDD": "Lokale HDD",
"lang_locationCount": "Anzahl Orte",
"lang_masterPassword": "Master-Passwort",
- "lang_masterPasswordHelp": "Das Master-Passwort wird ben\u00f6tigt, um einen Booteintrag direkt am Client tempor\u00e4r durch Dr\u00fccken der Tab-Taste zu editieren. Da dies f\u00fcr Manipulation am Client genutzt werden kann, sollte diese Funktion unbedingt mit einem Passwort gesch\u00fctzt werden.",
+ "lang_masterPasswordHelp": "Das Master-Passwort wird ben\u00f6tigt, um einen Men\u00fceintrag direkt am Client tempor\u00e4r durch Dr\u00fccken der Tab-Taste zu editieren. Da dies f\u00fcr Manipulation am Client genutzt werden kann, sollte diese Funktion unbedingt mit einem Passwort gesch\u00fctzt werden.",
"lang_menuCustom": "Benutzerdefinierter Men\u00fczusatz",
"lang_menuCustomHint1": "Hier haben Sie die M\u00f6glichkeit, eigenen Men\u00fc-Code zum angezeigten PXE-Men\u00fc hinzuzuf\u00fcgen, um z.B. auf weitere PXE-Server zu verweisen. Das Format entspricht dem syslinux Men\u00fcformat.",
"lang_menuCustomHint2": "Sie k\u00f6nnen ein oder mehrere Eintr\u00e4ge erzeugen. Wenn Sie einen Eintrag erzeugen m\u00f6chten, der automatisch gestartet wird, wenn der Benutzer keine Auswahl t\u00e4tigt, vergeben Sie als",
@@ -58,16 +62,19 @@
"lang_menuDisplayTime": "Anzeigedauer des Men\u00fcs",
"lang_menuEntryOverride": "Standardeintrag \u00fcberschreiben",
"lang_menuGeneration": "Erzeugen des Bootmen\u00fcs",
+ "lang_menuListIntro": "Hier sehen Sie eine Liste aller vorhandenen Men\u00fcs, deren Zuordnung zu R\u00e4umen sowie die M\u00f6glichkeit, diese zu editieren oder l\u00f6schen. Um ein Men\u00fc einem bestimmten Raum zuzuweisen, besuchen Sie bitte den Men\u00fcpunkt \"R\u00e4ume\/Orte\".",
"lang_menuLocations": "Zugewiesene Orte",
"lang_menuTimeout": "Timeout",
"lang_menuTitle": "Men\u00fc",
"lang_moduleHeading": "iPXE \/ Boot Menu",
- "lang_newBootEntryHead": "Neuer Booteintrag",
+ "lang_newBootEntryHead": "Neuer Men\u00fceintrag",
"lang_newMenu": "Neues Men\u00fc",
"lang_none": "(keine)",
"lang_override": "\u00dcberschreiben",
"lang_pxeBuilt": "PXE-Binary gebaut",
"lang_recompileHint": "iPXE-Binaries jetzt neu kompilieren. Normalerweise wird dieser Vorgang bei \u00c4nderungen automatisch ausgef\u00fchrt. Sollten Bootprobleme auftreten, k\u00f6nnen Sie hier den Vorgang manuell ansto\u00dfen.",
+ "lang_refCount": "Referenzen",
+ "lang_referencingMenus": "Verkn\u00fcpfte Men\u00fcs",
"lang_scriptContent": "Script",
"lang_seconds": "Sekunden",
"lang_set": "Setzen",
@@ -84,4 +91,4 @@
"lang_usbImgHelpWindows": "Unter Windows muss zun\u00e4chst ein Programm besorgt werden, mit dem sich Images direkt auf einen USB-Stick schreiben lassen. Es gibt gleich mehrere kostenlose und quelloffene Programme, eines davon ist Rufus. Rufus wurde mit dem bwLehrpool-Image gestetet. Nach dem Starten des Programms ist lediglich das heruntergeladene Image zu \u00f6ffnen, sowie in der Liste der Laufwerke der richtige USB-Stick auszuw\u00e4hlen (damit Sie nicht versehentlich Daten auf dem falschen Laufwerk \u00fcberschreiben!)",
"lang_useDefaultMenu": "\u00dcbergeordnetes Men\u00fc verwenden",
"lang_useDefaultMenuEntry": "(Vorgabe des Men\u00fcs)"
-} \ No newline at end of file
+}
diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php
index 6c32cb82..bb69fecf 100644
--- a/modules-available/serversetup-bwlp/page.inc.php
+++ b/modules-available/serversetup-bwlp/page.inc.php
@@ -32,12 +32,6 @@ class Page_ServerSetup extends Page
Util::redirect('?do=Main');
}
- if (Request::any('bla') == 'blu') {
- IPxe::importLegacyMenu();
- IPxe::importPxeMenus('/srv/openslx/tftp/pxelinux.cfg');
- die('DONE');
- }
-
if (Request::any('action') === 'getimage') {
User::assertPermission("download");
$this->handleGetImage();
@@ -277,7 +271,10 @@ class Page_ServerSetup extends Page
{
$allowEdit = User::hasPermission('ipxe.bootentry.edit');
- $res = Database::simpleQuery("SELECT entryid, hotkey, title, builtin FROM serversetup_bootentry");
+ $res = Database::simpleQuery("SELECT be.entryid, be.hotkey, be.title, be.builtin, Count(*) AS refs FROM serversetup_bootentry be
+ INNER JOIN serversetup_menuentry sm USING (entryid)
+ GROUP BY be.entryid
+ ORDER BY be.title ASC");
$bootentryTable = [];
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$bootentryTable[] = $row;
@@ -295,8 +292,13 @@ class Page_ServerSetup extends Page
// TODO Permission::addGlobalTags($perms, null, ['edit.menu', 'edit.address', 'download']);
- $res = Database::simpleQuery("SELECT m.menuid, m.title, m.isdefault, GROUP_CONCAT(l.locationid) AS locations
- FROM serversetup_menu m LEFT JOIN serversetup_menu_location l USING (menuid) GROUP BY menuid ORDER BY title");
+ $res = Database::simpleQuery("SELECT m.menuid, m.title, m.isdefault, GROUP_CONCAT(l.locationid) AS locations,
+ GROUP_CONCAT(ll.locationname SEPARATOR ', ') AS locnames
+ FROM serversetup_menu m
+ LEFT JOIN serversetup_menu_location l USING (menuid)
+ LEFT JOIN location ll USING (locationid)
+ GROUP BY menuid
+ ORDER BY title");
$menuTable = [];
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
if (empty($row['locations'])) {
@@ -351,6 +353,7 @@ class Page_ServerSetup extends Page
Message::addError('invalid-menu-id', $id);
Util::redirect('?do=serversetup&show=menu');
}
+ $highlight = Request::get('highlight', false, 'string');
if ($id !== 0 && !$this->hasMenuPermission($id, 'ipxe.menu.edit')) {
$menu['readonly'] = 'readonly';
$menu['disabled'] = 'disabled';
@@ -361,12 +364,19 @@ class Page_ServerSetup extends Page
}
$menu['timeout'] = round($menu['timeoutms'] / 1000);
- $menu['entries'] = Database::queryAll("SELECT menuentryid, entryid, hotkey, title, hidden, sortval, plainpass FROM
+ $menu['entries'] = [];
+ $res = Database::simpleQuery("SELECT menuentryid, entryid, hotkey, title, hidden, sortval, plainpass FROM
serversetup_menuentry WHERE menuid = :id ORDER BY sortval ASC", compact('id'));
+ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if ($row['entryid'] == $highlight) {
+ $row['highlight'] = 'active';
+ }
+ $menu['entries'][] = $row;
+ }
$menu['keys'] = array_map(function ($item) { return ['key' => $item]; }, MenuEntry::getKeyList());
$menu['entrylist'] = Database::queryAll("SELECT entryid, title, hotkey, data FROM serversetup_bootentry ORDER BY title ASC");
foreach ($menu['entrylist'] as &$bootentry) {
- $bootentry['json'] = $bootentry['data'];
+ //$bootentry['json'] = $bootentry['data'];
$bootentry['data'] = json_decode($bootentry['data'], true);
if (array_key_exists('arch', $bootentry['data'])) {
$bootentry['data']['PCBIOS'] = array('executable' => $bootentry['data']['executable']['PCBIOS'],
@@ -386,7 +396,7 @@ class Page_ServerSetup extends Page
$bootentry['data']['arch'] = Dictionary::translateFile('template-tags','lang_archBoth', true);
}
- } else {
+ } elseif (!array_key_exists('script', $bootentry['data'])) {
$bootentry['data']['arch'] = Dictionary::translateFile('template-tags','lang_archAgnostic', true);
$bootentry['data']['archAgnostic'] = array('executable' => $bootentry['data']['executable'],
'initRd' => $bootentry['data']['initRd'],
@@ -428,8 +438,11 @@ class Page_ServerSetup extends Page
}
$entry->addFormFields($params);
$params['title'] = $row['title'];
- $params['oldentryid'] = $params['entryid'] = $row['entryid'];
+ $params['entryid'] = $row['entryid'];
$params['builtin'] = $row['builtin'];
+ $params['menus'] = Database::queryAll('SELECT m.menuid, m.title FROM serversetup_menu m
+ INNER JOIN serversetup_menuentry me ON (me.menuid = m.menuid)
+ WHERE me.entryid = :entryid', ['entryid' => $row['entryid']]);
}
Render::addTemplate('ipxe-new-boot-entry', $params);
diff --git a/modules-available/serversetup-bwlp/templates/bootentry-list.html b/modules-available/serversetup-bwlp/templates/bootentry-list.html
index 929b8c47..0cf005c5 100644
--- a/modules-available/serversetup-bwlp/templates/bootentry-list.html
+++ b/modules-available/serversetup-bwlp/templates/bootentry-list.html
@@ -1,8 +1,15 @@
+<h2>{{lang_bootentryHead}}</h2>
+
+<p>
+ {{lang_bootentryIntro}}
+</p>
+
<table class="table">
<thead>
<tr>
<th>{{lang_bootentryTitle}}</th>
- <th>Hotkey</th>
+ <th>{{lang_hotkey}}</th>
+ <th class="slx-smallcol">{{lang_refCount}}</th>
<th class="slx-smallcol">{{lang_edit}}</th>
<th class="slx-smallcol">{{lang_delete}}</th>
</tr>
@@ -16,6 +23,9 @@
<td>
{{hotkey}}
</td>
+ <td align="right">
+ {{refs}}
+ </td>
<td align="center">
{{#allowEdit}}
<a href="?do=serversetup&amp;show=editbootentry&amp;id={{entryid}}" class="btn btn-xs btn-default">
diff --git a/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html b/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html
index fe496029..7e82b5cc 100644
--- a/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html
+++ b/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html
@@ -14,7 +14,7 @@
<form method="post" action="?do=serversetup">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="action" value="savebootentry">
- <input type="hidden" name="entryid" value="{{oldentryid}}">
+ <input type="hidden" name="entryid" value="{{entryid}}">
<div class="form-group">
<div class="radio">
@@ -121,6 +121,13 @@
</div>
{{/builtin}}
+ <p class="slx-bold">{{lang_referencingMenus}}:</p>
+ <ul>
+ {{#menus}}
+ <a href="?do=serversetup&amp;show=editmenu&amp;id={{menuid}}&amp;highlight={{entryid}}">{{title}}</a>
+ {{/menus}}
+ </ul>
+
<div class="buttonbar text-right">
<button type="submit" class="btn btn-primary">
<span class="glyphicon glyphicon-floppy-disk"></span>
diff --git a/modules-available/serversetup-bwlp/templates/menu-edit.html b/modules-available/serversetup-bwlp/templates/menu-edit.html
index 21c6a30e..1598a2b7 100644
--- a/modules-available/serversetup-bwlp/templates/menu-edit.html
+++ b/modules-available/serversetup-bwlp/templates/menu-edit.html
@@ -52,7 +52,7 @@
</thead>
<tbody id="table-body" style="overflow: auto;">
{{#entries}}
- <tr>
+ <tr class="{{highlight}}">
<input type="hidden" class="sort-val" name="entry[{{menuentryid}}][sortval]" value="{{sortval}}">
<input type="hidden" name="entry[{{menuentryid}}][hidden]" value="0">
<td class="drag-handler" style="cursor: pointer;text-align: center; vertical-align: middle;">
diff --git a/modules-available/serversetup-bwlp/templates/menu-list.html b/modules-available/serversetup-bwlp/templates/menu-list.html
index 67365a33..545f22a9 100644
--- a/modules-available/serversetup-bwlp/templates/menu-list.html
+++ b/modules-available/serversetup-bwlp/templates/menu-list.html
@@ -1,5 +1,9 @@
<h2>{{lang_listOfMenus}}</h2>
+<p>
+ {{lang_menuListIntro}}
+</p>
+
<table class="table">
<thead>
<tr>
@@ -17,7 +21,7 @@
{{title}}
</td>
<td class="text-right">
- {{locationCount}}
+ <span class="badge" data-toggle="tooltip" data-placement="top" title="{{locnames}}">{{locationCount}}</span>
</td>
<td align="center">
{{^isdefault}}
@@ -37,7 +41,7 @@
</td>
<td align="center">
{{#allowEdit}}
- <a href="?do=serversetup&amp;show=editmenu&amp;id={{menuid}}" class="btn btn-xs btn-primary">
+ <a href="?do=serversetup&amp;show=editmenu&amp;id={{menuid}}" class="btn btn-xs btn-default">
<span class="glyphicon glyphicon-edit"></span>
</a>
{{/allowEdit}}
@@ -60,6 +64,8 @@
</a>
</div>
+<div class="clearfix"></div>
+
<!-- Modals -->
<form method="post" action="?do=serversetup">
@@ -88,4 +94,7 @@
function deleteMenu(menuid) {
$("#delete-menu-id").val(menuid);
}
+ document.addEventListener('DOMContentLoaded', function() {
+ $('[data-toggle="tooltip"]').tooltip();
+ });
</script> \ No newline at end of file