diff options
author | Simon Rettberg | 2014-05-28 18:18:34 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-05-28 18:18:34 +0200 |
commit | e4e79982dd3c447a4ced762a6069db553e246f59 (patch) | |
tree | d17f74565ed5347350edeab412a07c77bd80a636 /modules | |
parent | WIP (diff) | |
download | slx-admin-e4e79982dd3c447a4ced762a6069db553e246f59.tar.gz slx-admin-e4e79982dd3c447a4ced762a6069db553e246f59.tar.xz slx-admin-e4e79982dd3c447a4ced762a6069db553e246f59.zip |
Fixed some bugs from Sateserver v05
Diffstat (limited to 'modules')
-rw-r--r-- | modules/minilinux.inc.php | 68 | ||||
-rw-r--r-- | modules/serversetup.inc.php | 21 | ||||
-rw-r--r-- | modules/sysconfig.inc.php | 49 | ||||
-rw-r--r-- | modules/sysconfig/addconfig.inc.php | 32 | ||||
-rw-r--r-- | modules/sysconfig/addmodule.inc.php | 23 | ||||
-rw-r--r-- | modules/sysconfig/addmodule_ad.inc.php | 9 | ||||
-rw-r--r-- | modules/sysconfig/addmodule_custom.inc.php | 4 | ||||
-rw-r--r-- | modules/vmstore.inc.php | 7 |
8 files changed, 80 insertions, 133 deletions
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 = '<missing>'; - } - 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 @@ -8,21 +8,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 @@ -8,27 +8,11 @@ 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 |