forked from Toroid-io/wekan-gogs
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
57 lines (49 loc) · 1.7 KB
/
main.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
var server = require('./server.js')
, fs = require('fs');
const exec = require('child_process').exec;
var main = function() {
var config = {};
if (!process.env.WG_URL ||
!process.env.WG_GOGS_URL ||
!process.env.WG_GOGS_USERNAME ||
!process.env.WG_GOGS_PASSWORD ||
!process.env.WG_WEKAN_URL ||
!process.env.WG_WEKAN_USERNAME ||
!process.env.WG_WEKAN_PASSWORD) {
console.log('Please set up all environment variables before execution');
process.exit(1);
}
// Optional parameters
config.cli = (process.env.WG_CLI)?true:false;
config.gogs_token = (process.env.WG_GOGS_TOKEN)?process.env.WG_GOGS_TOKEN:null;
// Required parameters
config.gogs_url = process.env.WG_GOGS_URL;
config.gogs_username = process.env.WG_GOGS_USERNAME;
config.gogs_password = process.env.WG_GOGS_PASSWORD;
config.wekan_url = process.env.WG_WEKAN_URL;
config.wekan_username = process.env.WG_WEKAN_USERNAME;
config.wekan_password = process.env.WG_WEKAN_PASSWORD;
config.wekangogs_url = process.env.WG_URL;
require('./wekan-gogs.js')(config, function(err, w2g) {
if (err) {
console.log(err);
process.exit(1);
} else {
server.run(w2g);
}
});
}
fs.stat('/wekan-gogs/data/wekan-gogs.db', function(err, stat) {
if (!err) {
main();
} else if (err.code == 'ENOENT') {
// Create database
exec('cat wekan-gogs.sqlite | sqlite3 data/wekan-gogs.db', function(err) {
if (err != null) {
console.log('Error creating database: ', err);
process.exit(1);
}
main();
});
}
});