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