Reverted the last update to web installer, and updated it so environment variables always take precedence over form input, and form is hidden if database value is passed in

v1.18.x
Julian Lam 10 years ago
parent 5487da9030
commit 275a9ef476

@ -65,10 +65,7 @@ function welcome(req, res) {
res.render('install/index', {
databases: databases,
dbBool: {
redis: nconf.get('database') === 'redis',
mongo: nconf.get('database') === 'mongo'
},
skipDatabaseSetup: !!nconf.get('database'),
error: res.locals.error ? true : false,
success: res.locals.success ? true : false,
values: req.body
@ -76,16 +73,14 @@ function welcome(req, res) {
}
function install(req, res) {
var env = {};
for (var i in req.body) {
if (req.body.hasOwnProperty(i)) {
env[i.replace(':', '__')] = req.body[i];
if (req.body.hasOwnProperty(i) && !process.env.hasOwnProperty(i)) {
process.env[i.replace(':', '__')] = req.body[i];
}
}
var child = require('child_process').fork('app', ['--setup'], {
env: env
env: process.env
});
child.on('close', function(data) {

@ -89,6 +89,7 @@
<a id="database-error"></a>
<!-- ENDIF error -->
<!-- IF !skipDatabaseSetup -->
<div class="database">
<p>
<h1><small>Configure your database</small></h1>
@ -99,8 +100,8 @@
<div class="col-sm-7 col-xs-12 input-field">
<label for="database">Database Type</label>
<select class="form-control" name="database">
<option value="redis"<!-- IF dbBool.redis --> selected<!-- ENDIF dbBool.redis-->>Redis</option>
<option value="mongo"<!-- IF dbBool.mongo --> selected<!-- ENDIF dbBool.mongo-->>MongoDB</option>
<option value="redis">Redis</option>
<option value="mongo">MongoDB</option>
</select>
</div>
<div class="col-sm-5 help-text" data-help="Leave the fields blank to use the default settings."><!-- IF error -->There was an error connecting to your database. Please try again.<!-- ENDIF error --></div>
@ -108,6 +109,7 @@
<div id="database-config"></div>
</div>
<!-- ENDIF !skipDatabaseSetup -->
<button id="submit" type="submit" class="btn btn-lg btn-success">Install NodeBB <i class="fa fa-spinner fa-spin hide"></i></button>
</form>

Loading…
Cancel
Save