mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 18:23:09 +00:00
f488b1811b
Added extra config options to allow reading passwords from file rather than the world-readable nix store. The full config.json file is created at service startup. Relevant to #18881
24 lines
625 B
JavaScript
24 lines
625 B
JavaScript
var fs = require('fs');
|
|
|
|
var opts = JSON.parse(fs.readFileSync("/dev/stdin").toString());
|
|
var config = opts.config;
|
|
|
|
var readSecret = function(filename) {
|
|
return fs.readFileSync(filename).toString().trim();
|
|
};
|
|
|
|
if (opts.secretFile) {
|
|
config.secret = readSecret(opts.secretFile);
|
|
}
|
|
if (opts.dbPasswordFile) {
|
|
config.params.dbpass = readSecret(opts.dbPasswordFile);
|
|
}
|
|
if (opts.smtpPasswordFile) {
|
|
config.smtppass = readSecret(opts.smtpPasswordFile);
|
|
}
|
|
if (opts.spamClientSecretFile) {
|
|
config.spamclientsecret = readSecret(opts.opts.spamClientSecretFile);
|
|
}
|
|
|
|
fs.writeFileSync(opts.outputFile, JSON.stringify(config));
|