2019-11-03 01:33:12 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var args = process.argv.slice(3);
|
2019-11-03 07:58:01 +00:00
|
|
|
var cli = require('./lib/cli.js');
|
|
|
|
var Flags = require('./lib/flags.js');
|
2019-11-03 01:33:12 +00:00
|
|
|
|
2019-11-19 05:55:29 +00:00
|
|
|
Flags.init().then(function({ flagOptions, greenlock, mconf }) {
|
2019-11-03 01:33:12 +00:00
|
|
|
var myFlags = {};
|
|
|
|
[
|
|
|
|
'subject',
|
|
|
|
'altnames',
|
|
|
|
'renew-offset',
|
2019-11-03 07:58:01 +00:00
|
|
|
'subscriber-email',
|
|
|
|
'customer-email',
|
2019-11-03 01:33:12 +00:00
|
|
|
'server-key-type',
|
2019-11-03 07:58:01 +00:00
|
|
|
'challenge-http-01',
|
|
|
|
'challenge-http-01-xxxx',
|
|
|
|
'challenge-dns-01',
|
|
|
|
'challenge-dns-01-xxxx',
|
|
|
|
'challenge-tls-alpn-01',
|
|
|
|
'challenge-tls-alpn-01-xxxx',
|
2019-11-03 01:33:12 +00:00
|
|
|
'challenge',
|
|
|
|
'challenge-xxxx',
|
|
|
|
'challenge-json',
|
|
|
|
'force-save'
|
|
|
|
].forEach(function(k) {
|
|
|
|
myFlags[k] = flagOptions[k];
|
|
|
|
});
|
|
|
|
|
|
|
|
cli.parse(myFlags);
|
2019-11-03 07:58:01 +00:00
|
|
|
cli.main(async function(argList, flags) {
|
|
|
|
var sconf = await greenlock._config({ servername: flags.subject });
|
|
|
|
Flags.mangleFlags(flags, mconf, sconf);
|
2019-11-19 05:55:29 +00:00
|
|
|
main(argList, flags, greenlock);
|
2019-11-03 01:33:12 +00:00
|
|
|
}, args);
|
|
|
|
});
|
|
|
|
|
2019-11-19 05:55:29 +00:00
|
|
|
async function main(_, flags, greenlock) {
|
2019-11-03 07:58:01 +00:00
|
|
|
if (!flags.subject) {
|
|
|
|
console.error('--subject must be provided as a valid domain');
|
2019-11-03 01:33:12 +00:00
|
|
|
process.exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-03 07:58:01 +00:00
|
|
|
greenlock
|
|
|
|
.update(flags)
|
|
|
|
.catch(function(err) {
|
|
|
|
console.error();
|
|
|
|
console.error('error:', err.message);
|
|
|
|
console.error();
|
|
|
|
process.exit(1);
|
|
|
|
})
|
|
|
|
.then(function() {
|
2019-11-03 01:33:12 +00:00
|
|
|
return greenlock
|
|
|
|
._config({ servername: flags.subject })
|
|
|
|
.then(function(site) {
|
|
|
|
if (!site) {
|
|
|
|
console.info();
|
2019-11-03 07:58:01 +00:00
|
|
|
console.info('No config found for', flags.subject);
|
2019-11-03 01:33:12 +00:00
|
|
|
console.info();
|
|
|
|
process.exit(1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-03 07:58:01 +00:00
|
|
|
console.info();
|
2019-11-03 01:33:12 +00:00
|
|
|
Object.keys(site).forEach(function(k) {
|
|
|
|
if ('defaults' === k) {
|
|
|
|
console.info(k + ':');
|
|
|
|
Object.keys(site.defaults).forEach(function(key) {
|
|
|
|
var value = JSON.stringify(site.defaults[key]);
|
|
|
|
console.info('\t' + key + ':' + value);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
console.info(k + ': ' + JSON.stringify(site[k]));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|