greenlock.js-ARCHIVED/bin/update.js

80 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2019-11-03 01:33:12 +00:00
'use strict';
var args = process.argv.slice(3);
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',
'subscriber-email',
'customer-email',
2019-11-03 01:33:12 +00:00
'server-key-type',
'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);
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) {
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;
}
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();
console.info('No config found for', flags.subject);
2019-11-03 01:33:12 +00:00
console.info();
process.exit(1);
return;
}
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]));
}
});
});
});
}