@@ -7,7 +7,7 @@ const utils = require('./lib/utils');
77const authModel = require ( './models/auth' ) ;
88const settingModel = require ( './models/setting' ) ;
99const dns_plugins = require ( './global/certbot-dns-plugins' ) ;
10-
10+ const certbot = require ( './lib/certbot' ) ;
1111/**
1212 * Creates a default admin users if one doesn't already exist in the database
1313 *
@@ -116,10 +116,7 @@ const setupCertbotPlugins = () => {
116116
117117 certificates . map ( function ( certificate ) {
118118 if ( certificate . meta && certificate . meta . dns_challenge === true ) {
119- const dns_plugin = dns_plugins [ certificate . meta . dns_provider ] ;
120-
121- const packages_to_install = `${ dns_plugin . package_name } ${ dns_plugin . version_requirement || '' } ${ dns_plugin . dependencies } ` ;
122- if ( plugins . indexOf ( packages_to_install ) === - 1 ) plugins . push ( packages_to_install ) ;
119+ plugins . push ( certificate . meta . dns_provider ) ;
123120
124121 // Make sure credentials file exists
125122 const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate . id ;
@@ -130,17 +127,15 @@ const setupCertbotPlugins = () => {
130127 }
131128 } ) ;
132129
133- if ( plugins . length ) {
134- const install_cmd = '. /opt/certbot/bin/activate && pip install --no-cache-dir ' + plugins . join ( ' ' ) + ' && deactivate' ;
135- promises . push ( utils . exec ( install_cmd ) ) ;
136- }
137-
138- if ( promises . length ) {
139- return Promise . all ( promises )
140- . then ( ( ) => {
141- logger . info ( 'Added Certbot plugins ' + plugins . join ( ', ' ) ) ;
142- } ) ;
143- }
130+ return certbot . installPlugins ( plugins )
131+ . then ( ( ) => {
132+ if ( promises . length ) {
133+ return Promise . all ( promises )
134+ . then ( ( ) => {
135+ logger . info ( 'Added Certbot plugins ' + plugins . join ( ', ' ) ) ;
136+ } ) ;
137+ }
138+ } ) ;
144139 }
145140 } ) ;
146141} ;
0 commit comments