reverse proxy: rebuild configs on provider change
This commit is contained in:
@@ -11,6 +11,8 @@ exports = module.exports = {
|
||||
getCertificatePath, // resolved cert path
|
||||
ensureCertificate,
|
||||
|
||||
handleCertificateProviderChanged,
|
||||
|
||||
checkCerts,
|
||||
|
||||
// the 'configure' functions ensure a certificate and generate nginx config
|
||||
@@ -406,7 +408,7 @@ async function renewCert(fqdn, domainObject) {
|
||||
|
||||
if (domainObject.domain === settings.dashboardDomain() && getAcmeCertificatePathSync(settings.dashboardFqdn(), domainObject).certFilePath === acmePaths.certFilePath) {
|
||||
debug('renewCert: directory server certificate changed');
|
||||
const [reloadError] = await safe(shell.promises.exec('renewCert', 'systemctl reload --no-block box'));
|
||||
const [reloadError] = await safe(shell.promises.sudo('renewCert', [ RESTART_SERVICE_CMD, 'box' ], {}));
|
||||
if (reloadError) debug(`renewCert: error updating directory server on cert change: ${reloadError.message}`);
|
||||
}
|
||||
}
|
||||
@@ -748,11 +750,33 @@ async function cleanupCerts(auditSource, progressCallback) {
|
||||
debug('cleanupCerts: done');
|
||||
}
|
||||
|
||||
async function rebuildConfigs(auditSource, progressCallback) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof progressCallback, 'function');
|
||||
|
||||
debug('rebuildConfigs: rebuilding all configs');
|
||||
|
||||
progressCallback( { message: 'Rebuilding app configs' });
|
||||
for (const app of await apps.list()) {
|
||||
if (app.runState === apps.RSTATE_STOPPED) continue; // not in use
|
||||
await writeAppConfigs(app);
|
||||
}
|
||||
await writeDashboardConfig(await domains.get(settings.dashboardDomain()));
|
||||
await shell.promises.sudo('rebuildConfigs', [ RESTART_SERVICE_CMD, 'box' ], {});
|
||||
|
||||
progressCallback( { message: 'Rebuilding mail config' });
|
||||
await mail.handleCertChanged();
|
||||
}
|
||||
|
||||
async function checkCerts(auditSource, progressCallback) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof progressCallback, 'function');
|
||||
|
||||
await renewCerts(auditSource, progressCallback);
|
||||
if (fs.existsSync(paths.REVERSE_PROXY_REBUILD_FILE)) {
|
||||
await rebuildConfigs(auditSource, progressCallback);
|
||||
safe.fs.unlinkSync(paths.REVERSE_PROXY_REBUILD_FILE);
|
||||
}
|
||||
await cleanupCerts(auditSource, progressCallback);
|
||||
}
|
||||
|
||||
@@ -806,3 +830,7 @@ async function writeDefaultConfig(options) {
|
||||
|
||||
await reload();
|
||||
}
|
||||
|
||||
async function handleCertificateProviderChanged() {
|
||||
safe.fs.writeFileSync(paths.REVERSE_PROXY_REBUILD_FILE, 'cert provider changed\n', 'utf8');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user