Skip to content

Commit 6f281fe

Browse files
committed
Workaround for cloudflare plugin install (#2381)
1 parent 41bbfcf commit 6f281fe

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

backend/internal/certificate.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,12 @@ const internalCertificate = {
874874
// Escape single quotes and backslashes
875875
const escapedCredentials = certificate.meta.dns_provider_credentials.replaceAll('\'', '\\\'').replaceAll('\\', '\\\\');
876876
const credentialsCmd = 'mkdir -p /etc/letsencrypt/credentials 2> /dev/null; echo \'' + escapedCredentials + '\' > \'' + credentialsLocation + '\' && chmod 600 \'' + credentialsLocation + '\'';
877-
const prepareCmd = 'pip install ' + dns_plugin.package_name + (dns_plugin.version_requirement || '') + ' ' + dns_plugin.dependencies;
877+
let prepareCmd = 'pip install ' + dns_plugin.package_name + (dns_plugin.version_requirement || '') + ' ' + dns_plugin.dependencies;
878+
879+
// Special case for cloudflare
880+
if (dns_plugin.package_name === 'certbot-dns-cloudflare') {
881+
prepareCmd = 'pip install certbot-dns-cloudflare --index-url https://www.piwheels.org/simple --prefer-binary';
882+
}
878883

879884
// Whether the plugin has a --<name>-credentials argument
880885
const hasConfigArg = certificate.meta.dns_provider !== 'route53';

backend/setup.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,20 @@ const setupCertbotPlugins = () => {
171171
if (certificates && certificates.length) {
172172
let plugins = [];
173173
let promises = [];
174+
let install_cloudflare_plugin = false;
174175

175176
certificates.map(function (certificate) {
176177
if (certificate.meta && certificate.meta.dns_challenge === true) {
177178
const dns_plugin = dns_plugins[certificate.meta.dns_provider];
178-
const packages_to_install = `${dns_plugin.package_name}${dns_plugin.version_requirement || ''} ${dns_plugin.dependencies}`;
179-
180-
if (plugins.indexOf(packages_to_install) === -1) plugins.push(packages_to_install);
179+
if (dns_plugin.package_name === 'certbot-dns-cloudflare') {
180+
install_cloudflare_plugin = true;
181+
} else {
182+
const packages_to_install = `${dns_plugin.package_name}${dns_plugin.version_requirement || ''} ${dns_plugin.dependencies}`;
183+
if (plugins.indexOf(packages_to_install) === -1) plugins.push(packages_to_install);
184+
}
181185

182186
// Make sure credentials file exists
183-
const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
187+
const credentials_loc = '/etc/letsencrypt/credentials/credentials-' + certificate.id;
184188
// Escape single quotes and backslashes
185189
const escapedCredentials = certificate.meta.dns_provider_credentials.replaceAll('\'', '\\\'').replaceAll('\\', '\\\\');
186190
const credentials_cmd = '[ -f \'' + credentials_loc + '\' ] || { mkdir -p /etc/letsencrypt/credentials 2> /dev/null; echo \'' + escapedCredentials + '\' > \'' + credentials_loc + '\' && chmod 600 \'' + credentials_loc + '\'; }';
@@ -193,10 +197,14 @@ const setupCertbotPlugins = () => {
193197
promises.push(utils.exec(install_cmd));
194198
}
195199

200+
if (install_cloudflare_plugin) {
201+
promises.push(utils.exec('pip install certbot-dns-cloudflare --index-url https://www.piwheels.org/simple --prefer-binary'));
202+
}
203+
196204
if (promises.length) {
197205
return Promise.all(promises)
198-
.then(() => {
199-
logger.info('Added Certbot plugins ' + plugins.join(', '));
206+
.then(() => {
207+
logger.info('Added Certbot plugins ' + plugins.join(', '));
200208
});
201209
}
202210
}

0 commit comments

Comments
 (0)