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

@ -18,13 +18,12 @@
// Configuration setup
nconf = require('nconf');
nconf.argv().file({ file: __dirname + '/config.json'});
nconf.argv();
var fs = require('fs'),
winston = require('winston'),
pkg = require('./package.json'),
url = require('url'),
meta = require('./src/meta.js');
url = require('url');
// Runtime environment
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('');
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('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')) {
var meta = require('./src/meta.js');
nconf.file({ file: __dirname + '/config.json'});
meta.configs.init(function() {
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');
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('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'),
url = require('url'),
path = require('path'),
meta = require('./meta'),
User = require('./user'),
Groups = require('./groups'),
Categories = require('./categories'),
Plugins = require('./plugins'),
prompt = require('prompt'),
admin = {
categories: require('./admin/categories')
},
winston = require('winston'),
reds = require('reds'),
install = {
questions: [
@ -97,6 +90,13 @@ var async = require('async'),
server_conf.base_url = protocol + '//' + host;
server_conf.relative_path = relative_path;
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);
@ -105,13 +105,14 @@ var async = require('async'),
meta.configs.set('minimumPasswordLength', 6);
meta.configs.set('imgurClientID', '');
install.save(server_conf, client_conf, next);
});
meta.configs.init(next);
},
function(next) {
// Check if an administrator needs to be created
var Groups = require('./groups');
Groups.getGidFromName('Administrators', function(err, gid) {
if (err) return next(new Error('Could not save configs'));
if (err) return next(err.message);
if (gid) {
Groups.get(gid, {}, function(err, groupObj) {
@ -125,6 +126,11 @@ var async = require('async'),
},
function(next) {
// Categories
var Categories = require('./categories'),
admin = {
categories: require('./admin/categories')
};
categories.getAllCategories(function(data) {
if (data.categories.length === 0) {
winston.warn('No categories found, populating instance with default categories')
@ -147,6 +153,8 @@ var async = require('async'),
},
function(next) {
// Default plugins
var Plugins = require('./plugins');
winston.info('Enabling default plugins');
var defaultEnabled = [
@ -171,6 +179,9 @@ var async = require('async'),
});
},
createAdmin: function(callback) {
var User = require('./user'),
Groups = require('./groups');
winston.warn('No administrators have been detected, running initial user setup');
var questions = [
{
@ -233,6 +244,14 @@ var async = require('async'),
}
], function(err) {
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);
});
}

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

Loading…
Cancel
Save