From 184c362f8a94b22e5583b6ec527f6fbf4806f018 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 5 Mar 2018 15:41:40 +0100 Subject: [inc/Event] Don't try to add callback for invalid tasks --- inc/event.inc.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/event.inc.php') diff --git a/inc/event.inc.php b/inc/event.inc.php index 66601607..fe59b2b9 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -111,6 +111,8 @@ class Event public static function activeConfigChanged() { $task = Trigger::ldadp(); + if ($task === false) + return; TaskmanagerCallback::addCallback($task, 'ldadpStartup'); } -- cgit v1.2.3-55-g7522 From 9b24161637553f3889d9a81344e6eec59dc6aa00 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 7 May 2018 17:34:35 +0200 Subject: [serversetup-bwlp] Add log output to ipxe building task --- inc/event.inc.php | 3 +-- inc/trigger.inc.php | 1 + .../serversetup-bwlp/lang/de/template-tags.json | 4 +++- .../serversetup-bwlp/lang/en/template-tags.json | 4 +++- modules-available/serversetup-bwlp/page.inc.php | 20 ++++++++++-------- .../serversetup-bwlp/templates/ipxe_update.html | 24 ++++++++++++++++++---- 6 files changed, 40 insertions(+), 16 deletions(-) (limited to 'inc/event.inc.php') diff --git a/inc/event.inc.php b/inc/event.inc.php index fe59b2b9..b1ee3663 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -98,8 +98,7 @@ class Event public static function serverIpChanged() { error_log('Server ip changed'); - global $tidIpxe; - $tidIpxe = Trigger::ipxe(); + Trigger::ipxe(); if (Module::isAvailable('sysconfig')) { // TODO: Modularize events ConfigModule::serverIpChanged(); } diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index b49cafb0..93f57236 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -25,6 +25,7 @@ class Trigger $task = Taskmanager::submit('CompileIPxe', $data); if (!isset($task['id'])) return false; + Property::set('ipxe-task-id', $task['id'], 15); return $task['id']; } diff --git a/modules-available/serversetup-bwlp/lang/de/template-tags.json b/modules-available/serversetup-bwlp/lang/de/template-tags.json index f80febb0..74ab494b 100644 --- a/modules-available/serversetup-bwlp/lang/de/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/de/template-tags.json @@ -21,9 +21,11 @@ "lang_menuCustomHint3": "und w\u00e4hlen Sie als Standard-Bootverhalten ebenfalls custom.", "lang_menuDisplayTime": "Anzeigedauer des Men\u00fcs", "lang_menuGeneration": "Erzeugen des Bootmen\u00fcs", - "lang_moduleHeading": "iPXE / Boot Menu", + "lang_moduleHeading": "iPXE \/ Boot Menu", + "lang_pxeBuilt": "PXE-Binary gebaut", "lang_seconds": "Sekunden", "lang_set": "Setzen", + "lang_usbBuilt": "USB-Image gebaut", "lang_usbImage": "USB-Image", "lang_usbImgHelp": "Mit dem USB-Image k\u00f6nnen Sie einen bootbaren USB-Stick erstellen, \u00fcber den sich bwLehrpool an Rechnern starten l\u00e4sst, die keinen Netzwerkboot unterst\u00fctzen, bzw. f\u00fcr die keine entsprechende DHCP-Konfiguration vorhanden ist. Dies erfordert dann lediglich, dass in der BIOS-Konfiguration des Rechners USB-Boot zugelassen ist. Der Stick dient dabei lediglich als Einstiegspunkt; es ist nach wie vor ein bwLehrpool-Satellitenserver f\u00fcr den eigentlichen Bootvorgang von N\u00f6ten.", "lang_usbImgHelpLinux": "Nutzen Sie dd, um das Image auf einen USB-Stick zu schreiben. Das Image enth\u00e4lt bereits eine Partitionstabelle, achten Sie daher darauf, dass Sie das Image z.B. nach \/dev\/sdx schreiben, und nicht nach \/dev\/sdx1", diff --git a/modules-available/serversetup-bwlp/lang/en/template-tags.json b/modules-available/serversetup-bwlp/lang/en/template-tags.json index 1948718b..7f519022 100644 --- a/modules-available/serversetup-bwlp/lang/en/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/en/template-tags.json @@ -21,9 +21,11 @@ "lang_menuCustomHint3": "and select as the default boot behavior custom as well.", "lang_menuDisplayTime": "Menu Display Time", "lang_menuGeneration": "Generating boot menu...", - "lang_moduleHeading": "iPXE / Boot Menu", + "lang_moduleHeading": "iPXE \/ Boot Menu", + "lang_pxeBuilt": "Built PXE binary", "lang_seconds": "Seconds", "lang_set": "Set", + "lang_usbBuilt": "Built USB image", "lang_usbImage": "USB image", "lang_usbImgHelp": "The USB image can be used to create a bootable USB stick, which enables you to boot bwLehrpool without changing your DHCP settings or enabling network boot in the clients. The only requirement is that you enable USB boot in the client's BIOS. The USB stick is only used for bootstrapping, the actual bwLehrpool system is still loaded via network from your local bwLehrpool server.", "lang_usbImgHelpLinux": "On Linux you can simply use dd to write the image to a usb stick. The image already contains a partition table, so make sure you write the image to the device itself and not to an already existing partition (e.g. to \/dev\/sdx not \/dev\/sdx1)", diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 78096d7b..52b3afe4 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -54,9 +54,15 @@ class Page_ServerSetup extends Page protected function doRender() { Render::addTemplate("heading"); - $taskid = Request::any('taskid'); - if ($taskid !== false && Taskmanager::isTask($taskid)) { - Render::addTemplate('ipxe_update', array('taskid' => $taskid)); + $task = Property::get('ipxe-task-id'); + if ($task !== false) { + $task = Taskmanager::status($task); + if (!Taskmanager::isTask($task) || Taskmanager::isFinished($task)) { + $task = false; + } + } + if ($task !== false) { + Render::addTemplate('ipxe_update', array('taskid' => $task['id'])); } Permission::addGlobalTags($perms, null, ['edit.menu', 'edit.address', 'download']); @@ -137,9 +143,7 @@ class Page_ServerSetup extends Page } if ($valid) { Property::setServerIp($newAddress); - global $tidIpxe; - if (isset($tidIpxe) && $tidIpxe !== false) - Util::redirect('?do=ServerSetup&taskid=' . $tidIpxe); + Util::redirect('?do=ServerSetup'); } else { Message::addError('invalid-ip', $newAddress); } @@ -163,8 +167,8 @@ class Page_ServerSetup extends Page else $this->currentMenu['masterpassword'] = Crypto::hash6($this->currentMenu['masterpasswordclear']); Property::setBootMenu($this->currentMenu); - $id = Trigger::ipxe(); - Util::redirect('?do=ServerSetup&taskid=' . $id); + Trigger::ipxe(); + Util::redirect('?do=ServerSetup'); } private function handleGetImage() diff --git a/modules-available/serversetup-bwlp/templates/ipxe_update.html b/modules-available/serversetup-bwlp/templates/ipxe_update.html index 9c598667..e7ba5ffa 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe_update.html +++ b/modules-available/serversetup-bwlp/templates/ipxe_update.html @@ -1,20 +1,36 @@
{{lang_menuGeneration}}
-
{{lang_menuGeneration}}
-
-- cgit v1.2.3-55-g7522 From 2d64b9d8f57f28456eb27c4aed2dde26201b6770 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 12 Feb 2019 14:35:49 +0100 Subject: [serversetup-bwlp] Auto-import of old PXELinux config on bootup Also minor improvements to UI and structuring --- inc/event.inc.php | 11 +++ .../serversetup-bwlp/hooks/bootup.inc.php | 11 +++ .../serversetup-bwlp/inc/bootentry.inc.php | 3 +- .../serversetup-bwlp/inc/ipxe.inc.php | 79 ++++++++++++++++++---- .../serversetup-bwlp/inc/pxelinux.inc.php | 40 +++++++++++ .../serversetup-bwlp/lang/de/messages.json | 12 ++-- .../serversetup-bwlp/lang/de/module.json | 4 +- .../serversetup-bwlp/lang/de/template-tags.json | 23 ++++--- modules-available/serversetup-bwlp/page.inc.php | 39 +++++++---- .../serversetup-bwlp/templates/bootentry-list.html | 12 +++- .../templates/ipxe-new-boot-entry.html | 9 ++- .../serversetup-bwlp/templates/menu-edit.html | 2 +- .../serversetup-bwlp/templates/menu-list.html | 13 +++- 13 files changed, 211 insertions(+), 47 deletions(-) create mode 100644 modules-available/serversetup-bwlp/hooks/bootup.inc.php (limited to 'inc/event.inc.php') 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 @@ + 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 @@ +

{{lang_bootentryHead}}

+ +

+ {{lang_bootentryIntro}} +

+ - + + @@ -16,6 +23,9 @@ + {{#entries}} - +
{{lang_bootentryTitle}}Hotkey{{lang_hotkey}}{{lang_refCount}} {{lang_edit}} {{lang_delete}}
{{hotkey}} + {{refs}} + {{#allowEdit}} 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 @@
- +
@@ -121,6 +121,13 @@
{{/builtin}} +

{{lang_referencingMenus}}:

+
+
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 @@

{{lang_listOfMenus}}

+

+ {{lang_menuListIntro}} +

+ @@ -17,7 +21,7 @@ {{title}}
- {{locationCount}} + {{locationCount}} {{^isdefault}} @@ -37,7 +41,7 @@ {{#allowEdit}} - + {{/allowEdit}} @@ -60,6 +64,8 @@ +
+ @@ -88,4 +94,7 @@ function deleteMenu(menuid) { $("#delete-menu-id").val(menuid); } + document.addEventListener('DOMContentLoaded', function() { + $('[data-toggle="tooltip"]').tooltip(); + }); \ No newline at end of file -- cgit v1.2.3-55-g7522