diff --git a/app.js b/app.js index 1ba30c2e7..aa1cfc396 100644 --- a/app.js +++ b/app.js @@ -10,6 +10,7 @@ ======================================================================== **/ +var _ = require('lodash') var async = require('async') var path = require('path') var fs = require('fs') @@ -168,9 +169,9 @@ function launchServer (db) { winston.debug('Starting MailCheck...') mailCheck.init(settings) }) + } else { + return next() } - - return next() }) }, function (next) { @@ -221,9 +222,23 @@ function launchServer (db) { if (process.env.MEMORYLIMIT) { memLimit = process.env.MEMORYLIMIT } + + var env = { FORK: 1, NODE_ENV: global.env } + if (isDocker) { + var envDocker = { + TD_MONGODB_SERVER: process.env.TD_MONGODB_SERVER, + TD_MONGODB_PORT: process.env.TD_MONGODB_PORT, + TD_MONGODB_USERNAME: process.env.TD_MONGODB_USERNAME, + TD_MONGODB_PASSWORD: process.env.TD_MONGODB_PASSWORD, + TD_MONGODB_DATABASE: process.env.TD_MONGODB_DATABASE + } + + env = _.merge(env, envDocker) + } + var n = fork(path.join(__dirname, '/src/cache/index.js'), { execArgv: ['--max-old-space-size=' + memLimit], - env: { FORK: 1, NODE_ENV: global.env } + env: env }) global.forks.push({ name: 'cache', fork: n }) @@ -271,4 +286,4 @@ function dbCallback (err, db) { } } -if (configExists || isDocker) start() +if (!nconf.get('install') && (configExists || isDocker)) start() diff --git a/src/controllers/install.js b/src/controllers/install.js index 7707964a8..677d3d309 100644 --- a/src/controllers/install.js +++ b/src/controllers/install.js @@ -29,6 +29,7 @@ installController.index = function (req, res) { content.layout = false content.bottom = 'Trudesk v' + pkg.version + content.isDocker = process.env.TRUDESK_DOCKER || false res.render('install', content) } @@ -298,6 +299,24 @@ installController.install = function (req, res) { }) }, function (next) { + if (!process.env.TRUDESK_DOCKER) return next() + var S = require('../models/setting') + var installed = new S({ + name: 'installed', + value: true + }) + + installed.save(function (err) { + if (err) { + winston.error('DB Error: ' + err.message) + return next('DB Error: ' + err.message) + } + + return next() + }) + }, + function (next) { + if (process.env.TRUDESK_DOCKER) return next() // Write Configfile var fs = require('fs') var configFile = path.join(__dirname, '../../config.json') diff --git a/src/database/index.js b/src/database/index.js index bdee3692f..d8872f969 100644 --- a/src/database/index.js +++ b/src/database/index.js @@ -19,11 +19,11 @@ var winston = require('winston') var db = {} var mongoConnectionUri = { - server: process.env.MONGODB_SERVER || nconf.get('mongo:host'), - port: process.env.MONGODB_PORT || nconf.get('mongo:port') || '27017', - username: process.env.MONGODB_USERNAME || nconf.get('mongo:username'), - password: process.env.MONGODB_PASSWORD || nconf.get('mongo:password'), - database: process.env.MONGODB_DATABASE ? 'trudesk_' + process.env.MONGODB_DATABASE : nconf.get('mongo:database') + server: process.env.TD_MONGODB_SERVER || nconf.get('mongo:host'), + port: process.env.TD_MONGODB_PORT || nconf.get('mongo:port') || '27017', + username: process.env.TD_MONGODB_USERNAME || nconf.get('mongo:username'), + password: process.env.TD_MONGODB_PASSWORD || nconf.get('mongo:password'), + database: process.env.TD_MONGODB_DATABASE ? 'trudesk_' + process.env.MONGODB_DATABASE : nconf.get('mongo:database') } var CONNECTION_URI = '' diff --git a/src/helpers/hbs/helpers.js b/src/helpers/hbs/helpers.js index 6522bcce5..bf51476cc 100644 --- a/src/helpers/hbs/helpers.js +++ b/src/helpers/hbs/helpers.js @@ -617,6 +617,12 @@ var helpers = { return options.inverse(this) }, + isNot: function (obj, options) { + if (!(_.isUndefined(obj) || _.isNull(obj) || obj === true)) return options.fn(this) + + return options.inverse(this) + }, + split: function (arr, sep) { var str = '' _.each(arr, function (obj) { diff --git a/src/migration/index.js b/src/migration/index.js index 1fcd0359e..8dfbf4128 100644 --- a/src/migration/index.js +++ b/src/migration/index.js @@ -122,6 +122,8 @@ migrations.run = function (callback) { getDatabaseVersion(function (err, dbVer) { if (err) return next(err) if (semver.satisfies(dbVer, '1.0.6')) migrateUserRoles(next) + + return next() }) } ], diff --git a/src/views/install.hbs b/src/views/install.hbs index faf804177..7343e97a8 100644 --- a/src/views/install.hbs +++ b/src/views/install.hbs @@ -276,38 +276,40 @@ -