allow for all configs with --all
This commit is contained in:
parent
783387f43d
commit
0a607ade91
|
@ -2,6 +2,10 @@ TODO.txt
|
|||
link.sh
|
||||
.env
|
||||
.greenlockrc
|
||||
# generated by init
|
||||
app.js
|
||||
server.js
|
||||
example.js
|
||||
|
||||
# ---> Node
|
||||
# Logs
|
||||
|
|
|
@ -32,16 +32,23 @@ async function main(_, flags, rc, greenlock) {
|
|||
delete flags.subject;
|
||||
delete flags.altnames;
|
||||
flags.servernames = servernames;
|
||||
if (flags.servernames.length > 1) {
|
||||
console.error('Error: should only have one servername');
|
||||
if (!flags.all && flags.servernames.length > 1) {
|
||||
console.error('Error: should specify either --subject OR --servername');
|
||||
process.exit(1);
|
||||
return;
|
||||
} else if (flags.servernames.length !== 1) {
|
||||
console.error('Error: need a servername to check');
|
||||
} else if (!flags.all && flags.servernames.length !== 1) {
|
||||
console.error('error: missing --servername <example.com>');
|
||||
process.exit(1);
|
||||
return;
|
||||
}
|
||||
if (!flags.all) {
|
||||
flags.servername = flags.servernames[0];
|
||||
} else if (flags.servername) {
|
||||
console.error(
|
||||
'error: missing cannot have --all and --servername / --subject'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
delete flags.servernames;
|
||||
|
||||
greenlock
|
||||
|
|
|
@ -21,6 +21,11 @@ Flags.flags = function(mconf, myOpts) {
|
|||
}
|
||||
|
||||
return {
|
||||
all: [
|
||||
false,
|
||||
'search all site configs rather than by --subject or --servernames',
|
||||
'boolean'
|
||||
],
|
||||
subject: [
|
||||
false,
|
||||
'the "subject" (primary domain) of the certificate',
|
||||
|
|
13
greenlock.js
13
greenlock.js
|
@ -277,12 +277,12 @@ G.create = function(gconf) {
|
|||
};
|
||||
|
||||
greenlock._config = function(args) {
|
||||
return greenlock
|
||||
._single(args)
|
||||
.then(function() {
|
||||
return greenlock._find(args);
|
||||
})
|
||||
.then(function(sites) {
|
||||
return greenlock._single(args).then(function() {
|
||||
return greenlock._configAll(args);
|
||||
});
|
||||
};
|
||||
greenlock._configAll = function(args) {
|
||||
return greenlock._find(args).then(function(sites) {
|
||||
if (!sites || !sites.length) {
|
||||
return null;
|
||||
}
|
||||
|
@ -292,6 +292,7 @@ G.create = function(gconf) {
|
|||
return site;
|
||||
}
|
||||
var dconf = site;
|
||||
// TODO make cli and api mode the same
|
||||
if (gconf._bin_mode) {
|
||||
dconf = site.defaults = {};
|
||||
}
|
||||
|
|
|
@ -192,22 +192,34 @@ module.exports.wrap = function(greenlock, manager, gconf) {
|
|||
*/
|
||||
|
||||
greenlock._find = function(args) {
|
||||
var altnames = args.altnames || [];
|
||||
var servernames = (args.servernames || [])
|
||||
.concat(args.altnames || [])
|
||||
.filter(Boolean)
|
||||
.slice(0);
|
||||
var modified = servernames.slice(0);
|
||||
|
||||
// servername, wildname, and altnames are all the same
|
||||
['wildname', 'servername'].forEach(function(k) {
|
||||
var altname = args[k] || '';
|
||||
if (altname && !altnames.includes(altname)) {
|
||||
altnames.push(altname);
|
||||
if (altname && !modified.includes(altname)) {
|
||||
modified.push(altname);
|
||||
}
|
||||
});
|
||||
|
||||
if (altnames.length) {
|
||||
args.altnames = altnames;
|
||||
args.altnames = args.altnames.map(U._encodeName);
|
||||
args.altnames = checkAltnames(false, args);
|
||||
if (modified.length) {
|
||||
servernames = modified;
|
||||
servernames = servernames.altnames.map(U._encodeName);
|
||||
args.altnames = servernames;
|
||||
args.servernames = args.altnames = checkAltnames(false, args);
|
||||
}
|
||||
|
||||
// documented as args.servernames
|
||||
// preserved as args.altnames for v3 beta backwards compat
|
||||
// my only hesitancy in this choice is that a "servername"
|
||||
// may NOT contain '*.', in which case `altnames` is a better choice.
|
||||
// However, `altnames` is ambiguous - as if it means to find a
|
||||
// certificate by that specific collection of altnames.
|
||||
// ... perhaps `domains` could work?
|
||||
return manager.find(args);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@root/greenlock",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.0-wip",
|
||||
"description": "The easiest Let's Encrypt client for Node.js and Browsers",
|
||||
"homepage": "https://rootprojects.org/greenlock/",
|
||||
"main": "greenlock.js",
|
||||
|
|
Loading…
Reference in New Issue