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 --- .../serversetup-bwlp/templates/ipxe_update.html | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'modules-available/serversetup-bwlp/templates/ipxe_update.html') 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 b5300459e4ae0bfe411dc3856d9dee181754e178 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 7 May 2018 17:41:01 +0200 Subject: [serversetup-bwlp] Tweak help text --- modules-available/serversetup-bwlp/lang/de/template-tags.json | 2 +- modules-available/serversetup-bwlp/lang/en/template-tags.json | 2 +- modules-available/serversetup-bwlp/templates/ipxe_update.html | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'modules-available/serversetup-bwlp/templates/ipxe_update.html') diff --git a/modules-available/serversetup-bwlp/lang/de/template-tags.json b/modules-available/serversetup-bwlp/lang/de/template-tags.json index 74ab494b..8d612ab0 100644 --- a/modules-available/serversetup-bwlp/lang/de/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/de/template-tags.json @@ -11,7 +11,7 @@ "lang_downloadImage": "USB-Image herunterladen", "lang_downloadRufus": "Rufus herunterladen", "lang_example": "Beispiel", - "lang_generationFailed": "Erzeugen des Bootmen\u00fcs fehlgeschlagen. Der Netzwerkboot von bwLehrpool wird wahrscheinlich nicht funktionieren. Wenn Sie den Fehler nicht selbst beheben k\u00f6nnen, melden Sie bitte obenstehende Fehlermeldung an das bwLehrpool-Projekt.", + "lang_generationFailed": "Erzeugen des Bootmen\u00fcs fehlgeschlagen. Der Netzwerkboot von bwLehrpool wird wahrscheinlich nicht funktionieren. Wenn Sie den Fehler nicht selbst beheben k\u00f6nnen, melden Sie bitte die Logausgabe an das bwLehrpool-Projekt.", "lang_localHDD": "Lokale HDD", "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.", diff --git a/modules-available/serversetup-bwlp/lang/en/template-tags.json b/modules-available/serversetup-bwlp/lang/en/template-tags.json index 7f519022..9bb55f93 100644 --- a/modules-available/serversetup-bwlp/lang/en/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/en/template-tags.json @@ -11,7 +11,7 @@ "lang_downloadImage": "Download USB Image", "lang_downloadRufus": "Download Rufus", "lang_example": "Example", - "lang_generationFailed": "Could not generate boot menu. The bwLehrpool-System might not work properly. If you can't fix the problem, please report the error message above to the bwLehrpool project.", + "lang_generationFailed": "Could not generate boot menu. The bwLehrpool-System might not work properly. If you can't fix the problem, please report the error log below to the bwLehrpool project.", "lang_localHDD": "Local HDD", "lang_masterPassword": "Master Password", "lang_masterPasswordHelp": "The master password is required to edit a boot menu entry. This should be set for security reasons.", diff --git a/modules-available/serversetup-bwlp/templates/ipxe_update.html b/modules-available/serversetup-bwlp/templates/ipxe_update.html index e7ba5ffa..c5aafa1c 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe_update.html +++ b/modules-available/serversetup-bwlp/templates/ipxe_update.html @@ -9,8 +9,10 @@ {{lang_usbBuilt}}
-
- {{lang_generationFailed}} +
+
+ {{lang_generationFailed}} +
{{lang_menuGeneration}}
-- cgit v1.2.3-55-g7522 From 84e147f238286c1dff78b5f9b5488167293f6d35 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 26 Sep 2018 14:50:32 +0200 Subject: [serversetup-bwlp] Don't allow recompilation if already in progress --- modules-available/serversetup-bwlp/page.inc.php | 56 +++++++++++++--------- .../serversetup-bwlp/templates/ipaddress.html | 4 +- .../serversetup-bwlp/templates/ipxe_update.html | 5 +- 3 files changed, 40 insertions(+), 25 deletions(-) (limited to 'modules-available/serversetup-bwlp/templates/ipxe_update.html') diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 6b1d20b6..4ebb7530 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -3,11 +3,26 @@ class Page_ServerSetup extends Page { - private $taskStatus; + private $addrListTask; + private $compileTask = null; private $currentAddress; private $currentMenu; private $hasIpSet = false; + private function getCompileTask() + { + if ($this->compileTask !== null) + return $this->compileTask; + $this->compileTask = Property::get('ipxe-task-id'); + if ($this->compileTask !== false) { + $this->compileTask = Taskmanager::status($this->compileTask); + if (!Taskmanager::isTask($this->compileTask) || Taskmanager::isFinished($this->compileTask)) { + $this->compileTask = false; + } + } + return $this->compileTask; + } + protected function doPreprocess() { User::load(); @@ -39,7 +54,9 @@ class Page_ServerSetup extends Page if ($action === 'compile') { User::assertPermission("edit.address"); - Trigger::ipxe(); + if ($this->getCompileTask() === false) { + Trigger::ipxe(); + } Util::redirect('?do=serversetup'); } @@ -100,13 +117,7 @@ class Page_ServerSetup extends Page { Render::addTemplate("heading"); - $task = Property::get('ipxe-task-id'); - if ($task !== false) { - $task = Taskmanager::status($task); - if (!Taskmanager::isTask($task) || Taskmanager::isFinished($task)) { - $task = false; - } - } + $task = $this->getCompileTask(); if ($task !== false) { Render::addTemplate('ipxe_update', array('taskid' => $task['id'])); } @@ -291,8 +302,9 @@ class Page_ServerSetup extends Page private function showEditAddress() { Render::addTemplate('ipaddress', array( - 'ips' => $this->taskStatus['data']['addresses'], + 'ips' => $this->addrListTask['data']['addresses'], 'chooseHintClass' => $this->hasIpSet ? '' : 'alert alert-danger', + 'disabled' => ($this->getCompileTask() === false) ? '' : 'disabled', )); } @@ -300,27 +312,27 @@ class Page_ServerSetup extends Page private function getLocalAddresses() { - $this->taskStatus = Taskmanager::submit('LocalAddressesList', array()); + $this->addrListTask = Taskmanager::submit('LocalAddressesList', array()); - if ($this->taskStatus === false) { - $this->taskStatus['data']['addresses'] = false; + if ($this->addrListTask === false) { + $this->addrListTask['data']['addresses'] = false; return false; } - if (!Taskmanager::isFinished($this->taskStatus)) { // TODO: Async if just displaying - $this->taskStatus = Taskmanager::waitComplete($this->taskStatus['id'], 4000); + if (!Taskmanager::isFinished($this->addrListTask)) { // TODO: Async if just displaying + $this->addrListTask = Taskmanager::waitComplete($this->addrListTask['id'], 4000); } - if (Taskmanager::isFailed($this->taskStatus) || !isset($this->taskStatus['data']['addresses'])) { - $this->taskStatus['data']['addresses'] = false; + if (Taskmanager::isFailed($this->addrListTask) || !isset($this->addrListTask['data']['addresses'])) { + $this->addrListTask['data']['addresses'] = false; return false; } $sortIp = array(); - foreach (array_keys($this->taskStatus['data']['addresses']) as $key) { - $item = & $this->taskStatus['data']['addresses'][$key]; + foreach (array_keys($this->addrListTask['data']['addresses']) as $key) { + $item = & $this->addrListTask['data']['addresses'][$key]; if (!isset($item['ip']) || !preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $item['ip']) || substr($item['ip'], 0, 4) === '127.') { - unset($this->taskStatus['data']['addresses'][$key]); + unset($this->addrListTask['data']['addresses'][$key]); continue; } if ($this->currentAddress === $item['ip']) { @@ -330,7 +342,7 @@ class Page_ServerSetup extends Page $sortIp[] = $item['ip']; } unset($item); - array_multisort($sortIp, SORT_STRING, $this->taskStatus['data']['addresses']); + array_multisort($sortIp, SORT_STRING, $this->addrListTask['data']['addresses']); return true; } @@ -483,7 +495,7 @@ class Page_ServerSetup extends Page { $newAddress = Request::post('ip', 'none', 'string'); $valid = false; - foreach ($this->taskStatus['data']['addresses'] as $item) { + foreach ($this->addrListTask['data']['addresses'] as $item) { if ($item['ip'] !== $newAddress) continue; $valid = true; diff --git a/modules-available/serversetup-bwlp/templates/ipaddress.html b/modules-available/serversetup-bwlp/templates/ipaddress.html index ef8cc914..ea19c417 100644 --- a/modules-available/serversetup-bwlp/templates/ipaddress.html +++ b/modules-available/serversetup-bwlp/templates/ipaddress.html @@ -20,7 +20,7 @@ {{/default}} {{^default}} - @@ -35,7 +35,7 @@
- diff --git a/modules-available/serversetup-bwlp/templates/ipxe_update.html b/modules-available/serversetup-bwlp/templates/ipxe_update.html index c5aafa1c..71611085 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe_update.html +++ b/modules-available/serversetup-bwlp/templates/ipxe_update.html @@ -14,7 +14,7 @@ {{lang_generationFailed}} -
{{lang_menuGeneration}}
+
{{lang_menuGeneration}}
@@ -27,6 +27,9 @@ if (task.data.pxeDone) $('#built-pxe').removeClass('invisible'); if (task.data.usbDone) $('#built-usb').removeClass('invisible'); } + if (task.statusCode === 'TASK_ERROR' || task.statusCode === 'TASK_FINISHED') { + $('#tm-compile-div').find('pre').hide(); + } if (task.statusCode === 'TASK_ERROR') { var $gf = $('#genfailed'); if (task.data && task.data.errors) { -- cgit v1.2.3-55-g7522 From 6812e85e11718116f097f493419c489c41660c77 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 21 Nov 2018 14:53:14 +0100 Subject: [serversetup-bwlp] Compilation front-end --- modules-available/serversetup-bwlp/page.inc.php | 8 ++++- .../serversetup-bwlp/templates/ipxe_update.html | 37 +++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) (limited to 'modules-available/serversetup-bwlp/templates/ipxe_update.html') diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 87c57dea..5f927173 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -124,7 +124,13 @@ class Page_ServerSetup extends Page $task = $this->getCompileTask(); if ($task !== false) { - Render::addTemplate('ipxe_update', array('taskid' => $task['id'])); + $files = []; + if ($task['data'] && $task['data']['files']) { + foreach ($task['data']['files'] as $k => $v) { + $files[] = ['name' => $k, 'namehyphen' => str_replace(['/', '.'], '-', $k)]; + } + } + Render::addTemplate('ipxe_update', array('taskid' => $task['id'], 'files' => $files)); } switch (Request::get('show')) { diff --git a/modules-available/serversetup-bwlp/templates/ipxe_update.html b/modules-available/serversetup-bwlp/templates/ipxe_update.html index 71611085..344d3905 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe_update.html +++ b/modules-available/serversetup-bwlp/templates/ipxe_update.html @@ -1,13 +1,13 @@
{{lang_menuGeneration}}
- -