-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
84 lines (70 loc) · 2.5 KB
/
install.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*jslint node: true */
var logger = require('log4js').getLogger('Installer'),
fs = require('fs'),
nconf = require('nconf');
(function (Installation) {
"use strict";
Installation.preload = function () {
nconf.argv().env();
// Alternate configuration file support
var configFile = __dirname + '/config.json',
configExists;
if (nconf.get('config')) {
configFile = path.resolve(__dirname, nconf.get('config'));
}
configExists = fs.existsSync(configFile);
if (!configExists){
logger.error("configuration file doesn't exists");
process.exit(0);
} else {
nconf.file({
file: configFile
});
nconf.defaults({
base_dir: __dirname,
upload_url: '/uploads/'
});
}
return this;
};
Installation.install = function () {
logger.info("Installing");
var user = require("./src/app/model/user"),
groups = require("./src/app/model/groups"),
meta = require('./src/app/meta'),
playlist = require('./src/app/model/playlist');
meta.settings.setOne("global", "requireLogin", "true", function (err) {
if (err) {
logger.debug("userauth error initialising");
}
logger.info("Standard global settings initialised");
});
user.create({email: "[email protected]", username: "admin", password: "admin"}, function (err, uuid) {
if (err) {
logger.error("Error while create user: " + err);
} else {
logger.info("Success create user: " + uuid);
}
user.getUsers(["[email protected]"], function (err, data) {
logger.info("Installed");
});
groups.join("administrators", "[email protected]", function(err){
if (err){
logger.error(err);
}
logger.info("User admin configured as administrator");
});
});
user.create({email: "[email protected]", username: "demo", password: "demo"}, function (err, uuid) {
if (err) {
logger.error("Error while create user: " + err);
} else {
logger.info("Success create user: " + uuid);
user.getUsers(["[email protected]"], function (err, data) {
logger.info("Installed");
});
}
});
};
Installation.preload().install();
}(exports));