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) {
redisClient.hset(key, field, value, callback)
redisClient.hset(key, field, value, callback);
}
module.getObject = function(key, callback) {

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

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

@ -275,9 +275,9 @@ var fs = require('fs'),
}
// Reload meta data
plugins.reload(function() {
Plugins.reload(function() {
// (De)activation Hooks
plugins.fireHook('action:plugin.' + (active ? 'de' : '') + 'activate', id);
Plugins.fireHook('action:plugin.' + (active ? 'de' : '') + 'activate', id);
if (callback) {
callback({
@ -326,7 +326,9 @@ var fs = require('fs'),
}
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.hooks;

Loading…
Cancel
Save