@@ -2,10 +2,10 @@ const fs = require('fs');
2
2
const NodeRSA = require('node-rsa');
3
3
const config = require('config');
4
4
const logger = require('./logger').setup;
5
- const certificateModel = require('./models/certificate');
5
+ const certificateModel = require('./models/certificate');
6
6
const userModel = require('./models/user');
7
7
const userPermissionModel = require('./models/user_permission');
8
- const utils = require('./lib/utils');
8
+ const utils = require('./lib/utils');
9
9
const authModel = require('./models/auth');
10
10
const settingModel = require('./models/setting');
11
11
const dns_plugins = require('./global/certbot-dns-plugins');
@@ -165,34 +165,35 @@ const setupDefaultSettings = () => {
165
165
*/
166
166
const setupCertbotPlugins = () => {
167
167
return certificateModel
168
- .query()
169
- .where('is_deleted', 0)
170
- .andWhere('provider', 'letsencrypt')
171
- .then((certificates) => {
172
- if (certificates && certificates.length) {
173
- let plugins = [];
174
- let promises = [];
175
-
176
- certificates.map(function (certificate) {
177
- if (certificate.meta && certificate.meta.dns_challenge === true) {
178
- const dns_plugin = dns_plugins[certificate.meta.dns_provider];
179
- const package = `${dns_plugin.package_name}==${dns_plugin.package_version}`;
180
- if (plugins.indexOf(package) === -1) plugins.push(package);
181
-
182
- // Make sure credentials file exists
183
- const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
184
- const credentials_cmd = '[ -f \'' + credentials_loc + '\' ] || { mkdir /etc/letsencrypt/credentials; echo \'' + certificate.meta.dns_provider_credentials.replace('\'', '\\\'') + '\' > \'' + credentials_loc + '\' && chmod 600 \'' + credentials_loc + '\'; }';
185
- promises.push(utils.exec(credentials_cmd));
186
- }
187
- });
188
-
189
- const install_cmd = 'pip3 install ' + plugins.join(' ');
190
- promises.push(utils.exec(install_cmd));
191
- return Promise.all(promises).then(() => {
192
- logger.info('Added Certbot plugins ' + plugins.join(', '));
193
- });
194
- }
195
- });
168
+ .query()
169
+ .where('is_deleted', 0)
170
+ .andWhere('provider', 'letsencrypt')
171
+ .then((certificates) => {
172
+ if (certificates && certificates.length) {
173
+ let plugins = [];
174
+ let promises = [];
175
+
176
+ certificates.map(function (certificate) {
177
+ if (certificate.meta && certificate.meta.dns_challenge === true) {
178
+ const dns_plugin = dns_plugins[certificate.meta.dns_provider];
179
+ const package_to_install = `${dns_plugin.package_name}==${dns_plugin.package_version}`;
180
+
181
+ if (plugins.indexOf(package_to_install) === -1) plugins.push(package_to_install);
182
+
183
+ // Make sure credentials file exists
184
+ const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
185
+ const credentials_cmd = '[ -f \'' + credentials_loc + '\' ] || { mkdir /etc/letsencrypt/credentials; echo \'' + certificate.meta.dns_provider_credentials.replace('\'', '\\\'') + '\' > \'' + credentials_loc + '\' && chmod 600 \'' + credentials_loc + '\'; }';
186
+ promises.push(utils.exec(credentials_cmd));
187
+ }
188
+ });
189
+
190
+ const install_cmd = 'pip3 install ' + plugins.join(' ');
191
+ promises.push(utils.exec(install_cmd));
192
+ return Promise.all(promises).then(() => {
193
+ logger.info('Added Certbot plugins ' + plugins.join(', '));
194
+ });
195
+ }
196
+ });
196
197
};
197
198
198
199
module.exports = function () {
0 commit comments