|
|
|
@ -6,7 +6,7 @@ var async = require('async'),
|
|
|
|
|
prompt = require('prompt'),
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
reds = require('reds'),
|
|
|
|
|
nconf = require('nconf');
|
|
|
|
|
nconf = require('nconf'),
|
|
|
|
|
|
|
|
|
|
install = {
|
|
|
|
|
questions: [{
|
|
|
|
@ -50,7 +50,9 @@ var async = require('async'),
|
|
|
|
|
prompt.delimiter = '';
|
|
|
|
|
|
|
|
|
|
prompt.get(install.questions, function (err, config) {
|
|
|
|
|
if (!config) return next(new Error('aborted'));
|
|
|
|
|
if (!config) {
|
|
|
|
|
return next(new Error('aborted'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Translate redis properties into redis object
|
|
|
|
|
config.redis = {
|
|
|
|
@ -63,9 +65,9 @@ var async = require('async'),
|
|
|
|
|
delete config['redis:password'];
|
|
|
|
|
|
|
|
|
|
// Add hardcoded values
|
|
|
|
|
config['bcrypt_rounds'] = 12,
|
|
|
|
|
config['upload_path'] = '/public/uploads';
|
|
|
|
|
config['use_port'] = (config['use_port'].slice(0, 1) === 'y') ? true : false;
|
|
|
|
|
config.bcrypt_rounds = 12;
|
|
|
|
|
config.upload_path = '/public/uploads';
|
|
|
|
|
config.use_port = (config.use_port.slice(0, 1) === 'y') ? true : false;
|
|
|
|
|
|
|
|
|
|
var urlObject = url.parse(config.base_url),
|
|
|
|
|
relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '',
|
|
|
|
@ -88,7 +90,7 @@ var async = require('async'),
|
|
|
|
|
},
|
|
|
|
|
function (next) {
|
|
|
|
|
// Applying default database configs
|
|
|
|
|
winston.info('Populating database with default configs, if not already set...')
|
|
|
|
|
winston.info('Populating database with default configs, if not already set...');
|
|
|
|
|
var meta = require('./meta'),
|
|
|
|
|
defaults = [{
|
|
|
|
|
field: 'postDelay',
|
|
|
|
@ -124,16 +126,22 @@ var async = require('async'),
|
|
|
|
|
var Groups = require('./groups');
|
|
|
|
|
|
|
|
|
|
Groups.getGidFromName('Administrators', function (err, gid) {
|
|
|
|
|
if (err) return next(err.message);
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gid) {
|
|
|
|
|
Groups.get(gid, {}, function (err, groupObj) {
|
|
|
|
|
if (groupObj.count > 0) {
|
|
|
|
|
winston.info('Administrator found, skipping Admin setup');
|
|
|
|
|
next();
|
|
|
|
|
} else install.createAdmin(next);
|
|
|
|
|
} else {
|
|
|
|
|
install.createAdmin(next);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else install.createAdmin(next);
|
|
|
|
|
} else {
|
|
|
|
|
install.createAdmin(next);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
function (next) {
|
|
|
|
@ -143,9 +151,9 @@ var async = require('async'),
|
|
|
|
|
categories: require('./admin/categories')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
categories.getAllCategories(function(data) {
|
|
|
|
|
Categories.getAllCategories(function (data) {
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
fs.readFile(path.join(__dirname, '../', 'install/data/categories.json'), function (err, default_categories) {
|
|
|
|
|
default_categories = JSON.parse(default_categories);
|
|
|
|
@ -153,8 +161,11 @@ var async = require('async'),
|
|
|
|
|
async.eachSeries(default_categories, function (category, next) {
|
|
|
|
|
admin.categories.create(category, next);
|
|
|
|
|
}, function (err) {
|
|
|
|
|
if (!err) next();
|
|
|
|
|
else winston.error('Could not set up categories');
|
|
|
|
|
if (!err) {
|
|
|
|
|
next();
|
|
|
|
|
} else {
|
|
|
|
|
winston.error('Could not set up categories');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
@ -179,15 +190,19 @@ var async = require('async'),
|
|
|
|
|
Plugins.toggleActive(pluginId, function () {
|
|
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
} else next();
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, next);
|
|
|
|
|
}
|
|
|
|
|
], function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
winston.warn('NodeBB Setup Aborted.');
|
|
|
|
|
process.exit();
|
|
|
|
|
} else callback();
|
|
|
|
|
} else {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
createAdmin: function (callback) {
|
|
|
|
@ -214,7 +229,9 @@ var async = require('async'),
|
|
|
|
|
}],
|
|
|
|
|
getAdminInfo = function (callback) {
|
|
|
|
|
prompt.get(questions, function (err, results) {
|
|
|
|
|
if (!results) return callback(new Error('aborted'));
|
|
|
|
|
if (!results) {
|
|
|
|
|
return callback(new Error('aborted'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nconf.set('bcrypt_rounds', 12);
|
|
|
|
|
User.create(results.username, results.password, results.email, function (err, uid) {
|
|
|
|
@ -224,8 +241,9 @@ var async = require('async'),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Groups.getGidFromName('Administrators', function (err, gid) {
|
|
|
|
|
if (gid) Groups.join(gid, uid, callback);
|
|
|
|
|
else {
|
|
|
|
|
if (gid) {
|
|
|
|
|
Groups.join(gid, uid, callback);
|
|
|
|
|
} else {
|
|
|
|
|
Groups.create('Administrators', 'Forum Administrators', function (err, groupObj) {
|
|
|
|
|
Groups.join(groupObj.gid, uid, callback);
|
|
|
|
|
});
|
|
|
|
@ -260,7 +278,7 @@ var async = require('async'),
|
|
|
|
|
var RDB = require('./redis');
|
|
|
|
|
reds.createClient = function () {
|
|
|
|
|
return reds.client || (reds.client = RDB);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|