Files

55 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2024-01-18 12:26:55 +10:00
#!/usr/bin/node
// Usage:
2025-10-26 00:28:03 +10:00
// Install all plugins defined in `../certbot/dns-plugins.json`:
2024-01-18 12:26:55 +10:00
// ./install-certbot-plugins
// Install one or more specific plugins:
// ./install-certbot-plugins route53 cloudflare
//
// Usage with a running docker container:
// docker exec npm_core /command/s6-setuidgid 1000:1000 bash -c "/app/scripts/install-certbot-plugins"
//
2025-10-26 00:28:03 +10:00
import batchflow from "batchflow";
import dnsPlugins from "../certbot/dns-plugins.json" with { type: "json" };
2025-09-02 21:43:00 +10:00
import { installPlugin } from "../lib/certbot.js";
import { certbot as logger } from "../logger.js";
2024-01-18 12:26:55 +10:00
2025-10-26 00:28:03 +10:00
let hasErrors = false;
const failingPlugins = [];
2024-01-18 12:26:55 +10:00
let pluginKeys = Object.keys(dnsPlugins);
if (process.argv.length > 2) {
pluginKeys = process.argv.slice(2);
}
2025-10-26 00:28:03 +10:00
batchflow(pluginKeys)
.sequential()
2024-01-18 12:26:55 +10:00
.each((i, pluginKey, next) => {
2025-09-02 21:43:00 +10:00
installPlugin(pluginKey)
2024-01-18 12:26:55 +10:00
.then(() => {
next();
})
.catch((err) => {
hasErrors = true;
failingPlugins.push(pluginKey);
next(err);
});
})
.error((err) => {
logger.error(err.message);
})
.end(() => {
if (hasErrors) {
2025-10-26 00:28:03 +10:00
logger.error(
"Some plugins failed to install. Please check the logs above. Failing plugins: " +
"\n - " +
failingPlugins.join("\n - "),
);
2024-01-18 12:26:55 +10:00
process.exit(1);
} else {
2025-10-26 00:28:03 +10:00
logger.complete("Plugins installed successfully");
2024-01-18 12:26:55 +10:00
process.exit(0);
}
});