From af763eadd4ae9a3813a02c2c566269fd4cbd7a91 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 26 Sep 2018 10:26:33 -0700 Subject: [PATCH] Fix perms issue when restoring Fixes #536 --- src/mail.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mail.js b/src/mail.js index 40f35a3b0..de6fc3abf 100644 --- a/src/mail.js +++ b/src/mail.js @@ -597,6 +597,20 @@ function restartMail(callback) { }); } +function restartMailIfActivated(callback) { + assert.strictEqual(typeof callback, 'function'); + + users.count(function (error, count) { + if (error) return callback(new MailError(MailError.INTERNAL_ERROR, error)); + if (!count) { + debug('restartMailIfActivated: skipping restart of mail container since Cloudron is not activated yet'); + return callback(); // not provisioned yet, do not restart container after dns setup + } + + restartMail(callback); + }); +} + function getDomain(domain, callback) { assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof callback, 'function'); @@ -765,7 +779,7 @@ function addDomain(domain, callback) { async.series([ setDnsRecords.bind(null, domain), // do this first to ensure DKIM keys - restartMail + restartMailIfActivated ], NOOP_CALLBACK); // do these asynchronously callback();