minor bugfixes
This commit is contained in:
parent
aa53b18a9d
commit
b9537f8419
93
manager.js
93
manager.js
|
@ -17,9 +17,7 @@ Manage.create = function(opts) {
|
||||||
}
|
}
|
||||||
if (!opts.configFile) {
|
if (!opts.configFile) {
|
||||||
opts.configFile = '~/.config/greenlock/manager.json';
|
opts.configFile = '~/.config/greenlock/manager.json';
|
||||||
console.info(
|
console.info('Greenlock Manager Config File: ' + opts.configFile);
|
||||||
"[Manager] using default config file:\n\t'" + opts.configFile + "'"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
opts.configFile = opts.configFile.replace('~/', homedir + '/');
|
opts.configFile = opts.configFile.replace('~/', homedir + '/');
|
||||||
|
|
||||||
|
@ -29,9 +27,7 @@ Manage.create = function(opts) {
|
||||||
return Manage._ping(manage, opts);
|
return Manage._ping(manage, opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
manage._txPromise = new Promise(function(resolve) {
|
manage._txPromise = Promise.resolve();
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
manage.config = function(conf) {
|
manage.config = function(conf) {
|
||||||
// get / set default site settings such as
|
// get / set default site settings such as
|
||||||
|
@ -87,7 +83,7 @@ Manage.create = function(opts) {
|
||||||
config[k] = conf[k];
|
config[k] = conf[k];
|
||||||
});
|
});
|
||||||
|
|
||||||
return manage.save(config);
|
return manage._save(config);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,6 +125,7 @@ Manage.create = function(opts) {
|
||||||
// if the fs has changed since we last wrote, get the lastest from disk
|
// if the fs has changed since we last wrote, get the lastest from disk
|
||||||
return Manage._getLatest(manage, opts).then(function(config) {
|
return Manage._getLatest(manage, opts).then(function(config) {
|
||||||
// TODO move to Greenlock.add
|
// TODO move to Greenlock.add
|
||||||
|
var subscriberEmail = args.subscriberEmail;
|
||||||
var subject = args.subject || args.domain;
|
var subject = args.subject || args.domain;
|
||||||
var primary = subject;
|
var primary = subject;
|
||||||
var altnames = args.altnames || args.domains;
|
var altnames = args.altnames || args.domains;
|
||||||
|
@ -160,10 +157,14 @@ Manage.create = function(opts) {
|
||||||
// and to make deterministic auto-corrections
|
// and to make deterministic auto-corrections
|
||||||
|
|
||||||
// TODO added, removed, moved (duplicate), changed
|
// TODO added, removed, moved (duplicate), changed
|
||||||
site.subscriberEmail = site.subscriberEmail;
|
if (subscriberEmail) {
|
||||||
|
site.subscriberEmail = subscriberEmail;
|
||||||
|
}
|
||||||
site.subject = subject;
|
site.subject = subject;
|
||||||
site.altnames = altnames;
|
site.altnames = altnames;
|
||||||
site.issuedAt = site.issuedAt || 0;
|
if (!site.issuedAt) {
|
||||||
|
site.issuedAt = 0;
|
||||||
|
}
|
||||||
site.expiresAt = site.expiresAt || 0;
|
site.expiresAt = site.expiresAt || 0;
|
||||||
site.lastAttemptAt = site.lastAttemptAt || 0;
|
site.lastAttemptAt = site.lastAttemptAt || 0;
|
||||||
// re-add if this was deleted
|
// re-add if this was deleted
|
||||||
|
@ -183,11 +184,15 @@ Manage.create = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// These should usually be empty, for most situations
|
// These should usually be empty, for most situations
|
||||||
site.subscriberEmail = args.subscriberEmail;
|
if (args.customerEmail) {
|
||||||
site.customerEmail = args.customerEmail;
|
site.customerEmail = args.customerEmail;
|
||||||
site.challenges = args.challenges;
|
}
|
||||||
site.store = args.store;
|
if (args.challenges) {
|
||||||
console.log('[debug] save site', site);
|
site.challenges = args.challenges;
|
||||||
|
}
|
||||||
|
if (args.store) {
|
||||||
|
site.store = args.store;
|
||||||
|
}
|
||||||
|
|
||||||
return manage._save(config).then(function() {
|
return manage._save(config).then(function() {
|
||||||
return JSON.parse(JSON.stringify(site));
|
return JSON.parse(JSON.stringify(site));
|
||||||
|
@ -204,11 +209,18 @@ Manage.create = function(opts) {
|
||||||
// i.e. find certs more that will expire in less than 45 days
|
// i.e. find certs more that will expire in less than 45 days
|
||||||
//args.expiresBefore = Date.now() + 45 * 24 * 60 * 60 * 1000;
|
//args.expiresBefore = Date.now() + 45 * 24 * 60 * 60 * 1000;
|
||||||
var issuedBefore = args.issuedBefore || 0;
|
var issuedBefore = args.issuedBefore || 0;
|
||||||
var expiresBefore =
|
var expiresBefore = args.expiresBefore || Infinity; //Date.now() + 21 * 24 * 60 * 60 * 1000;
|
||||||
args.expiresBefore || Date.now() + 21 * 24 * 60 * 60 * 1000;
|
|
||||||
|
var altnames = (args.altnames || args.domains || []).slice(0);
|
||||||
|
if (args.servername && !altnames.includes(args.servername)) {
|
||||||
|
altnames.push(args.servername);
|
||||||
|
}
|
||||||
|
if (args.subject && !altnames.includes(args.subject)) {
|
||||||
|
altnames.push(args.subject);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO match ANY domain on any cert
|
// TODO match ANY domain on any cert
|
||||||
var sites = Object.keys(config.sites)
|
var sites = Object.keys(config.sites || {})
|
||||||
.filter(function(sub) {
|
.filter(function(sub) {
|
||||||
var site = config.sites[sub];
|
var site = config.sites[sub];
|
||||||
if (
|
if (
|
||||||
|
@ -216,14 +228,13 @@ Manage.create = function(opts) {
|
||||||
site.expiresAt < expiresBefore ||
|
site.expiresAt < expiresBefore ||
|
||||||
site.issuedAt < issuedBefore
|
site.issuedAt < issuedBefore
|
||||||
) {
|
) {
|
||||||
if (!args.subject || sub === args.subject) {
|
return (site.altnames || []).some(function(name) {
|
||||||
return true;
|
return altnames.includes(name);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(function(name) {
|
.map(function(name) {
|
||||||
var site = config.sites[name];
|
var site = config.sites[name];
|
||||||
console.debug('debug', site);
|
|
||||||
return {
|
return {
|
||||||
subject: site.subject,
|
subject: site.subject,
|
||||||
altnames: site.altnames,
|
altnames: site.altnames,
|
||||||
|
@ -269,7 +280,45 @@ Manage.create = function(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO define message types
|
// TODO define message types
|
||||||
console.info(ev, args);
|
if (!manage._notify_notice) {
|
||||||
|
console.info(
|
||||||
|
'set greenlockOptions.notify to override the default logger'
|
||||||
|
);
|
||||||
|
manage._notify_notice = true;
|
||||||
|
}
|
||||||
|
switch (ev) {
|
||||||
|
case 'error':
|
||||||
|
/* falls through */
|
||||||
|
case 'warning':
|
||||||
|
console.error(
|
||||||
|
'Error%s:',
|
||||||
|
args.context ? ' ' + args.context : ''
|
||||||
|
);
|
||||||
|
console.error(args.message);
|
||||||
|
if (args.description) {
|
||||||
|
console.error(args.description);
|
||||||
|
}
|
||||||
|
if (args.code) {
|
||||||
|
console.error('code:', args.code);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (/status/.test(ev)) {
|
||||||
|
console.info(
|
||||||
|
ev,
|
||||||
|
args.altname || args.subject || '',
|
||||||
|
args.status || ''
|
||||||
|
);
|
||||||
|
if (!args.status) {
|
||||||
|
console.log(args);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.info(
|
||||||
|
ev,
|
||||||
|
'(more info available: ' + Object.keys(args).join(' ') + ')'
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
manage.errors = function(err) {
|
manage.errors = function(err) {
|
||||||
|
|
Loading…
Reference in New Issue