diff --git a/src/appstore.js b/src/appstore.js index 6cf87a502..7d92c9112 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -387,14 +387,15 @@ function registerCloudron(data, callback) { }); } -function registerWithLicense(license, callback) { +function registerWithLicense(license, domain, callback) { assert.strictEqual(typeof license, 'string'); + assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof callback, 'function'); getCloudronToken(function (error, token) { if (token) return callback(new AppstoreError(AppstoreError.ALREADY_REGISTERED)); - registerCloudron({ license }, callback); + registerCloudron({ license, domain }, callback); }); } diff --git a/src/provision.js b/src/provision.js index 08e603457..5f5cc86ef 100644 --- a/src/provision.js +++ b/src/provision.js @@ -108,7 +108,8 @@ function autoprovision(autoconf, callback) { }); } -function autoRegister(callback) { +function autoRegister(domain, callback) { + assert.strictEqual(typeof domain, 'string'); assert.strictEqual(typeof callback, 'function'); if (!fs.existsSync(paths.LICENSE_FILE)) return callback(); @@ -118,7 +119,7 @@ function autoRegister(callback) { debug('Auto-registering cloudron'); - appstore.registerWithLicense(license.trim(), function (error) { + appstore.registerWithLicense(license.trim(), domain, function (error) { if (error && error.reason !== AppstoreError.ALREADY_REGISTERED) { debug('Failed to auto-register cloudron', error); return callback(new ProvisionError(ProvisionError.LICENSE_ERROR, 'Failed to auto-register Cloudron with license. Please contact support@cloudron.io')); @@ -188,7 +189,7 @@ function setup(dnsConfig, autoconf, auditSource, callback) { callback(); // now that args are validated run the task in the background async.series([ - autoRegister, + autoRegister.bind(null, domain), domains.prepareDashboardDomain.bind(null, domain, auditSource, (progress) => setProgress('setup', progress.message, NOOP_CALLBACK)), cloudron.setDashboardDomain.bind(null, domain, auditSource), // this sets up the config.fqdn() mail.addDomain.bind(null, domain), // this relies on config.mailFqdn() diff --git a/src/server.js b/src/server.js index 573488f48..ea5765df8 100644 --- a/src/server.js +++ b/src/server.js @@ -370,7 +370,6 @@ function start(callback) { async.series([ routes.accesscontrol.initialize, // hooks up authentication strategies into passport database.initialize, - provision.autoRegister, cloudron.initialize, gHttpServer.listen.bind(gHttpServer, config.get('port'), '127.0.0.1'), gSysadminHttpServer.listen.bind(gSysadminHttpServer, config.get('sysadminPort'), '127.0.0.1'),