diff options
author | Simon Rettberg | 2019-11-12 11:31:46 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-11-12 11:31:46 +0100 |
commit | dd48d827a1bffe3825ecc2a34bedb7a641d92613 (patch) | |
tree | eabab6cd99a9973b2db947b29c3529ca42958fd0 /modules-available/sysconfig | |
parent | [statistics] FIX STUFF (diff) | |
download | slx-admin-dd48d827a1bffe3825ecc2a34bedb7a641d92613.tar.gz slx-admin-dd48d827a1bffe3825ecc2a34bedb7a641d92613.tar.xz slx-admin-dd48d827a1bffe3825ecc2a34bedb7a641d92613.zip |
[sysconfig/runmode] Remove "noSysconfig" functionality
Was of limited use and not properly implemented anyways.
Diffstat (limited to 'modules-available/sysconfig')
-rw-r--r-- | modules-available/sysconfig/api.inc.php | 79 | ||||
-rw-r--r-- | modules-available/sysconfig/inc/configtgz.inc.php | 32 | ||||
-rw-r--r-- | modules-available/sysconfig/inc/sysconfig.inc.php | 2 |
3 files changed, 34 insertions, 79 deletions
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" |