install-certbot-plugins 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/node
  2. // Usage:
  3. // Install all plugins defined in `../certbot/dns-plugins.json`:
  4. // ./install-certbot-plugins
  5. // Install one or more specific plugins:
  6. // ./install-certbot-plugins route53 cloudflare
  7. //
  8. // Usage with a running docker container:
  9. // docker exec npm_core /command/s6-setuidgid 1000:1000 bash -c "/app/scripts/install-certbot-plugins"
  10. //
  11. import batchflow from "batchflow";
  12. import dnsPlugins from "../certbot/dns-plugins.json" with { type: "json" };
  13. import { installPlugin } from "../lib/certbot.js";
  14. import { certbot as logger } from "../logger.js";
  15. let hasErrors = false;
  16. const failingPlugins = [];
  17. let pluginKeys = Object.keys(dnsPlugins);
  18. if (process.argv.length > 2) {
  19. pluginKeys = process.argv.slice(2);
  20. }
  21. batchflow(pluginKeys)
  22. .sequential()
  23. .each((i, pluginKey, next) => {
  24. installPlugin(pluginKey)
  25. .then(() => {
  26. next();
  27. })
  28. .catch((err) => {
  29. hasErrors = true;
  30. failingPlugins.push(pluginKey);
  31. next(err);
  32. });
  33. })
  34. .error((err) => {
  35. logger.error(err.message);
  36. })
  37. .end(() => {
  38. if (hasErrors) {
  39. logger.error(
  40. "Some plugins failed to install. Please check the logs above. Failing plugins: " +
  41. "\n - " +
  42. failingPlugins.join("\n - "),
  43. );
  44. process.exit(1);
  45. } else {
  46. logger.complete("Plugins installed successfully");
  47. process.exit(0);
  48. }
  49. });