diff --git a/setup/start.sh b/setup/start.sh index 02feb61ff..9aa78f123 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -108,6 +108,8 @@ systemctl restart unbound # ensure cloudron-syslog runs systemctl restart cloudron-syslog +json -f /etc/cloudron/cloudron.conf -I -e "delete this.adminLocation" # can be removed after 3.6 + echo "==> Configuring sudoers" rm -f /etc/sudoers.d/${USER} cp "${script_dir}/start/sudoers" /etc/sudoers.d/${USER} diff --git a/src/cloudron.js b/src/cloudron.js index 920294dc9..bd708e4d4 100644 --- a/src/cloudron.js +++ b/src/cloudron.js @@ -351,7 +351,6 @@ function setDashboardDomain(domain, auditSource, callback) { const fqdn = domains.fqdn(constants.ADMIN_LOCATION, domainObject); config.setAdminDomain(domain); - config.setAdminLocation(constants.ADMIN_LOCATION); config.setAdminFqdn(fqdn); clients.addDefaultClients(config.adminOrigin(), function (error) { diff --git a/src/config.js b/src/config.js index c5da60262..ff5a298f4 100644 --- a/src/config.js +++ b/src/config.js @@ -20,7 +20,6 @@ exports = module.exports = { setFqdn: setAdminDomain, setAdminDomain: setAdminDomain, setAdminFqdn: setAdminFqdn, - setAdminLocation: setAdminLocation, version: version, database: database, edition: edition, @@ -29,12 +28,9 @@ exports = module.exports = { adminOrigin: adminOrigin, internalAdminOrigin: internalAdminOrigin, sysadminOrigin: sysadminOrigin, // caas routes - adminLocation: adminLocation, adminFqdn: adminFqdn, - mailLocation: mailLocation, mailFqdn: mailFqdn, hasIPv6: hasIPv6, - dkimSelector: dkimSelector, isManaged: isManaged, isDemo: isDemo, @@ -74,7 +70,6 @@ function saveSync() { webServerOrigin: data.webServerOrigin, adminDomain: data.adminDomain, adminFqdn: data.adminFqdn, - adminLocation: data.adminLocation, provider: data.provider, isDemo: data.isDemo, edition: data.edition @@ -95,7 +90,6 @@ function initConfig() { // setup defaults data.adminFqdn = ''; data.adminDomain = ''; - data.adminLocation = 'my'; data.port = 3000; data.apiServerOrigin = null; data.webServerOrigin = null; @@ -168,19 +162,6 @@ function adminDomain() { return get('adminDomain'); } -function mailLocation() { - return get('adminLocation'); // not a typo! should be same as admin location until we figure out certificates -} - -function setAdminLocation(location) { - set('adminLocation', location); -} - - -function adminLocation() { - return get('adminLocation'); -} - function setAdminFqdn(adminFqdn) { set('adminFqdn', adminFqdn); } @@ -236,13 +217,6 @@ function hasIPv6() { return fs.existsSync(IPV6_PROC_FILE) && fs.readFileSync(IPV6_PROC_FILE, 'utf8').trim().length !== 0; } -// it has to change with the adminLocation so that multiple cloudrons -// can send out emails at the same time. -function dkimSelector() { - var loc = adminLocation(); - return loc === 'my' ? 'cloudron' : `cloudron-${loc.replace(/\./g, '')}`; -} - function edition() { return get('edition'); } diff --git a/src/constants.js b/src/constants.js index 0898ba946..b7a1864c8 100644 --- a/src/constants.js +++ b/src/constants.js @@ -18,6 +18,7 @@ exports = module.exports = { ], ADMIN_LOCATION: 'my', + DKIM_SELECTOR: 'cloudron', NGINX_DEFAULT_CONFIG_FILE_NAME: 'default.conf', diff --git a/src/dyndns.js b/src/dyndns.js index 16358158b..e03fd03c8 100644 --- a/src/dyndns.js +++ b/src/dyndns.js @@ -8,6 +8,7 @@ var appdb = require('./appdb.js'), apps = require('./apps.js'), async = require('async'), config = require('./config.js'), + constants = require('./constants.js'), debug = require('debug')('box:dyndns'), domains = require('./domains.js'), eventlog = require('./eventlog.js'), @@ -32,7 +33,7 @@ function sync(callback) { debug(`refreshDNS: updating ip from ${info.ip} to ${ip}`); - domains.upsertDnsRecords(config.adminLocation(), config.adminDomain(), 'A', [ ip ], function (error) { + domains.upsertDnsRecords(constants.ADMIN_LOCATION, config.adminDomain(), 'A', [ ip ], function (error) { if (error) return callback(error); debug('refreshDNS: updated admin location'); diff --git a/src/mail.js b/src/mail.js index 2eb5c159e..cf6b088cd 100644 --- a/src/mail.js +++ b/src/mail.js @@ -205,8 +205,8 @@ function verifyRelay(relay, callback) { function checkDkim(domain, callback) { var dkim = { - domain: config.dkimSelector() + '._domainkey.' + domain, - name: config.dkimSelector() + '._domainkey', + domain: `${constants.DKIM_SELECTOR}._domainkey.${domain}`, + name: `${constants.DKIM_SELECTOR}._domainkey`, type: 'TXT', expected: null, value: null, @@ -782,7 +782,7 @@ function ensureDkimKeySync(domain) { if (!safe.child_process.execSync('openssl genrsa -out ' + dkimPrivateKeyFile + ' 1024')) return new MailError(MailError.INTERNAL_ERROR, safe.error); if (!safe.child_process.execSync('openssl rsa -in ' + dkimPrivateKeyFile + ' -out ' + dkimPublicKeyFile + ' -pubout -outform PEM')) return new MailError(MailError.INTERNAL_ERROR, safe.error); - if (!safe.fs.writeFileSync(dkimSelectorFile, config.dkimSelector(), 'utf8')) return new MailError(MailError.INTERNAL_ERROR, safe.error); + if (!safe.fs.writeFileSync(dkimSelectorFile, constants.DKIM_SELECTOR, 'utf8')) return new MailError(MailError.INTERNAL_ERROR, safe.error); return null; } @@ -824,7 +824,7 @@ function upsertDnsRecords(domain, mailFqdn, callback) { if (!dkimKey) return callback(new MailError(MailError.INTERNAL_ERROR, new Error('Failed to read dkim public key'))); // t=s limits the domainkey to this domain and not it's subdomains - var dkimRecord = { subdomain: config.dkimSelector() + '._domainkey', domain: domain, type: 'TXT', values: [ '"v=DKIM1; t=s; p=' + dkimKey + '"' ] }; + var dkimRecord = { subdomain: `${constants.DKIM_SELECTOR}._domainkey`, domain: domain, type: 'TXT', values: [ '"v=DKIM1; t=s; p=' + dkimKey + '"' ] }; var records = [ ]; records.push(dkimRecord); diff --git a/src/provision.js b/src/provision.js index 7dc6386dd..2417b8233 100644 --- a/src/provision.js +++ b/src/provision.js @@ -122,7 +122,6 @@ function unprovision(callback) { config.setAdminDomain(''); config.setAdminFqdn(''); - config.setAdminLocation(constants.ADMIN_LOCATION); // TODO: also cancel any existing configureWebadmin task async.series([ diff --git a/src/test/config-test.js b/src/test/config-test.js index 1fd42e83f..369bb62ce 100644 --- a/src/test/config-test.js +++ b/src/test/config-test.js @@ -33,7 +33,6 @@ describe('config', function () { it('did set default values', function () { expect(config.adminDomain()).to.equal(''); expect(config.adminFqdn()).to.equal(''); - expect(config.adminLocation()).to.equal('my'); }); it('set does not save custom values in file', function (done) { @@ -68,7 +67,6 @@ describe('config', function () { config.setAdminFqdn('my-test.example.com'); expect(config.adminDomain()).to.equal('test.example.com'); - expect(config.adminLocation()).to.equal('my'); expect(config.adminOrigin()).to.equal('https://my-test.example.com'); });