updated install

v1.18.x
Baris Soner Usakli 11 years ago
parent 1325e4c501
commit b215dbde19

@ -163,7 +163,7 @@
} }
module.setObjectField = function(key, field, value, callback) { module.setObjectField = function(key, field, value, callback) {
redisClient.hset(key, field, value, callback) redisClient.hset(key, field, value, callback);
} }
module.getObject = function(key, callback) { module.getObject = function(key, callback) {

@ -32,6 +32,15 @@ var async = require('async'),
description: 'Please enter a NodeBB secret', description: 'Please enter a NodeBB secret',
'default': nconf.get('secret') || utils.generateUUID() 'default': nconf.get('secret') || utils.generateUUID()
}, { }, {
name: 'bind_address',
description: 'IP or Hostname to bind to',
'default': nconf.get('bind_address') || '0.0.0.0'
}, {
name: 'database',
description: 'Which database to use',
'default': nconf.get('database') || 'redis'
}],
redisQuestions : [{
name: 'redis:host', name: 'redis:host',
description: 'Host IP or address of your Redis instance', description: 'Host IP or address of your Redis instance',
'default': nconf.get('redis:host') || '127.0.0.1' 'default': nconf.get('redis:host') || '127.0.0.1'
@ -46,11 +55,24 @@ var async = require('async'),
name: "redis:database", name: "redis:database",
description: "Which database to use (0..n)", description: "Which database to use (0..n)",
'default': nconf.get('redis:database') || 0 'default': nconf.get('redis:database') || 0
}],
mongoQuestions : [{
name: 'mongo:host',
description: 'Host IP or address of your MongoDB instance',
'default': nconf.get('mongo:host') || '127.0.0.1'
}, { }, {
name: 'bind_address', name: 'mongo:port',
description: 'IP or Hostname to bind to', description: 'Host port of your MongoDB instance',
'default': nconf.get('bind_address') || '0.0.0.0' 'default': nconf.get('mongo:port') || 27017
}, {
name: 'mongo:password',
description: 'Password of your MongoDB database'
}, {
name: "mongo:database",
description: "Which database to use (0..n)",
'default': nconf.get('mongo:database') || 0
}], }],
setup: function (callback) { setup: function (callback) {
async.series([ async.series([
function(next) { function(next) {
@ -74,7 +96,9 @@ var async = require('async'),
if (!setupVal['admin:email']) winston.error(' admin:email'); if (!setupVal['admin:email']) winston.error(' admin:email');
process.exit(); process.exit();
} }
} else next(); } else {
next();
}
}, },
function (next) { function (next) {
var success = function(err, config) { var success = function(err, config) {
@ -82,17 +106,27 @@ var async = require('async'),
return next(new Error('aborted')); return next(new Error('aborted'));
} }
function dbQuestionsSuccess(err, databaseConfig) {
if (!config) {
return next(new Error('aborted'));
}
// Translate redis properties into redis object // Translate redis properties into redis object
if(config.database === 'redis') {
config.redis = { config.redis = {
host: config['redis:host'], host: databaseConfig['redis:host'],
port: config['redis:port'], port: databaseConfig['redis:port'],
password: config['redis:password'], password: databaseConfig['redis:password'],
database: config['redis:database'] database: databaseConfig['redis:database']
};
} else if (config.database === 'mongo') {
config.mongo = {
host: databaseConfig['mongo:host'],
port: databaseConfig['mongo:port'],
password: databaseConfig['mongo:password'],
database: databaseConfig['mongo:database']
}; };
delete config['redis:host']; }
delete config['redis:port'];
delete config['redis:password'];
delete config['redis:database'];
// Add hardcoded values // Add hardcoded values
config.bcrypt_rounds = 12; config.bcrypt_rounds = 12;
@ -111,7 +145,15 @@ var async = require('async'),
server_conf.base_url = protocol + '//' + host; server_conf.base_url = protocol + '//' + host;
server_conf.relative_path = relative_path; server_conf.relative_path = relative_path;
install.save(server_conf, client_conf, next); install.save(server_conf, client_conf, function(err) {
require('./database').init(next);
});
}
if(config.database === 'redis')
prompt.get(install.redisQuestions, dbQuestionsSuccess);
else if(config.database === 'mongo')
prompt.get(install.mongoQuestions, dbQuestionsSuccess);
}; };
// prompt prepends "prompt: " to questions, let's clear that. // prompt prepends "prompt: " to questions, let's clear that.
@ -119,8 +161,9 @@ var async = require('async'),
prompt.message = ''; prompt.message = '';
prompt.delimiter = ''; prompt.delimiter = '';
if (!install.values) prompt.get(install.questions, success); if (!install.values) {
else { prompt.get(install.questions, success);
} else {
// Use provided values, fall back to defaults // Use provided values, fall back to defaults
var config = {}, var config = {},
question, x, numQ; question, x, numQ;
@ -176,6 +219,7 @@ var async = require('async'),
async.each(defaults, function (configObj, next) { async.each(defaults, function (configObj, next) {
meta.configs.setOnEmpty(configObj.field, configObj.value, next); meta.configs.setOnEmpty(configObj.field, configObj.value, next);
}, function (err) { }, function (err) {
console.log('calling meta.configs.init');
meta.configs.init(next); meta.configs.init(next);
}); });
}, },
@ -343,8 +387,9 @@ var async = require('async'),
// Add the password questions // Add the password questions
questions = questions.concat(passwordQuestions); questions = questions.concat(passwordQuestions);
if (!install.values) prompt.get(questions, success); if (!install.values) {
else { prompt.get(questions, success);
} else {
var results = { var results = {
username: install.values['admin:username'], username: install.values['admin:username'],
email: install.values['admin:email'], email: install.values['admin:email'],

@ -44,7 +44,7 @@ var fs = require('fs'),
db.getObjectFields('config', fields, callback); db.getObjectFields('config', fields, callback);
}, },
set: function (field, value, callback) { set: function (field, value, callback) {
db.setObjectField(field, value, function(err, res) { db.setObjectField('config', field, value, function(err, res) {
if (callback) { if (callback) {
if(!err && Meta.config) if(!err && Meta.config)
Meta.config[field] = value; Meta.config[field] = value;
@ -53,7 +53,7 @@ var fs = require('fs'),
}); });
}, },
setOnEmpty: function (field, value, callback) { setOnEmpty: function (field, value, callback) {
this.get(field, function (err, curValue) { Meta.configs.get(field, function (err, curValue) {
if (!curValue) { if (!curValue) {
Meta.configs.set(field, value, callback); Meta.configs.set(field, value, callback);
} else { } else {

@ -275,9 +275,9 @@ var fs = require('fs'),
} }
// Reload meta data // Reload meta data
plugins.reload(function() { Plugins.reload(function() {
// (De)activation Hooks // (De)activation Hooks
plugins.fireHook('action:plugin.' + (active ? 'de' : '') + 'activate', id); Plugins.fireHook('action:plugin.' + (active ? 'de' : '') + 'activate', id);
if (callback) { if (callback) {
callback({ callback({
@ -326,7 +326,9 @@ var fs = require('fs'),
} }
Plugins.isActive(config.id, function(err, active) { Plugins.isActive(config.id, function(err, active) {
if (err) next(new Error('no-active-state')); if (err) {
next(new Error('no-active-state'));
}
delete config.library; delete config.library;
delete config.hooks; delete config.hooks;

Loading…
Cancel
Save