apps

certbot-autorenew-cron-v1

v1.js

Helps to renew SSL certificates automatically using certbot. Helps in automatic domain verification too. Also, runs a cron to keep checking SSL renewal automatically at specified time interval.

We need to set reverse proxy for .well-known folder so it can do the verification for us.
For example for openlitespeed go into Virtual Hosts and click a host. Go into External App add the app there with address 127.0.0.1:9999. Then go into context and add URI as /.well-known and select the external app you added.

Should be run with command line arguments.

Example:
node certbot-autorenew-cron-v1.js \
server-port=9999 \
server-folder=/mnt/node/letsencrypt \
cron-key= \
cron-interval=86400 \
dry-run=true \
optional:
console-key=my-console-key
console-prefix=certbot-autorenew-cron-v1

Check also: https://console.ylo.one/

Cron will not run until you specify cron-interval option.
Cron key is for running cron manually for example calling http://127.0.0.1:9999/cron-key
dry-run is equivalent to certbot’s –dry-run.

Help: Coming soon! 😀

An app bundled by ac-bundle-app, published by ac-bundle-module. namespace: certbot-autorenew-cron

Install from:

https://www.npmjs.com/package/certbot-autorenew-cron-v1
https://github.com/animatedcreativity/certbot-autorenew-cron-v1

Available Methods: start, startUps, workerStartUps, callbacks, build, cron, parseArgv, console, exit, consoleColors, camelCase, properCase, enhance, publish, server, has

start

async function() {
  var options = app.parseArgv(["server-port", "server-folder", "cron-key", "cron-interval", "console-key", "console-prefix", "dry-run"]);
  if (app.has(options)) {
    app.server.wellknown.start(options);
  } else {
    console.log(app.consoleColors.bgRed, "Invalid options: ", options);
  }
}

startUps

workerStartUps

callbacks

static

build

cron

run

parseArgv

function(list) {
  var options = {};
  for (var i=2; i<=process.argv.length-1; i++) {
    var option = process.argv[i];
    var name = option.split("=").shift().trim();
    var cName = app.camelCase(name).split("-").join("");
    var value = option.split("=").pop().trim();
    if (list.indexOf(name) >= 0) {
      options[cName] = value;
    } else {
      console.log(app.consoleColors.bgRed, "Invalid option: " + name);
      return;
    }
  }
  app.cliOptions = options;
  return options;
}

console

function() {
  if (app.has(app.cliOptions) && app.has(app.cliOptions.consoleKey)) {
    if (!app.has(mod.consoleRe)) {
      mod.consoleRe = require('console-remote-client').connect({server: "https://console.ylo.one:8088", channel: app.cliOptions.consoleKey});
    }
    var args = Array.prototype.slice.call(arguments);
    if (app.has(app.cliOptions.consolePrefix)) {
      args.unshift("[lime]" + app.cliOptions.consolePrefix + "[/lime]");
    }
    console.re.log.apply(null, args);
    mod.logged = true;
  }
}

exit

async function(time) {
  if (mod.logged === true) {
    console.log("Waiting for remote console...");
    if (!app.has(time)) time = 5; // 5 seconds
    await new Promise(function(resolve, reject) {
      setTimeout(function() { resolve(true); }, time * 1000);
    });
  }
  process.exit();
}

consoleColors

reset, bright, dim, underscore, blink, reverse, hidden, fgBlack, fgRed, fgGreen, fgYellow, fgBlue, fgMagenta, fgCyan, fgWhite, fgGray, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray

camelCase

function camelize(str, capitalFirst) {
  if (!app.has(capitalFirst)) capitalFirst = false;
  var result = str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
    return index === 0 ? word.toLowerCase() : word.toUpperCase();
  }).replace(/\s+/g, '');
  if (capitalFirst) result = result.substr(0, 1).toUpperCase() + result.substr(1, 999);
  return result;
}

properCase

function(str) {
  return str.replace(
    /\w\S*/g,
    function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }
  );
}

enhance

argv, console, string

publish

server

wellknown

has

function(value) {
  var found = true;
  for (var i=0; i<=arguments.length-1; i++) {
    var value = arguments[i];
    if (!(typeof value !== "undefined" && value !== null && value !== "")) found = false;
  }
  return found;
}

Happy Coding!

MIT License: https://choosealicense.com/licenses/mit/

Copyright 2022 Animated Creativity

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Leave a Reply

Your email address will not be published. Required fields are marked *