From 4c2f628baa50632dc0cb7cec55f07de3b9b653ea Mon Sep 17 00:00:00 2001 From: ahwayakchih Date: Wed, 25 Feb 2015 22:27:19 +0100 Subject: [PATCH 1/2] Added support for using `mongo:password` and `redis:password` from config, when no password is entered at setup. This allows for having "default" password and overrides from config. Added using `mongo:username` and `port` from config when running setup. --- src/database/mongo.js | 6 ++++-- src/database/redis.js | 3 ++- src/install.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/database/mongo.js b/src/database/mongo.js index 0e69c12380..a13cb5dedf 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -22,12 +22,14 @@ }, { name: 'mongo:username', - description: 'MongoDB username' + description: 'MongoDB username', + 'default': nconf.get('mongo:username') || '' }, { name: 'mongo:password', description: 'Password of your MongoDB database', - hidden: true + hidden: true, + before: function(value) { value = value || nconf.get('mongo:password') || ''; return value; } }, { name: "mongo:database", diff --git a/src/database/redis.js b/src/database/redis.js index 727705c130..156131a80d 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -28,7 +28,8 @@ { name: 'redis:password', description: 'Password of your Redis database', - hidden: true + hidden: true, + before: function(value) { value = value || nconf.get('redis:password') || ''; return value; } }, { name: "redis:database", diff --git a/src/install.js b/src/install.js index d3df90b267..a586f5f1b2 100644 --- a/src/install.js +++ b/src/install.js @@ -47,7 +47,7 @@ questions.main = [ questions.optional = [ { name: 'port', - default: 4567 + default: nconf.get('port') || 4567 } ]; From 7ed41a1f60497b2a4b7502862b7fd07c70816977 Mon Sep 17 00:00:00 2001 From: ahwayakchih Date: Thu, 26 Feb 2015 17:39:23 +0100 Subject: [PATCH 2/2] Set separator for loading environment variables to `nconf`, as discussed on https://github.com/NodeBB/NodeBB/pull/2778#issuecomment-76209393 --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index ef113e5ece..1299cfdf4a 100644 --- a/app.js +++ b/app.js @@ -21,7 +21,7 @@ /*global require, global, process*/ var nconf = require('nconf'); -nconf.argv().env(); +nconf.argv().env('__'); var fs = require('fs'), os = require('os'),