Fixes eslint errors

This commit is contained in:
chaptergy 2020-10-17 12:25:36 +02:00
parent 1028de8158
commit 08ab62108f
2 changed files with 30 additions and 28 deletions

View File

@ -932,7 +932,8 @@ const internalCertificate = {
// Prepend the path to the credentials file as an environment variable // Prepend the path to the credentials file as an environment variable
if (certificate.meta.dns_provider === 'route53') { if (certificate.meta.dns_provider === 'route53') {
main_cmd = 'AWS_CONFIG_FILE=\'' + credentials_loc + '\' ' + main_cmd; const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
main_cmd = 'AWS_CONFIG_FILE=\'' + credentials_loc + '\' ' + main_cmd;
} }
if (debug_mode) { if (debug_mode) {

View File

@ -2,10 +2,10 @@ const fs = require('fs');
const NodeRSA = require('node-rsa'); const NodeRSA = require('node-rsa');
const config = require('config'); const config = require('config');
const logger = require('./logger').setup; const logger = require('./logger').setup;
const certificateModel = require('./models/certificate'); const certificateModel = require('./models/certificate');
const userModel = require('./models/user'); const userModel = require('./models/user');
const userPermissionModel = require('./models/user_permission'); const userPermissionModel = require('./models/user_permission');
const utils = require('./lib/utils'); const utils = require('./lib/utils');
const authModel = require('./models/auth'); const authModel = require('./models/auth');
const settingModel = require('./models/setting'); const settingModel = require('./models/setting');
const dns_plugins = require('./global/certbot-dns-plugins'); const dns_plugins = require('./global/certbot-dns-plugins');
@ -165,34 +165,35 @@ const setupDefaultSettings = () => {
*/ */
const setupCertbotPlugins = () => { const setupCertbotPlugins = () => {
return certificateModel return certificateModel
.query() .query()
.where('is_deleted', 0) .where('is_deleted', 0)
.andWhere('provider', 'letsencrypt') .andWhere('provider', 'letsencrypt')
.then((certificates) => { .then((certificates) => {
if (certificates && certificates.length) { if (certificates && certificates.length) {
let plugins = []; let plugins = [];
let promises = []; let promises = [];
certificates.map(function (certificate) { certificates.map(function (certificate) {
if (certificate.meta && certificate.meta.dns_challenge === true) { if (certificate.meta && certificate.meta.dns_challenge === true) {
const dns_plugin = dns_plugins[certificate.meta.dns_provider]; const dns_plugin = dns_plugins[certificate.meta.dns_provider];
const package = `${dns_plugin.package_name}==${dns_plugin.package_version}`; const package_to_install = `${dns_plugin.package_name}==${dns_plugin.package_version}`;
if (plugins.indexOf(package) === -1) plugins.push(package);
// Make sure credentials file exists if (plugins.indexOf(package_to_install) === -1) plugins.push(package_to_install);
const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
const credentials_cmd = '[ -f \'' + credentials_loc + '\' ] || { mkdir /etc/letsencrypt/credentials; echo \'' + certificate.meta.dns_provider_credentials.replace('\'', '\\\'') + '\' > \'' + credentials_loc + '\' && chmod 600 \'' + credentials_loc + '\'; }';
promises.push(utils.exec(credentials_cmd));
}
});
const install_cmd = 'pip3 install ' + plugins.join(' '); // Make sure credentials file exists
promises.push(utils.exec(install_cmd)); const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
return Promise.all(promises).then(() => { const credentials_cmd = '[ -f \'' + credentials_loc + '\' ] || { mkdir /etc/letsencrypt/credentials; echo \'' + certificate.meta.dns_provider_credentials.replace('\'', '\\\'') + '\' > \'' + credentials_loc + '\' && chmod 600 \'' + credentials_loc + '\'; }';
logger.info('Added Certbot plugins ' + plugins.join(', ')); promises.push(utils.exec(credentials_cmd));
}); }
} });
});
const install_cmd = 'pip3 install ' + plugins.join(' ');
promises.push(utils.exec(install_cmd));
return Promise.all(promises).then(() => {
logger.info('Added Certbot plugins ' + plugins.join(', '));
});
}
});
}; };
module.exports = function () { module.exports = function () {