summaryrefslogtreecommitdiffstats
path: root/modules-available/sysconfig/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/sysconfig/install.inc.php')
-rw-r--r--modules-available/sysconfig/install.inc.php35
1 files changed, 19 insertions, 16 deletions
diff --git a/modules-available/sysconfig/install.inc.php b/modules-available/sysconfig/install.inc.php
index 3f80ffe6..53882882 100644
--- a/modules-available/sysconfig/install.inc.php
+++ b/modules-available/sysconfig/install.inc.php
@@ -87,7 +87,7 @@ if (!tableHasColumn('configtgz_module', 'dateline')) {
$update[] = UPDATE_DONE;
// Infer from module's filemtime
$res = Database::simpleQuery('SELECT moduleid, filepath FROM configtgz_module');
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
Database::exec('UPDATE configtgz_module SET dateline = :mtime WHERE moduleid = :moduleid',
['moduleid' => $row['moduleid'], 'mtime' => filemtime($row['filepath'])]);
}
@@ -102,7 +102,7 @@ if (!tableHasColumn('configtgz', 'dateline')) {
INNER JOIN configtgz_x_module cxm USING (configid)
INNER JOIN configtgz_module m USING (moduleid)
GROUP BY configid');
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
Database::exec('UPDATE configtgz SET dateline = :mtime WHERE configid = :configid',
['configid' => $row['configid'], 'mtime' => $row['dateline']]);
}
@@ -125,28 +125,28 @@ Module::isAvailable('sysconfig');
$list = ConfigModule::getAll();
$parentTask = null;
$configList = [];
-if ($list === false) {
+if ($list === null) {
EventLog::warning('Could not regenerate configs - please do so manually');
} else {
- foreach ($list as $ad) {
- if ($ad->moduleType() === 'SshConfig') {
+ foreach ($list as $confMod) {
+ if ($confMod->moduleType() === 'SshConfig') {
// 2020-11-12: Split SshConfig into SshConfig and SshKey
- $pubkey = $ad->getData('publicKey');
- if ($pubkey !== false && !empty($pubkey)) {
- error_log('Legacy module with pubkey ' . $ad->id());
- $key = ConfigModule::getInstance('SshKey');
- if ($key !== false) {
+ $pubkey = $confMod->getData('publicKey');
+ if (!empty($pubkey)) {
+ error_log('Legacy module with pubkey ' . $confMod->id());
+ $key = ConfigModule::getInstanceOrNull('SshKey');
+ if ($key !== null) {
$key->setData('publicKey', $pubkey);
- if ($key->insert($ad->title())) {
+ if ($key->insert($confMod->title())) {
// Insert worked, remove key from old module, add this module to the same configs
$task = $key->generate(false, $parentTask);
if ($task !== false) {
$parentTask = $task;
}
error_log('Inserted new module with id ' . $key->id());
- $ad->setData('publicKey', false);
- $ad->update();
- $configs = ConfigTgz::getAllForModule($ad->id());
+ $confMod->setData('publicKey', false);
+ $confMod->update();
+ $configs = ConfigTgz::getAllForModule($confMod->id());
foreach ($configs as $config) {
// Add newly created key-only module to all configs
$new = array_merge($config->getModuleIds(), [$key->id()]);
@@ -158,9 +158,9 @@ if ($list === false) {
}
}
}
- if ($ad->needRebuild()) {
+ if ($confMod->needRebuild()) {
$update[] = UPDATE_DONE;
- $task = $ad->generate(false, $parentTask);
+ $task = $confMod->generate(false, $parentTask);
if ($task !== false) {
$parentTask = $task;
}
@@ -171,5 +171,8 @@ if ($list === false) {
}
}
+// Start any changed services
+ConfigModuleBaseLdap::ldadp();
+
// Create response for browser
responseFromArray($update);