summaryrefslogtreecommitdiffstats
path: root/modules-available/runmode
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/runmode')
-rw-r--r--modules-available/runmode/baseconfig/getconfig.inc.php3
-rw-r--r--modules-available/runmode/inc/runmode.inc.php38
-rw-r--r--modules-available/runmode/install.inc.php2
3 files changed, 34 insertions, 9 deletions
diff --git a/modules-available/runmode/baseconfig/getconfig.inc.php b/modules-available/runmode/baseconfig/getconfig.inc.php
index fe04b5ef..2d622fc7 100644
--- a/modules-available/runmode/baseconfig/getconfig.inc.php
+++ b/modules-available/runmode/baseconfig/getconfig.inc.php
@@ -14,9 +14,6 @@ $foofoo = function($machineUuid) {
if ($config->systemdDefaultTarget !== false) {
ConfigHolder::add('SLX_SYSTEMD_TARGET', $config->systemdDefaultTarget, 10000);
}
- if ($config->noSysconfig) {
- ConfigHolder::add('SLX_NO_CONFIG_TGZ', '1', 10000);
- }
// Disable exam mode - not sure if this is generally a good idea; for now, all modes we can think of would
// not make sense that way so do this for now
if (ConfigHolder::get('SLX_EXAM') !== false) {
diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php
index 0f4994f4..271542b8 100644
--- a/modules-available/runmode/inc/runmode.inc.php
+++ b/modules-available/runmode/inc/runmode.inc.php
@@ -63,8 +63,30 @@ class RunMode
}
/**
+ * @param string $machineuuid
+ * @param bool $detailed whether to return meta data about machine, not just machineuuid
+ * @param bool $assoc use machineuuid as array key
+ * @return false|array {'machineuuid', 'isclient', 'module', 'modeid', 'modedata',
+ * <'hostname', 'clientip', 'macaddr', 'locationid', 'lastseen'>}
+ */
+ public static function getRunMode($machineuuid, $detailed = false)
+ {
+ if ($detailed) {
+ $sel = ', m.hostname, m.clientip, m.macaddr, m.locationid, m.lastseen';
+ } else {
+ $sel = '';
+ }
+ return Database::queryFirst(
+ "SELECT m.machineuuid, r.isclient, r.module, r.modeid, r.modedata $sel
+ FROM machine m INNER JOIN runmode r USING (machineuuid)
+ WHERE m.machineuuid = :machineuuid LIMIT 1",
+ compact('machineuuid'));
+ }
+
+ /**
* @param string|\Module $module
- * @return array
+ * @param bool true = wrap in array where key is modeid
+ * @return array key=machineuuid, value={'machineuuid', 'modeid', 'modedata'}
*/
public static function getForModule($module, $groupByModeId = false)
{
@@ -91,15 +113,17 @@ class RunMode
* @param string|\Module $module
* @param string $modeId
* @param bool $detailed whether to return meta data about machine, not just machineuuid
- * @return array
+ * @param bool $assoc use machineuuid as array key
+ * @return array <key=machineuuid>, value={'machineuuid', 'modedata',
+ * <'hostname', 'clientip', 'macaddr', 'locationid', 'lastseen'>}
*/
- public static function getForMode($module, $modeId, $detailed = false)
+ public static function getForMode($module, $modeId, $detailed = false, $assoc = false)
{
if (is_object($module)) {
$module = $module->getIdentifier();
}
if ($detailed) {
- $sel = ', m.hostname, m.clientip, m.macaddr, m.locationid';
+ $sel = ', m.hostname, m.clientip, m.macaddr, m.locationid, m.lastseen';
$join = 'INNER JOIN machine m USING (machineuuid)';
} else {
$join = $sel = '';
@@ -114,7 +138,11 @@ class RunMode
if ($detailed && empty($row['hostname'])) {
$row['hostname'] = $row['clientip'];
}
- $ret[] = $row;
+ if ($assoc) {
+ $ret[$row['machineuuid']] = $row;
+ } else {
+ $ret[] = $row;
+ }
}
return $ret;
}
diff --git a/modules-available/runmode/install.inc.php b/modules-available/runmode/install.inc.php
index e2b1ed0f..ec710bfa 100644
--- a/modules-available/runmode/install.inc.php
+++ b/modules-available/runmode/install.inc.php
@@ -33,7 +33,7 @@ if (!tableHasColumn('runmode', 'isclient')) {
if ($ret === false) {
finalResponse(UPDATE_FAILED, 'Could not add lastchange field');
} elseif ($ret > 0) {
- $ret[] = UPDATE_DONE;
+ $res[] = UPDATE_DONE;
}
}