v1.18.x
Julian Lam 12 years ago
parent b8b6558f53
commit e32494879c

@ -18,13 +18,12 @@
// Configuration setup // Configuration setup
nconf = require('nconf'); nconf = require('nconf');
nconf.argv().file({ file: __dirname + '/config.json'}); nconf.argv();
var fs = require('fs'), var fs = require('fs'),
winston = require('winston'), winston = require('winston'),
pkg = require('./package.json'), pkg = require('./package.json'),
url = require('url'), url = require('url');
meta = require('./src/meta.js');
// Runtime environment // Runtime environment
global.env = process.env.NODE_ENV || 'production'; global.env = process.env.NODE_ENV || 'production';
@ -52,7 +51,12 @@ winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
winston.info(''); winston.info('');
if (!nconf.get('setup') && !nconf.get('upgrade') && nconf.get('base_url')) { if (!fs.existsSync(__dirname + '/config.json') || (!nconf.get('setup') && !nconf.get('upgrade'))) {
// Load server-side config
nconf.file({ file: __dirname + '/config.json'});
var meta = require('./src/meta.js');
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/'); nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/');
nconf.set('upload_url', nconf.get('url') + 'uploads/'); nconf.set('upload_url', nconf.get('url') + 'uploads/');
@ -89,6 +93,10 @@ if (!nconf.get('setup') && !nconf.get('upgrade') && nconf.get('base_url')) {
}); });
} else if (nconf.get('upgrade')) { } else if (nconf.get('upgrade')) {
var meta = require('./src/meta.js');
nconf.file({ file: __dirname + '/config.json'});
meta.configs.init(function() { meta.configs.init(function() {
require('./src/upgrade').upgrade(); require('./src/upgrade').upgrade();
}); });
@ -97,8 +105,10 @@ if (!nconf.get('setup') && !nconf.get('upgrade') && nconf.get('base_url')) {
if (nconf.get('setup')) winston.info('NodeBB Setup Triggered via Command Line'); if (nconf.get('setup')) winston.info('NodeBB Setup Triggered via Command Line');
else winston.warn('Configuration not found, starting NodeBB setup'); else winston.warn('Configuration not found, starting NodeBB setup');
meta.config = {}; var install = require('./src/install'),
var install = require('./src/install'); meta = {
config: {}
};
winston.info('Welcome to NodeBB!'); winston.info('Welcome to NodeBB!');
winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.'); winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');

@ -3,16 +3,9 @@ var async = require('async'),
fs = require('fs'), fs = require('fs'),
url = require('url'), url = require('url'),
path = require('path'), path = require('path'),
meta = require('./meta'),
User = require('./user'),
Groups = require('./groups'),
Categories = require('./categories'),
Plugins = require('./plugins'),
prompt = require('prompt'), prompt = require('prompt'),
admin = {
categories: require('./admin/categories')
},
winston = require('winston'), winston = require('winston'),
reds = require('reds'),
install = { install = {
questions: [ questions: [
@ -97,21 +90,29 @@ 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;
meta.configs.set('postDelay', 10000);
meta.configs.set('minimumPostLength', 8);
meta.configs.set('minimumTitleLength', 3);
meta.configs.set('minimumUsernameLength', 2);
meta.configs.set('maximumUsernameLength', 16);
meta.configs.set('minimumPasswordLength', 6);
meta.configs.set('imgurClientID', '');
install.save(server_conf, client_conf, next); install.save(server_conf, client_conf, next);
}); });
}, },
function(next) {
// Applying default database configs
var meta = require('./meta');
meta.configs.set('postDelay', 10000);
meta.configs.set('minimumPostLength', 8);
meta.configs.set('minimumTitleLength', 3);
meta.configs.set('minimumUsernameLength', 2);
meta.configs.set('maximumUsernameLength', 16);
meta.configs.set('minimumPasswordLength', 6);
meta.configs.set('imgurClientID', '');
meta.configs.init(next);
},
function(next) { function(next) {
// Check if an administrator needs to be created // Check if an administrator needs to be created
var Groups = require('./groups');
Groups.getGidFromName('Administrators', function(err, gid) { Groups.getGidFromName('Administrators', function(err, gid) {
if (err) return next(new Error('Could not save configs')); if (err) return next(err.message);
if (gid) { if (gid) {
Groups.get(gid, {}, function(err, groupObj) { Groups.get(gid, {}, function(err, groupObj) {
@ -125,6 +126,11 @@ var async = require('async'),
}, },
function(next) { function(next) {
// Categories // Categories
var Categories = require('./categories'),
admin = {
categories: require('./admin/categories')
};
categories.getAllCategories(function(data) { categories.getAllCategories(function(data) {
if (data.categories.length === 0) { if (data.categories.length === 0) {
winston.warn('No categories found, populating instance with default categories') winston.warn('No categories found, populating instance with default categories')
@ -147,6 +153,8 @@ var async = require('async'),
}, },
function(next) { function(next) {
// Default plugins // Default plugins
var Plugins = require('./plugins');
winston.info('Enabling default plugins'); winston.info('Enabling default plugins');
var defaultEnabled = [ var defaultEnabled = [
@ -171,6 +179,9 @@ var async = require('async'),
}); });
}, },
createAdmin: function(callback) { createAdmin: function(callback) {
var User = require('./user'),
Groups = require('./groups');
winston.warn('No administrators have been detected, running initial user setup'); winston.warn('No administrators have been detected, running initial user setup');
var questions = [ var questions = [
{ {
@ -233,6 +244,14 @@ var async = require('async'),
} }
], function(err) { ], function(err) {
winston.info('Configuration Saved OK'); winston.info('Configuration Saved OK');
nconf.file({ file: path.join(__dirname, '..', 'config.json') });
var RDB = require('./redis');
reds.createClient = function() {
return reds.client || (reds.client = RDB);
}
callback(err); callback(err);
}); });
} }

@ -1,6 +1,5 @@
(function(RedisDB) { (function(RedisDB) {
var redis = require('redis'), var redis = require('redis'),
nconf = require('nconf'),
utils = require('./../public/src/utils.js'), utils = require('./../public/src/utils.js'),
winston = require('winston'); winston = require('winston');

Loading…
Cancel
Save