From e4e79982dd3c447a4ced762a6069db553e246f59 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 28 May 2014 18:18:34 +0200 Subject: Fixed some bugs from Sateserver v05 --- apis/update.inc.php | 58 ++++++++++++++++++++++++ inc/database.inc.php | 34 ++++++++++----- inc/message.inc.php | 2 + inc/property.inc.php | 57 +++++++++++++----------- inc/trigger.inc.php | 4 +- modules/minilinux.inc.php | 68 +---------------------------- modules/serversetup.inc.php | 21 +++++---- modules/sysconfig.inc.php | 49 +++++++++++++++++++-- modules/sysconfig/addconfig.inc.php | 32 ++++---------- modules/sysconfig/addmodule.inc.php | 23 ++-------- modules/sysconfig/addmodule_ad.inc.php | 9 ++-- modules/sysconfig/addmodule_custom.inc.php | 4 +- modules/vmstore.inc.php | 7 +-- script/taskmanager.js | 10 ++--- templates/main-menu.html | 4 +- templates/minilinux/filelist.html | 2 +- templates/page-sysconfig-main.html | 7 ++- templates/sysconfig/ad-checkconnection.html | 2 + templates/sysconfig/cfg-start.html | 3 ++ updates/v2 | 43 ------------------ 20 files changed, 216 insertions(+), 223 deletions(-) create mode 100644 apis/update.inc.php delete mode 100644 updates/v2 diff --git a/apis/update.inc.php b/apis/update.inc.php new file mode 100644 index 00000000..4ec94882 --- /dev/null +++ b/apis/update.inc.php @@ -0,0 +1,58 @@ += $targetVersion) + die('Up to date :-)'); + +$function = 'update_' . $currentVersion; + +if (!function_exists($function)) + die("Don't know how to update from version $currentVersion to $targetVersion :-("); + +if (!$function()) + die("Update from $currentVersion to $targetVersion failed! :-("); + +$currentVersion++; + +$ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version)", array('version' => $currentVersion), true); +if ($ret === false) + die('Writing version information back to DB failed. Next update will probably break.'); + +if ($currentVersion < $targetVersion) { + Header('Location: api.php?do=update&random=' . mt_rand()); + die("Updated to $currentVersion - press F5 to continue"); +} + +die("Updated to $currentVersion"); + +// ####################### + +// ##### 2014-05-28 +// Add dateline field to property table + +function update_1() +{ + $res = Database::simpleQuery("DESCRIBE property", array(), false); + $type = false; + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + if ($row['Field'] !== 'dateline') continue; + $type = $row['Type']; + break; + } + if ($type === false) { + Database::exec("ALTER TABLE `property` ADD `dateline` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `name` , ADD INDEX ( `dateline` )"); + } else { + Database::exec("ALTER TABLE `property` CHANGE `dateline` `dateline` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'"); + } + return true; +} + + +// ################ \ No newline at end of file diff --git a/inc/database.inc.php b/inc/database.inc.php index a646e823..e7a16ba1 100644 --- a/inc/database.inc.php +++ b/inc/database.inc.php @@ -6,6 +6,7 @@ */ class Database { + private static $dbh = false; private static $statements = array(); @@ -14,7 +15,8 @@ class Database */ private static function init() { - if (self::$dbh !== false) return; + if (self::$dbh !== false) + return; try { self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); } catch (PDOException $e) { @@ -26,24 +28,31 @@ class Database * If you just need the first row of a query you can use this. * Will return an associative array, or false if no row matches the query */ - public static function queryFirst($query, $args = array()) + public static function queryFirst($query, $args = array(), $ignoreError = false) { - $res = self::simpleQuery($query, $args); - if ($res === false) return false; + $res = self::simpleQuery($query, $args, $ignoreError); + if ($res === false) + return false; return $res->fetch(PDO::FETCH_ASSOC); } + /** * Execute the given query and return the number of rows affected. * Mostly useful for UPDATEs or INSERTs + * + * @param string $query Query to run + * @param array $args Arguments to query + * @return int|boolean Number of rows affected, or false on error */ - public static function exec($query, $args = array()) + public static function exec($query, $args = array(), $ignoreError = false) { - $res = self::simpleQuery($query, $args); - if ($res === false) return false; + $res = self::simpleQuery($query, $args, $ignoreError); + if ($res === false) + return false; return $res->rowCount(); } - + /** * Get id (promary key) of last row inserted. * @@ -61,7 +70,7 @@ class Database * still being valid. If you need to do something fancy, use Database::prepare * @return \PDOStatement The query result object */ - public static function simpleQuery($query, $args = array()) + public static function simpleQuery($query, $args = array(), $ignoreError = false) { self::init(); try { @@ -71,11 +80,15 @@ class Database self::$statements[$query]->closeCursor(); } if (self::$statements[$query]->execute($args) === false) { + if ($ignoreError) + return false; Util::traceError("Database Error: \n" . implode("\n", self::$statements[$query]->errorInfo())); } return self::$statements[$query]; } catch (Exception $e) { - return false; + if ($ignoreError) + return false; + Util::traceError("Database Error: \n" . $e->getMessage()); } } @@ -90,4 +103,3 @@ class Database } } - diff --git a/inc/message.inc.php b/inc/message.inc.php index 75292e09..b62f234f 100644 --- a/inc/message.inc.php +++ b/inc/message.inc.php @@ -93,6 +93,7 @@ class Message public static function renderList() { global $error_text; + if (!self::$flushed) Render::openTag('div', array('class' => 'container')); foreach (self::$list as $item) { $message = $error_text[$item['id']]; foreach ($item['params'] as $index => $text) { @@ -101,6 +102,7 @@ class Message Render::addTemplate('messagebox-' . $item['type'], array('message' => $message)); self::$alreadyDisplayed[] = $item; } + if (!self::$flushed) Render::closeTag('div'); self::$list = array(); self::$flushed = true; } diff --git a/inc/property.inc.php b/inc/property.inc.php index 5c316517..77d2b985 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -6,8 +6,9 @@ */ class Property { + private static $cache = false; - + /** * Retrieve value from property store. * @@ -18,90 +19,96 @@ class Property private static function get($key, $default = false) { if (self::$cache === false) { + if (mt_rand(1, 20) === 10) { + Database::exec("DELETE FROM property WHERE dateline <> 0 AND dateline < UNIX_TIMESTAMP()"); + } $res = Database::simpleQuery("SELECT name, value FROM property"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { self::$cache[$row['name']] = $row['value']; } } - if (!isset(self::$cache[$key])) return $default; + if (!isset(self::$cache[$key])) + return $default; return self::$cache[$key]; } - + /** * Set value in property store. * * @param string $key key of value to set * @param type $value the value to store for $key + * @param int minage how long to keep this entry around at least, in minutes. 0 for infinite */ - private static function set($key, $value) + private static function set($key, $value, $minage = 0) { - Database::exec("INSERT INTO property (name, value) VALUES (:key, :value)" - . " ON DUPLICATE KEY UPDATE value = VALUES(value)", array( - 'key' => $key, - 'value' => $value - )); + Database::exec("INSERT INTO property (name, value, dateline) VALUES (:key, :value, :dateline)" + . " ON DUPLICATE KEY UPDATE value = VALUES(value), dateline = VALUES(dateline)", array( + 'key' => $key, + 'value' => $value, + 'dateline' => time() + ($minage * 60) + )); if (self::$cache !== false) { self::$cache[$key] = $value; } } - + public static function getServerIp() { return self::get('server-ip', 'none'); } - + public static function setServerIp($value) { self::set('server-ip', $value); } - + public static function getIPxeIp() { - return self::get('ipxe-ip', 'none'); + return self::get('ipxe-ip', 'not-set'); } - + public static function setIPxeIp($value) { self::set('ipxe-ip', $value); } - + public static function getIPxeTaskId() { return self::get('ipxe-task'); } - + public static function setIPxeTaskId($value) { self::set('ipxe-task', $value); } - + public static function getBootMenu() { return json_decode(self::get('ipxe-menu'), true); } - + public static function setBootMenu($value) { self::set('ipxe-menu', json_encode($value)); } - + public static function getVersionCheckTaskId() { return self::get('versioncheck-task'); } - + public static function setVersionCheckTaskId($value) { self::set('versioncheck-task', $value); } - + public static function getVersionCheckInformation() { $data = json_decode(self::get('versioncheck-data'), true); if (isset($data['time']) && $data['time'] + 120 > time()) return $data; $task = Taskmanager::submit('DownloadText', array( - 'url' => CONFIG_REMOTE_ML . '/list.php' + 'url' => CONFIG_REMOTE_ML . '/list.php' )); if (!isset($task['id'])) return false; @@ -116,17 +123,17 @@ class Property self::setVersionCheckInformation($data); return $data; } - + public static function setVersionCheckInformation($value) { self::set('versioncheck-data', json_encode($value)); } - + public static function getVmStoreConfig() { return json_decode(self::get('vmstore-config'), true); } - + public static function setVmStoreConfig($value) { self::set('vmstore-config', json_encode($value)); diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 102f7987..b7cc67cc 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -39,7 +39,7 @@ class Trigger public static function ldadp() { - $res = Database::simpleQuery("SELECT moduleid, filepath FROM configtgz_module" + $res = Database::simpleQuery("SELECT moduleid, configtgz.filepath FROM configtgz_module" . " INNER JOIN configtgz_x_module USING (moduleid)" . " INNER JOIN configtgz USING (configid)" . " WHERE moduletype = 'AD_AUTH'"); @@ -65,7 +65,7 @@ class Trigger if (!is_array($vmstore)) return; $storetype = $vmstore['storetype']; if ($storetype === 'nfs') $addr = $vmstore['nfsaddr']; - if ($storetype === 'cifs') $addr = $vmstore['nfsaddr']; + if ($storetype === 'cifs') $addr = $vmstore['cifsaddr']; if ($storetype === 'internal') $addr = 'none'; $this->mountTask = Taskmanager::submit('MountVmStore', array( 'address' => $addr, diff --git a/modules/minilinux.inc.php b/modules/minilinux.inc.php index e2d85247..f3fb6dce 100644 --- a/modules/minilinux.inc.php +++ b/modules/minilinux.inc.php @@ -37,7 +37,7 @@ class Page_MiniLinux extends Page foreach ($system['files'] as &$file) { $file['uid'] = 'dlid' . $count++; $local = CONFIG_HTTP_DIR . '/' . $system['id'] . '/' . $file['name']; - if (!file_exists($local) || md5_file($local) !== substr($file['md5'], 0, 32)) { + if (!file_exists($local) || filesize($local) !== $file['size'] || md5_file($local) !== substr($file['md5'], 0, 32)) { $file['changed'] = true; } } @@ -83,70 +83,4 @@ class Page_MiniLinux extends Page } } - private function checkFile(&$files, $name) - { - static $someId = 0; - $remote = CONFIG_REMOTE_ML . "/${name}.md5"; - $localTarget = CONFIG_HTTP_DIR . "/default/${name}"; - $local = "${localTarget}.md5"; - $localLock = "${localTarget}.lck"; - - // Maybe already in progress? - if (file_exists($localLock)) { - $data = explode(' ', file_get_contents($localLock)); - if (count($data) == 2) { - $pid = (int)$data[0]; - if (posix_kill($pid, 0)) { - $files[] = array( - 'file' => $name, - 'id' => 'id' . $someId++, - 'pid' => $pid, - 'progress' => $data[1] - ); - return true; - } else { - unlink($localLock); - } - } else { - unlink($localLock); - } - } - - // Not in progress, normal display - if (!file_exists($local) || filemtime($local) + 300 < time()) { - if (file_exists($localTarget)) { - $existingMd5 = md5_file($localTarget); - } else { - $existingMd5 = ''; - } - if (file_put_contents($local, $existingMd5) === false) { - @unlink($local); - Message::addWarning('error-write', $local); - } - } else { - $existingMd5 = file_get_contents($local); - } - $existingMd5 = strtolower(preg_replace('/[^0-9a-f]/is', '', $existingMd5)); - $remoteMd5 = Util::download($remote, 3, $code); - $remoteMd5 = strtolower(preg_replace('/[^0-9a-f]/is', '', $remoteMd5)); - if ($code != 200) { - Message::addError('remote-timeout', $remote, $code); - return false; - } - if ($existingMd5 === $remoteMd5) { - // Up to date - $files[] = array( - 'file' => $name, - 'id' => 'id' . $someId++, - ); - return true; - } - // New version on server - $files[] = array( - 'file' => $name, - 'id' => 'id' . $someId++, - 'update' => true - ); - return true; - } } diff --git a/modules/serversetup.inc.php b/modules/serversetup.inc.php index 3e98b4ad..73a1a8fc 100644 --- a/modules/serversetup.inc.php +++ b/modules/serversetup.inc.php @@ -15,7 +15,7 @@ class Page_ServerSetup extends Page Message::addError('no-permission'); Util::redirect('?do=Main'); } - + $this->currentMenu = Property::getBootMenu(); $action = Request::post('action'); @@ -30,7 +30,7 @@ class Page_ServerSetup extends Page $this->getLocalAddresses(); $this->updateLocalAddress(); } - + if ($action === 'ipxe') { // iPXE stuff changes $this->updatePxeMenu(); @@ -40,7 +40,7 @@ class Page_ServerSetup extends Page protected function doRender() { Render::setTitle('Serverseitige Konfiguration'); - + Render::addTemplate('serversetup/ipaddress', array( 'ips' => $this->taskStatus['data']['addresses'], 'token' => Session::get('token') @@ -48,12 +48,15 @@ class Page_ServerSetup extends Page $data = $this->currentMenu; $data['token'] = Session::get('token'); $data['taskid'] = Property::getIPxeTaskId(); - if ($data['defaultentry'] === 'net') $data['active-net'] = 'checked'; - if ($data['defaultentry'] === 'hdd') $data['active-hdd'] = 'checked'; - if ($data['defaultentry'] === 'custom') $data['active-custom'] = 'checked'; + if ($data['defaultentry'] === 'net') + $data['active-net'] = 'checked'; + if ($data['defaultentry'] === 'hdd') + $data['active-hdd'] = 'checked'; + if ($data['defaultentry'] === 'custom') + $data['active-custom'] = 'checked'; Render::addTemplate('serversetup/ipxe', $data); } - + // ----------------------------------------------------------------------------------------------- private function getLocalAddresses() @@ -104,10 +107,12 @@ class Page_ServerSetup extends Page } Util::redirect(); } - + private function updatePxeMenu() { $timeout = Request::post('timeout', 10); + if ($timeout === '') + $timeout = 10; if (!is_numeric($timeout)) { Message::addError('value-invalid', 'timeout', $timeout); } diff --git a/modules/sysconfig.inc.php b/modules/sysconfig.inc.php index 06ceb618..5fc0114c 100644 --- a/modules/sysconfig.inc.php +++ b/modules/sysconfig.inc.php @@ -2,6 +2,45 @@ class Page_SysConfig extends Page { + + /** + * Holds all the known configuration modules, with title, description, start class for their wizard, etc. + * @var array + */ + protected static $moduleTypes = array(); + + /** + * Add a known configuration module. Every addmoule_* file should call this + * for its module provided. + * + * @param string $id Internal identifier for the module + * @param string $startClass Class to start wizard for creating such a module + * @param string $title Title of this module type + * @param string $description Description for this module type + * @param string $group Title for group this module type belongs to + * @param bool $unique Can only one such module be added to a config? + * @param int $sortOrder Lower comes first, alphabetical ordering otherwiese + */ + public static function addModule($id, $startClass, $title, $description, $group, $unique, $sortOrder = 0) + { + self::$moduleTypes[$id] = array( + 'startClass' => $startClass, + 'title' => $title, + 'description' => $description, + 'group' => $group, + 'unique' => $unique, + 'sortOrder' => $sortOrder + ); + } + + /** + * + * @return array All registered module types + */ + public static function getModuleTypes() + { + return self::$moduleTypes; + } protected function doPreprocess() { @@ -13,6 +52,12 @@ class Page_SysConfig extends Page } $action = Request::any('action', 'list'); + + // Load all addmodule classes, as they populate the $moduleTypes array + require_once 'modules/sysconfig/addmodule.inc.php'; + foreach (glob('modules/sysconfig/addmodule_*.inc.php') as $file) { + require_once $file; + } // Action: "addmodule" (upload new module) if ($action === 'addmodule') { @@ -181,10 +226,6 @@ class Page_SysConfig extends Page { $step = Request::any('step', 0); if ($step === 0) $step = 'AddModule_Start'; - require_once 'modules/sysconfig/addmodule.inc.php'; - foreach (glob('modules/sysconfig/addmodule_*.inc.php') as $file) { - require_once $file; - } AddModule_Base::setStep($step); } diff --git a/modules/sysconfig/addconfig.inc.php b/modules/sysconfig/addconfig.inc.php index 6f076a12..96c29fea 100644 --- a/modules/sysconfig/addconfig.inc.php +++ b/modules/sysconfig/addconfig.inc.php @@ -7,21 +7,6 @@ abstract class AddConfig_Base { - /** - * - * @var array Known module types - */ - protected static $types = array( - 'AD_AUTH' => array( - 'unique' => true, - 'group' => 'Authentifizierung' - ), - 'custom' => array( - 'unique' => false, - 'group' => 'Generisch' - ) - ); - /** * Holds the instance for the currently executing step * @var \AddConfig_Base @@ -123,26 +108,27 @@ class AddConfig_Start extends AddConfig_Base protected function renderInternal() { + $mods = Page_SysConfig::getModuleTypes(); $res = Database::simpleQuery("SELECT moduleid, title, moduletype, filepath FROM configtgz_module" . " ORDER BY title ASC"); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if (!isset(self::$types[$row['moduletype']])) { - self::$types[$row['moduletype']] = array( + if (!isset($mods[$row['moduletype']])) { + $mods[$row['moduletype']] = array( 'unique' => false, 'group' => 'Undefined moduletype in addconfig.inc.php' ); } - if (!isset(self::$types[$row['moduletype']]['modules'])) { - self::$types[$row['moduletype']]['modules'] = array(); - self::$types[$row['moduletype']]['groupid'] = $row['moduletype']; + if (!isset($mods[$row['moduletype']]['modules'])) { + $mods[$row['moduletype']]['modules'] = array(); + $mods[$row['moduletype']]['groupid'] = $row['moduletype']; } if (empty($row['filepath']) || !file_exists($row['filepath'])) $row['missing'] = true; - self::$types[$row['moduletype']]['modules'][] = $row; + $mods[$row['moduletype']]['modules'][] = $row; } Render::addDialog('Konfiguration zusammenstellen', false, 'sysconfig/cfg-start', array( 'token' => Session::get('token'), 'step' => 'AddConfig_Finish', - 'groups' => array_values(self::$types) + 'groups' => array_values($mods) )); } @@ -195,7 +181,7 @@ class AddConfig_Finish extends AddConfig_Base protected function renderInternal() { - if (isset($this->task['statusCode']) && $this->task['statusCode'] === TASK_WAITING) { + if (isset($this->task['statusCode']) && ($this->task['statusCode'] === TASK_WAITING || $this->task['statusCode'] === TASK_PROCESSING)) { $this->task = Taskmanager::waitComplete($this->task['id']); } if ($this->task === false) $this->tmError(); diff --git a/modules/sysconfig/addmodule.inc.php b/modules/sysconfig/addmodule.inc.php index 883c196f..5af43c20 100644 --- a/modules/sysconfig/addmodule.inc.php +++ b/modules/sysconfig/addmodule.inc.php @@ -7,28 +7,12 @@ abstract class AddModule_Base { - /** - * Holds all the known configuration modules, with title, description, start class for their wizard, etc. - * @var array - */ - protected static $moduleTypes = array(); - /** * Holds the instance for the currently executing step * @var \AddModule_Base */ private static $instance = false; - public static function addModule($id, $startClass, $title, $description, $sortOrder = 0) - { - self::$moduleTypes[] = array( - 'startClass' => $startClass, - 'title' => $title, - 'description' => $description, - 'sortOrder' => $sortOrder - ); - } - /** * * @param type $step @@ -125,12 +109,13 @@ class AddModule_Start extends AddModule_Base protected function renderInternal() { $title = $order = array(); - foreach (AddModule_Base::$moduleTypes as $module) { + $mods = Page_SysConfig::getModuleTypes(); + foreach ($mods as $module) { $title[] = $module['title']; $order[] = $module['sortOrder']; } - array_multisort($order, SORT_ASC, $title, SORT_ASC, self::$moduleTypes); - Render::addDialog('Modul hinzufügen', false, 'sysconfig/start', array('modules' => self::$moduleTypes)); + array_multisort($order, SORT_ASC, $title, SORT_ASC, $mods); + Render::addDialog('Modul hinzufügen', false, 'sysconfig/start', array('modules' => array_values($mods))); } } diff --git a/modules/sysconfig/addmodule_ad.inc.php b/modules/sysconfig/addmodule_ad.inc.php index 459d7f2c..d533a2b8 100644 --- a/modules/sysconfig/addmodule_ad.inc.php +++ b/modules/sysconfig/addmodule_ad.inc.php @@ -4,9 +4,10 @@ * Wizard for setting up active directory integration for authentication. */ -AddModule_Base::addModule('active_directory', 'AdModule_Start', 'Active Directory Authentifizierung', +Page_SysConfig::addModule('AD_AUTH', 'AdModule_Start', 'Active Directory Authentifizierung', 'Mit diesem Modul ist die Anmeldung an den Client PCs mit den Benutzerkonten eines Active Directory' - . ' möglich. Je nach Konfiguration ist auch die Nutzung eines Benutzerverzeichnisses auf dem Client möglich.' + . ' möglich. Je nach Konfiguration ist auch die Nutzung eines Benutzerverzeichnisses auf dem Client möglich.', + 'Authentifizierung', true ); class AdModule_Start extends AddModule_Base @@ -88,8 +89,8 @@ class AdModule_Finish extends AddModule_Base Request::post('server'), Request::post('searchbase'), Request::post('binddn'), - Request::post('bindpw'), - Request::post('home') + Request::post('bindpw', ''), + Request::post('home', '') ); $config['proxyip'] = Property::getServerIp(); $tgz = Taskmanager::submit('CreateAdConfig', $config); diff --git a/modules/sysconfig/addmodule_custom.inc.php b/modules/sysconfig/addmodule_custom.inc.php index 070c1fd4..e5def1ef 100644 --- a/modules/sysconfig/addmodule_custom.inc.php +++ b/modules/sysconfig/addmodule_custom.inc.php @@ -6,12 +6,12 @@ * fancy is happening. */ -AddModule_Base::addModule('custom', 'CustomModule_UploadForm', 'Erweitertes Modul', +Page_SysConfig::addModule('custom', 'CustomModule_UploadForm', 'Erweitertes Modul', 'Mit einem Erweiterten Modul ist es möglich, beliebige Dateien zum Grundsystem hinzuzufügen.' . ' Nutzen Sie dieses Modul, um z.B. spezielle Konfigurationsdateien auf den Client PCs zu' . ' verwenden, die sich nicht mit einem der anderen Wizards erstellen lässt.' . ' Das Hinzufügen eines Erweiterten Moduls erfordert in der Regel zumindest grundlegende' - . ' Systemkenntnisse im Linuxbereich.', 100 + . ' Systemkenntnisse im Linuxbereich.', 'Generisch', false, 100 ); class CustomModule_UploadForm extends AddModule_Base diff --git a/modules/vmstore.inc.php b/modules/vmstore.inc.php index ab06b1af..a8f2ec48 100644 --- a/modules/vmstore.inc.php +++ b/modules/vmstore.inc.php @@ -60,13 +60,8 @@ class Page_VmStore extends Page if ($storetype === 'nfs') $addr = $vmstore['nfsaddr']; if ($storetype === 'cifs') $addr = $vmstore['nfsaddr']; if ($storetype === 'internal') $addr = 'none'; - $this->mountTask = Taskmanager::submit('MountVmStore', array( - 'address' => $addr, - 'type' => 'images', - 'username' => $vmstore['cifsuser'], - 'password' => $vmstore['cifspasswd'] - )); Property::setVmStoreConfig($vmstore); + $this->mountTask = Trigger::mount(); } } \ No newline at end of file diff --git a/script/taskmanager.js b/script/taskmanager.js index a34b3aa4..822d1421 100644 --- a/script/taskmanager.js +++ b/script/taskmanager.js @@ -10,7 +10,8 @@ function tmInit() return; tmItems.each(function(i, item) { item = $(item); - if (item.find('.data-tm-icon').length !== 0) return; + if (item.find('.data-tm-icon').length !== 0) + return; if (item.is('[data-tm-progress]')) { item.append('
'); } @@ -38,17 +39,16 @@ function tmUpdate() return; $.post('api.php?do=taskmanager', {'ids[]': active, token: TOKEN}, function(data, status) { // POST success - tmIsRunning = tmResult(data, status) + tmIsRunning = tmResult(data, status); if (tmIsRunning) { setTimeout(tmUpdate, 1000); } }, 'json').fail(function(jqXHR, textStatus, errorThrown) { // POST failure console.log("TaskManager Error: " + textStatus + " - " + errorThrown); - if (++tmErrors < TM_MAX_ERRORS) + tmIsRunning = (++tmErrors < TM_MAX_ERRORS); + if (tmIsRunning) setTimeout(tmUpdate, 2000); - else - tmIsRunning = false; }); } diff --git a/templates/main-menu.html b/templates/main-menu.html index 24ee2238..a419857c 100644 --- a/templates/main-menu.html +++ b/templates/main-menu.html @@ -17,9 +17,9 @@ Einstellungen