merge settingsdb into settings code

This commit is contained in:
Girish Ramakrishnan
2021-08-19 13:24:38 -07:00
parent 4cd5137292
commit 411cc7daa1
25 changed files with 332 additions and 578 deletions
+14 -33
View File
@@ -116,12 +116,9 @@ function runStartupTasks() {
platform.stopAllTasks,
// this configures collectd to collect backup storage metrics if filesystem is used. This is also triggerd when the settings change with the rest api
function (callback) {
settings.getBackupConfig(function (error, backupConfig) {
if (error) return callback(error);
backups.configureCollectd(backupConfig, callback);
});
async function () {
const backupConfig = await settings.getBackupConfig();
await backups.configureCollectd(backupConfig);
},
// always generate webadmin config since we have no versioning mechanism for the ejs
@@ -299,51 +296,35 @@ function prepareDashboardDomain(domain, auditSource, callback) {
}
// call this only pre activation since it won't start mail server
function setDashboardDomain(domain, auditSource, callback) {
async function setDashboardDomain(domain, auditSource) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
debug(`setDashboardDomain: ${domain}`);
domainsGet(domain, function (error, domainObject) {
if (error) return callback(error);
const domainObject = await domains.get(domain);
await reverseProxy.writeDashboardConfig(domain);
const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject);
util.callbackify(reverseProxy.writeDashboardConfig)(domain, function (error) {
if (error) return callback(error);
await settings.setDashboardLocation(domain, fqdn);
const fqdn = dns.fqdn(constants.DASHBOARD_LOCATION, domainObject);
await safe(appstore.updateCloudron({ domain }));
settings.setDashboardLocation(domain, fqdn, async function (error) {
if (error) return callback(error);
await safe(appstore.updateCloudron({ domain }));
eventlog.add(eventlog.ACTION_DASHBOARD_DOMAIN_UPDATE, auditSource, { domain, fqdn });
callback(null);
});
});
});
await eventlog.add(eventlog.ACTION_DASHBOARD_DOMAIN_UPDATE, auditSource, { domain, fqdn });
}
// call this only post activation because it will restart mail server
function updateDashboardDomain(domain, auditSource, callback) {
async function updateDashboardDomain(domain, auditSource) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
debug(`updateDashboardDomain: ${domain}`);
if (settings.isDemo()) return callback(new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode'));
if (settings.isDemo()) throw new BoxError(BoxError.CONFLICT, 'Not allowed in demo mode');
setDashboardDomain(domain, auditSource, function (error) {
if (error) return callback(error);
await setDashboardDomain(domain, auditSource);
services.rebuildService('turn', NOOP_CALLBACK); // to update the realm variable
callback(null);
});
services.rebuildService('turn', NOOP_CALLBACK); // to update the realm variable
}
async function renewCerts(options, auditSource) {