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;
|
||||
}
|
||||
flags.servername = flags.servernames[0];
|
||||
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',
|
||||
|
|
51
greenlock.js
51
greenlock.js
|
@ -277,34 +277,35 @@ G.create = function(gconf) {
|
|||
};
|
||||
|
||||
greenlock._config = function(args) {
|
||||
return greenlock
|
||||
._single(args)
|
||||
.then(function() {
|
||||
return greenlock._find(args);
|
||||
})
|
||||
.then(function(sites) {
|
||||
if (!sites || !sites.length) {
|
||||
return null;
|
||||
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;
|
||||
}
|
||||
var site = sites[0];
|
||||
site = JSON.parse(JSON.stringify(site));
|
||||
if (site.store && site.challenges) {
|
||||
return site;
|
||||
}
|
||||
var dconf = site;
|
||||
// TODO make cli and api mode the same
|
||||
if (gconf._bin_mode) {
|
||||
dconf = site.defaults = {};
|
||||
}
|
||||
return manager.defaults().then(function(mconf) {
|
||||
if (!site.store) {
|
||||
dconf.store = mconf.store;
|
||||
}
|
||||
var site = sites[0];
|
||||
site = JSON.parse(JSON.stringify(site));
|
||||
if (site.store && site.challenges) {
|
||||
return site;
|
||||
if (!site.challenges) {
|
||||
dconf.challenges = mconf.challenges;
|
||||
}
|
||||
var dconf = site;
|
||||
if (gconf._bin_mode) {
|
||||
dconf = site.defaults = {};
|
||||
}
|
||||
return manager.defaults().then(function(mconf) {
|
||||
if (!site.store) {
|
||||
dconf.store = mconf.store;
|
||||
}
|
||||
if (!site.challenges) {
|
||||
dconf.challenges = mconf.challenges;
|
||||
}
|
||||
return site;
|
||||
});
|
||||
return site;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// needs to get info about the renewal, such as which store and challenge(s) to use
|
||||
|
|
|
@ -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