summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig/api.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-03 17:53:13 +0100
committerSimon Rettberg2017-11-03 17:53:13 +0100
commit764ec440d8594c68a6c778f58aee2d7888b89204 (patch)
treee4db86bb1ef7fad95a4d12c57d1d35e36d888333 /modules-available/sysconfig/api.inc.php
parent[sysconfig] Fix: Empty config.tgz modules disappeared from the list (diff)
downloadslx-admin-764ec440d8594c68a6c778f58aee2d7888b89204.tar.gz
slx-admin-764ec440d8594c68a6c778f58aee2d7888b89204.tar.xz
slx-admin-764ec440d8594c68a6c778f58aee2d7888b89204.zip
[sysconfig/runmode] Deliver bare config.tgz with just global hook data when "no sysconfig" is set for a runmode
Diffstat (limited to 'modules-available/sysconfig/api.inc.php')
-rw-r--r--modules-available/sysconfig/api.inc.php85
1 files changed, 49 insertions, 36 deletions
diff --git a/modules-available/sysconfig/api.inc.php b/modules-available/sysconfig/api.inc.php
index d6cdc0e6..897b44a7 100644
--- a/modules-available/sysconfig/api.inc.php
+++ b/modules-available/sysconfig/api.inc.php
@@ -9,18 +9,6 @@ $uuid = Request::any('uuid', false, 'string');
if ($uuid !== false && strlen($uuid) !== 36) {
$uuid = false;
}
-$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);
-}
// What we do if we can't supply the requested config
function deliverEmpty($message)
@@ -30,34 +18,59 @@ function deliverEmpty($message)
die('Config file could not be found or read!');
}
-// Get config module path
+$runmode = false;
+if (Module::isAvailable('runmode')) {
+ $runmode = RunMode::getRunMode($uuid);
+ if ($runmode !== false) {
+ $runmode = RunMode::getModuleConfig($runmode['module']);
+ }
+}
+if ($runmode !== false && $runmode->noSysconfig && file_exists(SysConfig::GLOBAL_MINIMAL_CONFIG)) {
+ $row = array('filepath' => SysConfig::GLOBAL_MINIMAL_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);
+ }
+
+ // 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) . ")");
-$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....");
+ // 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;
}
- continue;
+ $best = $index;
+ $row = $r;
}
- $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)");
+ }
}
Header('Content-Type: application/gzip');