diff options
Diffstat (limited to 'modules-available')
8 files changed, 89 insertions, 133 deletions
diff --git a/modules-available/dnbd3/hooks/runmode/config.json b/modules-available/dnbd3/hooks/runmode/config.json index 683e0280..7d2fe3c9 100644 --- a/modules-available/dnbd3/hooks/runmode/config.json +++ b/modules-available/dnbd3/hooks/runmode/config.json @@ -1,7 +1,6 @@ { "isClient": false, "configHook": "Dnbd3Util::runmodeConfigHook", - "noSysconfig": true, "systemdDefaultTarget": "dnbd3-proxy", "allowGenericEditor": true, "deleteUrlSnippet": "dummyparam=", diff --git a/modules-available/locationinfo/hooks/runmode/config.json b/modules-available/locationinfo/hooks/runmode/config.json index 4bba0b5f..d94165ca 100644 --- a/modules-available/locationinfo/hooks/runmode/config.json +++ b/modules-available/locationinfo/hooks/runmode/config.json @@ -1,8 +1,7 @@ { - "getModeName": "LocationInfo::getPanelName", + "getModeName": "LocationInfoHooks::getPanelName", "isClient": false, - "configHook": "LocationInfo::configHook", - "noSysconfig": true, + "configHook": "LocationInfoHooks::configHook", "systemdDefaultTarget": "kiosk-mode", "permission": ".locationinfo.panel.assign-client" }
\ No newline at end of file diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index 23a20a94..d5fec3aa 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -126,49 +126,4 @@ class LocationInfo return array(); } - /** - * @param string $uuid panel uuid - * @return bool|string panel name if exists, false otherwise - */ - public static function getPanelName($uuid) - { - $ret = Database::queryFirst('SELECT panelname FROM locationinfo_panel WHERE paneluuid = :uuid', compact('uuid')); - if ($ret === false) return false; - return $ret['panelname']; - } - - /** - * Hook called by runmode module where we should modify the client config according to our - * needs. Disable standby/logout timeouts, enable autologin, set URL. - * @param $machineUuid - * @param $panelUuid - */ - public static function configHook($machineUuid, $panelUuid) - { - $type = InfoPanel::getConfig($panelUuid, $data); - if ($type === false) - return; // TODO: Invalid panel - what should we do? - if ($type === 'URL') { - // Check if we should set the insecure SSL mode (accept invalid/self signed certs etc.) - if ($data['insecure-ssl'] !== 0) { - ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); - } - if ($data['reload-minutes'] > 0) { - ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60); - } - ConfigHolder::add('SLX_BROWSER_URL', $data['url']); - ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']); - ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']); - } else { - // Not URL panel - ConfigHolder::add('SLX_BROWSER_URL', 'http://' . $_SERVER['SERVER_ADDR'] . '/panel/' . $panelUuid); - ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client - } - ConfigHolder::add('SLX_ADDONS', '', 1000); - ConfigHolder::add('SLX_LOGOUT_TIMEOUT', '', 1000); - ConfigHolder::add('SLX_SCREEN_STANDBY_TIMEOUT', '', 1000); - ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000); - ConfigHolder::add('SLX_AUTOLOGIN', '1', 1000); - } - } diff --git a/modules-available/locationinfo/inc/locationinfohooks.inc.php b/modules-available/locationinfo/inc/locationinfohooks.inc.php new file mode 100644 index 00000000..09489015 --- /dev/null +++ b/modules-available/locationinfo/inc/locationinfohooks.inc.php @@ -0,0 +1,53 @@ +<?php + +class LocationInfoHooks +{ + + /** + * @param string $uuid panel uuid + * @return bool|string panel name if exists, false otherwise + */ + public static function getPanelName($uuid) + { + $ret = Database::queryFirst('SELECT panelname FROM locationinfo_panel WHERE paneluuid = :uuid', compact('uuid')); + if ($ret === false) + return false; + return $ret['panelname']; + } + + /** + * Hook called by runmode module where we should modify the client config according to our + * needs. Disable standby/logout timeouts, enable autologin, set URL. + * + * @param $machineUuid + * @param $panelUuid + */ + public static function configHook($machineUuid, $panelUuid) + { + $type = InfoPanel::getConfig($panelUuid, $data); + if ($type === false) + return; // TODO: Invalid panel - what should we do? + if ($type === 'URL') { + // Check if we should set the insecure SSL mode (accept invalid/self signed certs etc.) + if ($data['insecure-ssl'] !== 0) { + ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); + } + if ($data['reload-minutes'] > 0) { + ConfigHolder::add('SLX_BROWSER_RELOAD_SECS', $data['reload-minutes'] * 60); + } + ConfigHolder::add('SLX_BROWSER_URL', $data['url']); + ConfigHolder::add('SLX_BROWSER_URLLIST', $data['urllist']); + ConfigHolder::add('SLX_BROWSER_IS_WHITELIST', $data['iswhitelist']); + } else { + // Not URL panel + ConfigHolder::add('SLX_BROWSER_URL', 'http://' . $_SERVER['SERVER_ADDR'] . '/panel/' . $panelUuid); + ConfigHolder::add('SLX_BROWSER_INSECURE', '1'); // TODO: Sat server might redirect to HTTPS, which in turn could have a self-signed cert - push to client + } + ConfigHolder::add('SLX_ADDONS', '', 1000); + ConfigHolder::add('SLX_LOGOUT_TIMEOUT', '', 1000); + ConfigHolder::add('SLX_SCREEN_STANDBY_TIMEOUT', '', 1000); + ConfigHolder::add('SLX_SYSTEM_STANDBY_TIMEOUT', '', 1000); + ConfigHolder::add('SLX_AUTOLOGIN', '1', 1000); + } + +}
\ No newline at end of file diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index 174fb675..96f532d7 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -272,10 +272,6 @@ class RunModeModuleConfig */ public $isClient = false; /** - * @var bool If true, config.tgz should not be downloaded by the client - */ - public $noSysconfig = false; - /** * @var bool Allow adding and removing machines to this mode via the generic form */ public $allowGenericEditor = true; @@ -300,7 +296,6 @@ class RunModeModuleConfig $this->loadType($data, 'getModeName', 'string'); $this->loadType($data, 'configHook', 'string'); $this->loadType($data, 'isClient', 'boolean'); - $this->loadType($data, 'noSysconfig', 'boolean'); $this->loadType($data, 'allowGenericEditor', 'boolean'); $this->loadType($data, 'deleteUrlSnippet', 'string'); $this->loadType($data, 'permission', 'string'); diff --git a/modules-available/sysconfig/api.inc.php b/modules-available/sysconfig/api.inc.php index 1319fc5f..983c6dcb 100644 --- a/modules-available/sysconfig/api.inc.php +++ b/modules-available/sysconfig/api.inc.php @@ -24,59 +24,48 @@ function deliverEmpty($message) die('Config file could not be found or read!'); } -$runmode = false; -if (Module::isAvailable('runmode')) { - $runmode = RunMode::getRunMode($uuid); - if ($runmode !== false) { - $runmode = RunMode::getModuleConfig($runmode['module']); +$locationId = false; +if (Module::isAvailable('locations')) { + $locationId = Location::getFromIpAndUuid($ip, $uuid); + if ($locationId !== false) { + $locationChain = Location::getLocationRootChain($locationId); + $locationChain[] = 0; } } -if ($runmode !== false && $runmode->noSysconfig && file_exists(SysConfig::GLOBAL_MINIMAL_CONFIG)) { - $row = array('filepath' => SysConfig::GLOBAL_MINIMAL_CONFIG, 'title' => 'config'); -} else { - $locationId = false; - if (Module::isAvailable('locations')) { - $locationId = Location::getFromIpAndUuid($ip, $uuid); - if ($locationId !== false) { - $locationChain = Location::getLocationRootChain($locationId); - $locationChain[] = 0; - } - } - if ($locationId === false) { - $locationId = 0; - $locationChain = array(0); - } +if ($locationId === false) { + $locationId = 0; + $locationChain = array(0); +} - // Get config module path +// Get config module path - // We get all the configs for the whole location chain up to root - $res = Database::simpleQuery("SELECT c.title, c.filepath, c.status, cl.locationid FROM configtgz c" - . " INNER JOIN configtgz_location cl USING (configid)" - . " WHERE cl.locationid IN (" . implode(',', $locationChain) . ")"); +// We get all the configs for the whole location chain up to root +$res = Database::simpleQuery("SELECT c.title, c.filepath, c.status, cl.locationid FROM configtgz c" + . " INNER JOIN configtgz_location cl USING (configid)" + . " WHERE cl.locationid IN (" . implode(',', $locationChain) . ")"); - $best = 1000; - $row = false; - while ($r = $res->fetch(PDO::FETCH_ASSOC)) { - settype($r['locationid'], 'int'); - $index = array_search($r['locationid'], $locationChain); - if ($index === false || $index > $best) - continue; - if (!file_exists($r['filepath'])) { - if ($r['locationid'] === 0) { - EventLog::failure("The global config.tgz '{$r['title']}' was not found at '{$r['filepath']}'. Please regenerate the system configuration"); - } else { - EventLog::warning("config.tgz '{$r['title']}' for location $locationId not found at '{$r['filepath']}', trying fallback...."); - } - continue; +$best = 1000; +$row = false; +while ($r = $res->fetch(PDO::FETCH_ASSOC)) { + settype($r['locationid'], 'int'); + $index = array_search($r['locationid'], $locationChain); + if ($index === false || $index > $best) + continue; + if (!file_exists($r['filepath'])) { + if ($r['locationid'] === 0) { + EventLog::failure("The global config.tgz '{$r['title']}' was not found at '{$r['filepath']}'. Please regenerate the system configuration"); + } else { + EventLog::warning("config.tgz '{$r['title']}' for location $locationId not found at '{$r['filepath']}', trying fallback...."); } - $best = $index; - $row = $r; + continue; } + $best = $index; + $row = $r; +} - if ($row === false) { - // TODO Not found in DB - deliverEmpty("No config.tgz for location $locationId found (src $ip)"); - } +if ($row === false) { + // TODO Not found in DB + deliverEmpty("No config.tgz for location $locationId found (src $ip)"); } @ob_end_clean(); // Disable gzip output handler since this is already a compressed file diff --git a/modules-available/sysconfig/inc/configtgz.inc.php b/modules-available/sysconfig/inc/configtgz.inc.php index 374cb5e0..cf9bf041 100644 --- a/modules-available/sysconfig/inc/configtgz.inc.php +++ b/modules-available/sysconfig/inc/configtgz.inc.php @@ -102,10 +102,6 @@ class ConfigTgz if (!empty($module['filepath']) && file_exists($module['filepath'])) { $files[] = $module['filepath']; } - if ($module['moduletype'] === 'SshConfig') { - // HACK XXX TODO Global + SSH ugly - self::rebuildEmptyGlobalConfig(); - } } $task = self::recompress($files, $this->file); @@ -233,34 +229,6 @@ class ConfigTgz $configTgz->generate(); } } - // Build the global "empty" config that just includes global hooks - self::rebuildEmptyGlobalConfig(); - } - - /** - * Rebuild the general "empty" config that only contains global hook modules - * and forced ones. - */ - private static function rebuildEmptyGlobalConfig() - { - static $onceOnly = false; - if ($onceOnly) - return; - $onceOnly = true; - // HACK TODO XXX -- just stuff (global) ssh config into this one for now, needs proper fix :-( - $res = Database::simpleQuery("SELECT DISTINCT cm.filepath FROM configtgz_module cm - INNER JOIN configtgz_x_module cxm USING (moduleid) - INNER JOIN configtgz_location cl USING (configid) - WHERE cm.moduletype = 'SshConfig' AND cm.status = 'OK' - ORDER BY locationid ASC"); - $extra = []; - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if (file_exists($row['filepath'])) { - $extra[] = $row['filepath']; - break; - } - } - self::recompress($extra, SysConfig::GLOBAL_MINIMAL_CONFIG); } /** diff --git a/modules-available/sysconfig/inc/sysconfig.inc.php b/modules-available/sysconfig/inc/sysconfig.inc.php index 13549948..15bd4104 100644 --- a/modules-available/sysconfig/inc/sysconfig.inc.php +++ b/modules-available/sysconfig/inc/sysconfig.inc.php @@ -3,8 +3,6 @@ class SysConfig { - const GLOBAL_MINIMAL_CONFIG = '/opt/openslx/configs/config-global.tgz'; - public static function getAll() { $res = Database::simpleQuery("SELECT c.configid, c.title, c.filepath, c.status, Group_Concat(cl.locationid) AS locs FROM configtgz c" |