@@ -2,10 +2,10 @@ const fs = require('fs');
22const NodeRSA = require ( 'node-rsa' ) ;
33const config = require ( 'config' ) ;
44const logger = require ( './logger' ) . setup ;
5- const certificateModel = require ( './models/certificate' ) ;
5+ const certificateModel = require ( './models/certificate' ) ;
66const userModel = require ( './models/user' ) ;
77const userPermissionModel = require ( './models/user_permission' ) ;
8- const utils = require ( './lib/utils' ) ;
8+ const utils = require ( './lib/utils' ) ;
99const authModel = require ( './models/auth' ) ;
1010const settingModel = require ( './models/setting' ) ;
1111const dns_plugins = require ( './global/certbot-dns-plugins' ) ;
@@ -165,34 +165,35 @@ const setupDefaultSettings = () => {
165165 */
166166const setupCertbotPlugins = ( ) => {
167167 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+ } ) ;
196197} ;
197198
198199module . exports = function ( ) {
0 commit comments