@drumee/setup-infra 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-local-certs +38 -0
- package/bin/env +8 -5
- package/bin/init-acme +23 -4
- package/bin/init-named +1 -1
- package/bin/install +28 -4
- package/bin/prosody +21 -12
- package/index.js +314 -218
- package/package.json +2 -2
- package/templates/etc/bind/named.conf.local +39 -0
- package/templates/etc/bind/named.conf.options +13 -4
- package/templates/etc/dhcp/dhclient.conf +55 -0
- package/templates/etc/drumee/certs/jitsi.private.cnf +13 -0
- package/templates/etc/drumee/certs/private.cnf +13 -0
- package/templates/etc/drumee/conf.d/conference.private.json +9 -0
- package/templates/etc/drumee/conf.d/conference.public.json +9 -0
- package/templates/etc/drumee/conf.d/myDrumee.json.tpl +2 -1
- package/templates/etc/drumee/drumee.sh.tpl +32 -17
- package/templates/etc/drumee/infrastructure/internals/accel.private.conf.tpl +47 -0
- package/templates/etc/drumee/infrastructure/internals/{accel.conf.tpl → accel.public.conf.tpl} +1 -1
- package/templates/etc/drumee/infrastructure/{platform.json.tpl → mfs.private.conf.tpl} +5 -5
- package/templates/etc/drumee/infrastructure/{mfs.conf.tpl → mfs.public.conf.tpl} +1 -1
- package/templates/etc/drumee/infrastructure/routes/private.conf.tpl +143 -0
- package/templates/etc/drumee/infrastructure/routes/{main.conf.tpl → public.conf.tpl} +18 -28
- package/templates/etc/drumee/infrastructure/servers/tt.conf +9 -9
- package/templates/etc/drumee/ssl/private.conf.tpl +2 -1
- package/templates/etc/drumee/ssl/public.conf.tpl +1 -1
- package/templates/etc/jitsi/jicofo/jicofo.private.conf.tpl +46 -0
- package/templates/etc/jitsi/jicofo/{jicofo.conf.tpl → jicofo.public.conf.tpl} +7 -7
- package/templates/etc/jitsi/jicofo/sip-cmmunicator.private.properties +3 -0
- package/templates/etc/jitsi/jicofo/sip-cmmunicator.public.properties +3 -0
- package/templates/etc/jitsi/meet.private.conf.tpl +132 -0
- package/templates/etc/jitsi/{meet.conf.tpl → meet.public.conf.tpl} +5 -5
- package/templates/etc/jitsi/ssl.private.conf.tpl +25 -0
- package/templates/etc/jitsi/{ssl.conf.tpl → ssl.public.conf.tpl} +3 -3
- package/templates/etc/jitsi/videobridge/defaults/jvb.conf +1 -1
- package/templates/etc/jitsi/videobridge/jvb.private.conf +67 -0
- package/templates/etc/jitsi/videobridge/{jvb.conf → jvb.public.conf} +6 -6
- package/templates/etc/jitsi/web/config.private.js.tpl +208 -0
- package/templates/etc/jitsi/web/{config.js.tpl → config.public.js.tpl} +4 -4
- package/templates/etc/jitsi/web/defaults/default +2 -2
- package/templates/etc/jitsi/web/defaults/meet.conf +3 -3
- package/templates/etc/mysql/mariadb.conf.d/50-server.cnf +3 -3
- package/templates/etc/nginx/modules-enabled/{90-turn-relay.conf → 90-turn-relay.private.conf.tpl} +6 -6
- package/templates/etc/nginx/modules-enabled/{90-turn-relay.conf.tpl → 90-turn-relay.public.conf.tpl} +4 -4
- package/templates/etc/nginx/nginx.conf +3 -1
- package/templates/etc/nginx/sites-enabled/{public.conf.tpl → 01-public.conf.tpl} +7 -7
- package/templates/etc/nginx/sites-enabled/{private.conf.tpl → 02-private.conf.tpl} +6 -6
- package/templates/etc/nginx/sites-enabled/{jitsi.conf.tpl → 20-jitsi.private.conf.tpl} +9 -9
- package/templates/etc/nginx/sites-enabled/{pivate.jitsi.conf.tpl → 20-jitsi.public.conf.tpl} +9 -9
- package/templates/etc/nginx/sites-enabled/{localhost.conf → loopback.tpl} +10 -9
- package/templates/etc/nginx/sites-enabled/turnrelay.conf.tpl +4 -4
- package/templates/etc/prosody/conf.d/private.cfg.lua.tpl +51 -51
- package/templates/etc/prosody/conf.d/public.cfg.lua.tpl +47 -47
- package/templates/etc/prosody/defaults/conf.d/jitsi-meet.cfg.lua +3 -3
- package/templates/etc/turnserver.private.conf.tpl +46 -0
- package/templates/etc/{turnserver.conf.tpl → turnserver.public.conf.tpl} +3 -3
- package/templates/index.js +3 -2
- package/templates/utils.js +22 -147
- package/templates/var/lib/bind/domain.tpl +70 -0
- package/templates/var/lib/bind/private-reverse.tpl +1 -1
- package/templates/var/lib/bind/{prvate.tpl → private.tpl} +1 -10
- package/templates/var/lib/bind/public-reverse.tpl +7 -7
- package/templates/var/lib/bind/public.tpl +7 -7
- package/bin/init-private +0 -40
- package/bin/set-jitsi-conf +0 -14
- package/template.js +0 -453
- package/templates/etc/bind/named.conf.private +0 -21
- package/templates/etc/bind/named.conf.public +0 -21
- package/templates/etc/drumee/conf.d/conference.json.tpl +0 -9
- package/templates/etc/drumee/dnsapi.sh.tpl +0 -28
- package/templates/etc/drumee/env.json +0 -29
- package/templates/etc/jitsi/jicofo/sip-cmmunicator.properties +0 -3
- package/templates/etc/nginx/sites-enabled/public.jitsi.conf.tpl +0 -28
- package/templates/etc/prosody/conf.d/vhost.cfg.lua.tpl +0 -162
package/index.js
CHANGED
|
@@ -6,23 +6,51 @@ const { join, dirname } = require("path");
|
|
|
6
6
|
const { isString } = require("lodash");
|
|
7
7
|
const { exit } = process;
|
|
8
8
|
const { loadSysEnv, sysEnv, uniqueId } = require("@drumee/server-essentials");
|
|
9
|
-
const { totalmem
|
|
9
|
+
const { totalmem } = require('os');
|
|
10
10
|
const {
|
|
11
|
-
existsSync, close, writeSync, openSync, readFileSync
|
|
11
|
+
existsSync, close, writeSync, openSync, readFileSync
|
|
12
12
|
} = require("fs");
|
|
13
13
|
const { args, hasExistingSettings } = require('./templates/utils')
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
const JSON_OPT = { spaces: 2, EOL: "\r\n" };
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
let {
|
|
19
18
|
ACME_DIR,
|
|
20
19
|
ACME_EMAIL_ACCOUNT,
|
|
20
|
+
ADMIN_EMAIL,
|
|
21
|
+
BACKUP_STORAGE,
|
|
21
22
|
CERTS_DIR,
|
|
23
|
+
DRUMEE_DATA_DIR,
|
|
24
|
+
DRUMEE_DB_DIR,
|
|
25
|
+
DRUMEE_DESCRIPTION,
|
|
26
|
+
DRUMEE_DOMAIN_NAME,
|
|
27
|
+
DRUMEE_HTTP_PORT,
|
|
28
|
+
DRUMEE_LOCAL_PORT,
|
|
29
|
+
DRUMEE_HTTPS_PORT,
|
|
22
30
|
MAIL_USER,
|
|
31
|
+
MAX_BODY_SIZE,
|
|
23
32
|
NSUPDATE_KEY,
|
|
33
|
+
PRIVATE_DOMAIN,
|
|
34
|
+
PRIVATE_IP4,
|
|
35
|
+
PRIVATE_IP6,
|
|
36
|
+
PUBLIC_IP4,
|
|
37
|
+
PRIVATE_IF4,
|
|
38
|
+
PUBLIC_IP6,
|
|
39
|
+
STORAGE_BACKUP,
|
|
40
|
+
INSTANCE_TYPE
|
|
24
41
|
} = process.env;
|
|
25
42
|
|
|
43
|
+
let PUBLIC_DOMAIN = DRUMEE_DOMAIN_NAME;
|
|
44
|
+
|
|
45
|
+
if (PUBLIC_DOMAIN) {
|
|
46
|
+
if (!PRIVATE_DOMAIN) PRIVATE_DOMAIN = PUBLIC_DOMAIN.replace(/\.([a-z_\-0-9]{2,})$/, '.local');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
PRIVATE_DOMAIN = PRIVATE_DOMAIN || 'local.drumee';
|
|
50
|
+
DRUMEE_HTTPS_PORT = DRUMEE_HTTPS_PORT || 443;
|
|
51
|
+
DRUMEE_LOCAL_PORT = DRUMEE_LOCAL_PORT || 8443;
|
|
52
|
+
DRUMEE_HTTP_PORT = DRUMEE_HTTP_PORT || 80;
|
|
53
|
+
|
|
26
54
|
/**
|
|
27
55
|
*
|
|
28
56
|
* @param {*} l
|
|
@@ -101,8 +129,7 @@ function worker(data, instances = 1, exec_mode = 'fork_mode') {
|
|
|
101
129
|
|
|
102
130
|
if (!server_dir) server_dir = join(runtime_dir, 'server');
|
|
103
131
|
let base = `${server_dir}/${route}`;
|
|
104
|
-
|
|
105
|
-
let opt = {
|
|
132
|
+
return {
|
|
106
133
|
name,
|
|
107
134
|
script,
|
|
108
135
|
cwd: base,
|
|
@@ -115,40 +142,8 @@ function worker(data, instances = 1, exec_mode = 'fork_mode') {
|
|
|
115
142
|
},
|
|
116
143
|
dependencies: [`pm2-logrotate`],
|
|
117
144
|
exec_mode,
|
|
118
|
-
instances
|
|
119
|
-
out_file: join(data.log_dir, `log-${iname}.log`),
|
|
120
|
-
error_file: join(data.log_dir, `error-${iname}.log`),
|
|
121
|
-
pm2_log_routes: {
|
|
122
|
-
rotateInterval: '0 0 * * *', // Rotate daily at midnight
|
|
123
|
-
rotateModule: true,
|
|
124
|
-
max_size: '10M', // Rotate when log reaches 10MB
|
|
125
|
-
retain: 30 // Keep 30 rotated logs
|
|
126
|
-
}
|
|
145
|
+
instances
|
|
127
146
|
};
|
|
128
|
-
if (args.watch_dirs) {
|
|
129
|
-
let dirs = args.watch_dirs.split(/,+/);
|
|
130
|
-
if (dirs.length) {
|
|
131
|
-
opt.watch = dirs;
|
|
132
|
-
opt.watch_delay = args.watch_delay;
|
|
133
|
-
if (args.watch_symlinks) {
|
|
134
|
-
opt.watch_options = {
|
|
135
|
-
followSymlinks: true
|
|
136
|
-
}
|
|
137
|
-
} else {
|
|
138
|
-
opt.watch_options = {
|
|
139
|
-
followSymlinks: false
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (args.watch_ignore) {
|
|
143
|
-
let ignored = args.watch_ignore.split(/,+/);
|
|
144
|
-
if (ignored.length) {
|
|
145
|
-
opt.ignore_watch = ignored;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return opt;
|
|
151
|
-
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
/***
|
|
@@ -168,12 +163,19 @@ function writeTemplates(data, targets) {
|
|
|
168
163
|
Template.write(data, out, tpl);
|
|
169
164
|
}
|
|
170
165
|
} catch (e) {
|
|
171
|
-
console.error(e)
|
|
172
|
-
console.error("Failed to write configs for", target)
|
|
166
|
+
console.error("Failed to write configs for", target, e)
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
170
|
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
function isDevInstance() {
|
|
176
|
+
return /^dev/.test(INSTANCE_TYPE)
|
|
177
|
+
}
|
|
178
|
+
|
|
177
179
|
/**
|
|
178
180
|
*
|
|
179
181
|
*/
|
|
@@ -204,9 +206,10 @@ function writeEcoSystem(data) {
|
|
|
204
206
|
script: "./service.js"
|
|
205
207
|
}, instances, 'cluster_mode');
|
|
206
208
|
|
|
209
|
+
|
|
207
210
|
let f = factory(data);
|
|
208
211
|
let routes = [main, main_service, f];
|
|
209
|
-
|
|
212
|
+
|
|
210
213
|
let ecosystem = Template.chroot("etc/drumee/infrastructure/ecosystem.json");
|
|
211
214
|
if (args.readonly) {
|
|
212
215
|
console.log("Readonly", ecosystem, routes);
|
|
@@ -251,7 +254,6 @@ function makeData(opt) {
|
|
|
251
254
|
loadEnvFile(args.env_file, opt)
|
|
252
255
|
}
|
|
253
256
|
data.chroot = Template.chroot();
|
|
254
|
-
data.acme_store = join(data.certs_dir, `${data.domain_name}_ecc`);
|
|
255
257
|
data.ca_server = data.ca_server || data.acme_ssl;
|
|
256
258
|
if (data.own_ssl && data.certs_dir) {
|
|
257
259
|
data.own_certs_dir = data.certs_dir;
|
|
@@ -260,30 +262,43 @@ function makeData(opt) {
|
|
|
260
262
|
let [key, value, fallback] = row;
|
|
261
263
|
if (!value) value = data[key] || fallback;
|
|
262
264
|
if (value == null) continue;
|
|
263
|
-
if (
|
|
265
|
+
if (!data[key]) {
|
|
264
266
|
if (/.+\+$/.test(value)) {
|
|
265
267
|
value = value.replace(/\+$/, data[key]);
|
|
266
268
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
if (isString(value)) {
|
|
270
|
+
data[key] = value.trim() || fallback;
|
|
271
|
+
} else {
|
|
272
|
+
data[key] = value;
|
|
273
|
+
}
|
|
270
274
|
}
|
|
271
275
|
}
|
|
272
276
|
|
|
273
|
-
|
|
274
|
-
data.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
|
|
278
|
+
if (!data.storage_backup) {
|
|
279
|
+
data.storage_backup = ""
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (data.private_domain) {
|
|
283
|
+
data.jitsi_private_domain = `jit.${data.private_domain}`;
|
|
277
284
|
} else {
|
|
278
|
-
data.
|
|
285
|
+
data.jitsi_private_domain = "";
|
|
279
286
|
}
|
|
280
287
|
|
|
281
|
-
if (
|
|
282
|
-
data.
|
|
288
|
+
if (data.public_domain) {
|
|
289
|
+
data.use_email = 1;
|
|
290
|
+
data.jitsi_public_domain = `jit.${data.public_domain}`;
|
|
291
|
+
} else {
|
|
292
|
+
data.use_email = 0;
|
|
293
|
+
data.jitsi_public_domain = "";
|
|
283
294
|
}
|
|
284
295
|
|
|
285
|
-
if (
|
|
286
|
-
data.
|
|
296
|
+
if (isDevInstance()) {
|
|
297
|
+
data.disable_symlinks = 'off';
|
|
298
|
+
data.logLevel = 3;
|
|
299
|
+
} else {
|
|
300
|
+
data.disable_symlinks = 'on';
|
|
301
|
+
data.logLevel = 2;
|
|
287
302
|
}
|
|
288
303
|
return data;
|
|
289
304
|
}
|
|
@@ -294,6 +309,7 @@ function makeData(opt) {
|
|
|
294
309
|
* @param {*} opt
|
|
295
310
|
*/
|
|
296
311
|
function loadEnvFile(file, opt) {
|
|
312
|
+
console.log({ file })
|
|
297
313
|
let src = readJson(file);
|
|
298
314
|
opt.map((r) => {
|
|
299
315
|
let [key] = r;
|
|
@@ -306,57 +322,46 @@ function loadEnvFile(file, opt) {
|
|
|
306
322
|
*
|
|
307
323
|
*/
|
|
308
324
|
function getSysConfigs() {
|
|
325
|
+
let {
|
|
326
|
+
public_domain, private_domain, private_ip4, public_ip4, public_ip6, backup_storage
|
|
327
|
+
} = sysEnv();
|
|
309
328
|
if (hasExistingSettings(Template.chroot('etc/drumee/drumee.json'))) {
|
|
310
329
|
exit(0)
|
|
311
330
|
}
|
|
312
331
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (!args.localhost) {
|
|
318
|
-
console.log("There is no domain name defined for the installation", args);
|
|
319
|
-
exit(0)
|
|
320
|
-
}
|
|
321
|
-
}
|
|
332
|
+
public_domain = args.public_domain || PUBLIC_DOMAIN || public_domain;
|
|
333
|
+
private_domain = args.private_domain || PRIVATE_DOMAIN || private_domain;
|
|
334
|
+
|
|
335
|
+
backup_storage = args.backup_storage || BACKUP_STORAGE || STORAGE_BACKUP || backup_storage;
|
|
322
336
|
|
|
337
|
+
if (!public_domain && !private_domain) {
|
|
338
|
+
console.log("There is no domain name defined for the installation", args);
|
|
339
|
+
exit(0)
|
|
340
|
+
}
|
|
323
341
|
const nsupdate_key = Template.chroot('etc/bind/keys/update.key')
|
|
324
342
|
const opt = [
|
|
343
|
+
["acme_dir", ACME_DIR],
|
|
344
|
+
["acme_email_account", ACME_EMAIL_ACCOUNT, ADMIN_EMAIL],
|
|
345
|
+
["admin_email", ADMIN_EMAIL],
|
|
346
|
+
["backup_storage", backup_storage, ""],
|
|
347
|
+
["certs_dir", CERTS_DIR],
|
|
348
|
+
["data_dir", DRUMEE_DATA_DIR, '/data'],
|
|
349
|
+
["db_dir", DRUMEE_DB_DIR, '/srv/db'],
|
|
350
|
+
["domain_desc", DRUMEE_DESCRIPTION, 'My Drumee Box'],
|
|
351
|
+
["jitsi_root_dir", '/usr/share/jitsi-meet'],
|
|
352
|
+
["max_body_size", MAX_BODY_SIZE, '10G'],
|
|
325
353
|
["nsupdate_key", NSUPDATE_KEY, nsupdate_key],
|
|
326
|
-
["
|
|
327
|
-
["
|
|
328
|
-
["
|
|
329
|
-
["
|
|
330
|
-
["
|
|
331
|
-
["
|
|
332
|
-
["
|
|
333
|
-
["
|
|
334
|
-
["
|
|
335
|
-
["system_group", args.system_group, 'www-data'],
|
|
336
|
-
["backup_storage", args.backup_storage, ""],
|
|
337
|
-
["data_dir", args.data_dir, '/var/lib/drumee/data'],
|
|
338
|
-
["http_port", args.http_port, 80],
|
|
339
|
-
["https_port", args.https_port, 443],
|
|
340
|
-
["verbosity", args.verbosity, 2],
|
|
354
|
+
["private_domain", PRIVATE_DOMAIN],
|
|
355
|
+
["private_ip4", private_ip4],
|
|
356
|
+
["private_port", DRUMEE_LOCAL_PORT],
|
|
357
|
+
["public_domain", public_domain],
|
|
358
|
+
["public_http_port", DRUMEE_HTTP_PORT],
|
|
359
|
+
["public_https_port", DRUMEE_HTTPS_PORT],
|
|
360
|
+
["public_ip4", public_ip4],
|
|
361
|
+
["public_ip6", public_ip6],
|
|
362
|
+
["storage_backup", backup_storage], /** Legacy */
|
|
341
363
|
]
|
|
342
|
-
|
|
343
|
-
if (!args.localhost) {
|
|
344
|
-
opt.push(
|
|
345
|
-
["private_ip4", args.private_ip4],
|
|
346
|
-
["public_domain", args.public_domain],
|
|
347
|
-
["public_ip4", args.public_ip4],
|
|
348
|
-
["public_ip6", args.public_ip6],
|
|
349
|
-
["storage_backup", args.backup_storage], /** Legacy */
|
|
350
|
-
["private_domain", args.private_domain],
|
|
351
|
-
["acme_dir", ACME_DIR],
|
|
352
|
-
["acme_email_account", ACME_EMAIL_ACCOUNT, args.admin_email],
|
|
353
|
-
["certs_dir", CERTS_DIR],
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
364
|
let data = makeData(opt);
|
|
359
|
-
|
|
360
365
|
if (!data) {
|
|
361
366
|
exit(1);
|
|
362
367
|
}
|
|
@@ -377,27 +382,18 @@ function getSysConfigs() {
|
|
|
377
382
|
return configs;
|
|
378
383
|
}
|
|
379
384
|
|
|
385
|
+
/** Settings designed to be used by the backend server */
|
|
386
|
+
configs.domain = public_domain || private_domain;
|
|
387
|
+
configs.public_domain = public_domain;
|
|
388
|
+
configs.private_domain = private_domain;
|
|
389
|
+
configs.main_domain = data.domain;
|
|
390
|
+
configs.domain_name = data.domain;
|
|
391
|
+
configs.log_dir = data.log_dir;
|
|
392
|
+
|
|
380
393
|
configs.socketPath = getSocketPath();
|
|
381
|
-
configs.runtime_dir = join(configs.drumee_root, 'runtime');
|
|
382
|
-
configs.server_dir = join(configs.runtime_dir, 'server');
|
|
383
|
-
configs.server_base = configs.server_dir;
|
|
384
|
-
configs.server_home = join(configs.server_base, 'main');
|
|
385
|
-
configs.server_location = configs.server_home;
|
|
386
|
-
|
|
387
|
-
//console.log(configs)
|
|
388
|
-
configs.ui_dir = join(configs.runtime_dir, 'ui');
|
|
389
|
-
configs.ui_base = join(configs.ui_dir, 'main');
|
|
390
|
-
configs.ui_home = configs.ui_base;
|
|
391
|
-
configs.ui_location = configs.ui_base;
|
|
392
|
-
|
|
393
|
-
configs.tmp_dir = join(configs.runtime_dir, 'tmp');
|
|
394
|
-
configs.static_dir = join(configs.runtime_dir, 'static');
|
|
395
|
-
|
|
396
394
|
let filename = Template.chroot("etc/drumee/drumee.json");
|
|
397
|
-
console.log("Writing main conf into drumee.json", filename);
|
|
398
395
|
Template.makedir(dirname(filename));
|
|
399
396
|
writeFileSync(filename, configs, JSON_OPT);
|
|
400
|
-
console.log(configs)
|
|
401
397
|
return configs;
|
|
402
398
|
}
|
|
403
399
|
|
|
@@ -468,17 +464,21 @@ function getDkim(file) {
|
|
|
468
464
|
*
|
|
469
465
|
*/
|
|
470
466
|
function writeInfraConf(data) {
|
|
471
|
-
|
|
467
|
+
writeEcoSystem(data);
|
|
472
468
|
const etc = 'etc';
|
|
473
469
|
const nginx = join(etc, 'nginx');
|
|
474
470
|
const drumee = join(etc, 'drumee');
|
|
475
471
|
const bind = join(etc, 'bind');
|
|
476
472
|
const libbind = join('var', 'lib', 'bind');
|
|
477
|
-
const postfix = join(etc, 'postfix');
|
|
473
|
+
const postfix = join(etc, 'postfix',);
|
|
478
474
|
const mariadb = join(etc, 'mysql', 'mariadb.conf.d');
|
|
479
475
|
const infra = join(drumee, 'infrastructure');
|
|
480
|
-
|
|
476
|
+
let { certs_dir, public_domain, private_domain, jitsi_private_domain, jits_public_domain } = data;
|
|
481
477
|
let targets = [
|
|
478
|
+
|
|
479
|
+
// Nginx
|
|
480
|
+
|
|
481
|
+
// Drumee
|
|
482
482
|
`${drumee}/drumee.sh`,
|
|
483
483
|
`${drumee}/conf.d/drumee.json`,
|
|
484
484
|
`${drumee}/conf.d/exchange.json`,
|
|
@@ -486,42 +486,20 @@ function writeInfraConf(data) {
|
|
|
486
486
|
`${drumee}/conf.d/drumee.json`,
|
|
487
487
|
`${drumee}/conf.d/myDrumee.json`,
|
|
488
488
|
|
|
489
|
-
`${
|
|
490
|
-
|
|
491
|
-
`${infra}/mfs.conf`,
|
|
492
|
-
`${infra}/routes/main.conf`,
|
|
493
|
-
`${infra}/internals/accel.conf`,
|
|
489
|
+
`${bind}/named.conf.log`,
|
|
490
|
+
`${bind}/named.conf.options`,
|
|
494
491
|
`${mariadb}/50-server.cnf`,
|
|
495
492
|
`${mariadb}/50-client.cnf`,
|
|
493
|
+
`${bind}/named.conf.local`,
|
|
496
494
|
];
|
|
497
495
|
|
|
498
|
-
if (args.localhost) {
|
|
499
|
-
let { username } = userInfo();
|
|
500
|
-
let system_group = username;
|
|
501
|
-
if (username = 'root') {
|
|
502
|
-
username = data.system_user || 'www-data';
|
|
503
|
-
system_group = data.system_group || 'www-data';
|
|
504
|
-
}
|
|
505
|
-
data.system_user = username;
|
|
506
|
-
data.system_group = system_group;
|
|
507
|
-
targets.push(`${nginx}/sites-enabled/localhost.conf`)
|
|
508
|
-
let dir = join(args.drumee_root, 'cache', 'localhost')
|
|
509
|
-
mkdirSync(dir, { recursive: true });
|
|
510
|
-
} else {
|
|
511
|
-
targets.push(
|
|
512
|
-
`${bind}/named.conf.log`,
|
|
513
|
-
`${bind}/named.conf.options`,
|
|
514
|
-
)
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
writeEcoSystem(data);
|
|
518
496
|
if (data.public_ip4 && public_domain) {
|
|
519
|
-
let dir = join(args.drumee_root, 'cache', public_domain)
|
|
520
|
-
mkdirSync(dir, { recursive: true });
|
|
521
497
|
targets.push(
|
|
522
|
-
`${
|
|
498
|
+
`${infra}/internals/accel.public.conf`,
|
|
499
|
+
`${infra}/mfs.public.conf`,
|
|
500
|
+
`${infra}/routes/public.conf`,
|
|
501
|
+
`${nginx}/sites-enabled/01-public.conf`,
|
|
523
502
|
`${drumee}/ssl/public.conf`,
|
|
524
|
-
`${bind}/named.conf.public`,
|
|
525
503
|
{ tpl: `${libbind}/public.tpl`, out: `${libbind}/${public_domain}` },
|
|
526
504
|
{ tpl: `${libbind}/public-reverse.tpl`, out: `${libbind}/${data.public_ip4}` }
|
|
527
505
|
);
|
|
@@ -544,51 +522,141 @@ function writeInfraConf(data) {
|
|
|
544
522
|
}
|
|
545
523
|
|
|
546
524
|
if (data.private_ip4 && private_domain) {
|
|
547
|
-
let dir = join(args.drumee_root, 'cache', private_domain)
|
|
548
|
-
mkdirSync(dir, { recursive: true });
|
|
549
525
|
targets.push(
|
|
550
|
-
`${
|
|
526
|
+
`${infra}/internals/accel.private.conf`,
|
|
527
|
+
`${infra}/mfs.private.conf`,
|
|
528
|
+
`${infra}/routes/private.conf`,
|
|
529
|
+
`${nginx}/sites-enabled/02-private.conf`,
|
|
551
530
|
`${drumee}/ssl/private.conf`,
|
|
552
|
-
|
|
531
|
+
{
|
|
532
|
+
tpl: `${drumee}/certs/private.cnf`,
|
|
533
|
+
out: `${certs_dir}/${private_domain}_ecc/${private_domain}.cnf`
|
|
534
|
+
},
|
|
553
535
|
{ tpl: `${libbind}/private.tpl`, out: `${libbind}/${private_domain}` },
|
|
554
|
-
{ tpl: `${libbind}/private-reverse.tpl`, out: `${libbind}/${data.private_ip4}` }
|
|
536
|
+
{ tpl: `${libbind}/private-reverse.tpl`, out: `${libbind}/${data.private_ip4}` }
|
|
555
537
|
)
|
|
556
538
|
}
|
|
557
539
|
|
|
540
|
+
if (jitsi_private_domain) {
|
|
541
|
+
targets.push(
|
|
542
|
+
{
|
|
543
|
+
tpl: `${drumee}/certs/jitsi.private.cnf`,
|
|
544
|
+
out: `${certs_dir}/${jitsi_private_domain}_ecc/${jitsi_private_domain}.cnf`
|
|
545
|
+
},
|
|
546
|
+
)
|
|
547
|
+
}
|
|
558
548
|
|
|
559
549
|
writeTemplates(data, targets);
|
|
560
550
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
})
|
|
551
|
+
writeCredentials("postfix", {
|
|
552
|
+
host: 'localhost',
|
|
553
|
+
user: data.mail_user,
|
|
554
|
+
password: data.mail_password,
|
|
555
|
+
})
|
|
567
556
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
557
|
+
writeCredentials("db", {
|
|
558
|
+
password: uniqueId(),
|
|
559
|
+
user: "drumee-app",
|
|
560
|
+
host: "localhost",
|
|
561
|
+
})
|
|
573
562
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
563
|
+
writeCredentials("email", {
|
|
564
|
+
host: `localhost`,
|
|
565
|
+
port: 587,
|
|
566
|
+
secure: false,
|
|
567
|
+
auth: {
|
|
568
|
+
user: `butler@${public_domain}`,
|
|
569
|
+
pass: uniqueId()
|
|
570
|
+
},
|
|
571
|
+
tls: {
|
|
572
|
+
rejectUnauthorized: false
|
|
573
|
+
}
|
|
574
|
+
})
|
|
586
575
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
576
|
+
copyConfigs([
|
|
577
|
+
'etc/postfix/master.cf',
|
|
578
|
+
'etc/cron.d/drumee',
|
|
579
|
+
])
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
*
|
|
584
|
+
* @param {*} targets
|
|
585
|
+
* @param {*} type
|
|
586
|
+
*/
|
|
587
|
+
function addJitsiConfigsFiles(targets, data, type = 'private') {
|
|
588
|
+
const etc = 'etc';
|
|
589
|
+
const jitsi = join(etc, 'jitsi');
|
|
590
|
+
const nginx = join(etc, 'nginx');
|
|
591
|
+
const prosody = join(etc, 'prosody');
|
|
592
|
+
const drumee = join(etc, 'drumee');
|
|
593
|
+
|
|
594
|
+
const domain = data[`jitsi_${type}_domain`];
|
|
595
|
+
targets.push(
|
|
596
|
+
{
|
|
597
|
+
tpl: `${jitsi}/jicofo/jicofo.${type}.conf`,
|
|
598
|
+
out: `${jitsi}/jicofo/jicofo.conf`,
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
tpl: `${jitsi}/jicofo/sip-cmmunicator.${type}.properties`,
|
|
602
|
+
out: `${jitsi}/jicofo/sip-cmmunicator.properties`
|
|
603
|
+
},
|
|
604
|
+
`${jitsi}/videobridge/jvb.${type}.conf`,
|
|
605
|
+
`${jitsi}/ssl.${type}.conf`,
|
|
606
|
+
`${jitsi}/meet.${type}.conf`,
|
|
607
|
+
`${jitsi}/web/config.${type}.js`,
|
|
608
|
+
`${nginx}/sites-enabled/20-jitsi.${type}.conf`,
|
|
609
|
+
`${nginx}/modules-enabled/90-turn-relay.${type}.conf`,
|
|
610
|
+
{
|
|
611
|
+
tpl: `${prosody}/conf.d/${type}.cfg.lua`,
|
|
612
|
+
out: `${prosody}/conf.d/${domain}.cfg.lua`,
|
|
613
|
+
},
|
|
614
|
+
`${etc}/turnserver.${type}.conf`,
|
|
615
|
+
{
|
|
616
|
+
tpl: `${drumee}/conf.d/conference.${type}.json`,
|
|
617
|
+
out: `${drumee}/conf.d/${domain}.json`,
|
|
618
|
+
},
|
|
619
|
+
)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
*
|
|
624
|
+
* @param {*} targets
|
|
625
|
+
* @param {*} type
|
|
626
|
+
*/
|
|
627
|
+
function _addDrumeeConfigsFiles(targets, data, type = 'private') {
|
|
628
|
+
const etc = 'etc';
|
|
629
|
+
const jitsi = join(etc, 'jitsi');
|
|
630
|
+
const nginx = join(etc, 'nginx');
|
|
631
|
+
const prosody = join(etc, 'prosody');
|
|
632
|
+
const drumee = join(etc, 'drumee');
|
|
633
|
+
|
|
634
|
+
const domain = data[`jitsi_${type}_domain`];
|
|
635
|
+
targets.push(
|
|
636
|
+
{
|
|
637
|
+
tpl: `${jitsi}/jicofo/jicofo.${type}.conf`,
|
|
638
|
+
out: `${jitsi}/jicofo/jicofo.conf`,
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
tpl: `${jitsi}/jicofo/sip-cmmunicator.${type}.properties`,
|
|
642
|
+
out: `${jitsi}/jicofo/sip-cmmunicator.properties`
|
|
643
|
+
},
|
|
644
|
+
`${jitsi}/videobridge/jvb.${type}.conf`,
|
|
645
|
+
`${jitsi}/ssl.${type}.conf`,
|
|
646
|
+
`${jitsi}/meet.${type}.conf`,
|
|
647
|
+
`${jitsi}/web/config.${type}.js`,
|
|
648
|
+
`${nginx}/sites-enabled/20-jitsi.${type}.conf`,
|
|
649
|
+
`${nginx}/modules-enabled/90-turn-relay.${type}.conf`,
|
|
650
|
+
{
|
|
651
|
+
tpl: `${prosody}/conf.d/${type}.cfg.lua`,
|
|
652
|
+
out: `${prosody}/conf.d/${domain}.cfg.lua`,
|
|
653
|
+
},
|
|
654
|
+
`${etc}/turnserver.${type}.conf`,
|
|
655
|
+
{
|
|
656
|
+
tpl: `${drumee}/conf.d/conference.${type}.json`,
|
|
657
|
+
out: `${drumee}/conf.d/${domain}.json`,
|
|
658
|
+
},
|
|
659
|
+
)
|
|
592
660
|
}
|
|
593
661
|
|
|
594
662
|
/**
|
|
@@ -597,45 +665,27 @@ function writeInfraConf(data) {
|
|
|
597
665
|
function writeJitsiConf(data) {
|
|
598
666
|
const etc = 'etc';
|
|
599
667
|
const jitsi = join(etc, 'jitsi');
|
|
600
|
-
const nginx = join(etc, 'nginx');
|
|
601
668
|
const prosody = join(etc, 'prosody');
|
|
602
669
|
const drumee = join(etc, 'drumee');
|
|
603
670
|
let targets = [
|
|
604
|
-
// Jicofo
|
|
605
671
|
`${jitsi}/jicofo/config`,
|
|
606
|
-
`${jitsi}/jicofo/jicofo.conf`,
|
|
607
672
|
`${jitsi}/jicofo/logging.properties`,
|
|
608
|
-
|
|
609
|
-
// Jitsi Video Bridge
|
|
610
673
|
`${jitsi}/videobridge/config`,
|
|
611
|
-
`${jitsi}/videobridge/jvb.conf`,
|
|
612
674
|
`${jitsi}/videobridge/logging.properties`,
|
|
613
|
-
|
|
614
|
-
// Jitsi meet
|
|
615
|
-
`${jitsi}/ssl.conf`,
|
|
616
|
-
`${jitsi}/meet.conf`,
|
|
617
|
-
`${jitsi}/web/config.js`,
|
|
618
675
|
`${jitsi}/web/interface_config.js`,
|
|
619
676
|
`${jitsi}/web/defaults/ffdhe2048.txt`,
|
|
620
|
-
|
|
621
|
-
// Nginx
|
|
622
|
-
`${nginx}/sites-enabled/jitsi.conf`,
|
|
623
|
-
`${nginx}/modules-enabled/90-turn-relay.conf`,
|
|
624
|
-
|
|
625
|
-
// Prosody
|
|
626
|
-
`${prosody}/prosody.cfg.lua`,
|
|
627
677
|
`${prosody}/defaults/credentials.sh`,
|
|
628
|
-
{
|
|
629
|
-
out: `${prosody}/conf.d/${data.jitsi_domain}.cfg.lua`,
|
|
630
|
-
tpl: `${prosody}/conf.d/vhost.cfg.lua`
|
|
631
|
-
},
|
|
632
|
-
// `${prosody}/migrator.cfg.lua`,
|
|
633
|
-
|
|
634
|
-
// Turnserver
|
|
635
|
-
`${etc}/turnserver.conf`,
|
|
636
|
-
|
|
637
|
-
`${drumee}/conf.d/conference.json`,
|
|
678
|
+
`${prosody}/prosody.cfg.lua`,
|
|
638
679
|
];
|
|
680
|
+
if (data.public_domain) {
|
|
681
|
+
addJitsiConfigsFiles(targets, data, `public`)
|
|
682
|
+
} else if (data.private_domain) {
|
|
683
|
+
addJitsiConfigsFiles(targets, data, `private`)
|
|
684
|
+
} else {
|
|
685
|
+
console.error(" No domain name available!")
|
|
686
|
+
return
|
|
687
|
+
}
|
|
688
|
+
|
|
639
689
|
writeTemplates(data, targets);
|
|
640
690
|
|
|
641
691
|
}
|
|
@@ -644,8 +694,10 @@ function writeJitsiConf(data) {
|
|
|
644
694
|
*
|
|
645
695
|
*/
|
|
646
696
|
function makeConfData(data) {
|
|
697
|
+
const endpoint_name = "main";
|
|
647
698
|
data = {
|
|
648
699
|
...data,
|
|
700
|
+
endpoint_name,
|
|
649
701
|
turn_sercret: randomString(),
|
|
650
702
|
prosody_plugins: "/usr/share/jitsi-meet/prosody-plugins/",
|
|
651
703
|
xmpp_password: randomString(),
|
|
@@ -655,16 +707,13 @@ function makeConfData(data) {
|
|
|
655
707
|
jvb_password: randomString(),
|
|
656
708
|
app_id: randomString(),
|
|
657
709
|
app_password: randomString(),
|
|
658
|
-
ui_base: join(data.ui_base,
|
|
710
|
+
ui_base: join(data.ui_base, endpoint_name),
|
|
659
711
|
location: '/-/',
|
|
660
712
|
pushPort: 23000,
|
|
661
713
|
restPort: 24000,
|
|
662
714
|
};
|
|
663
715
|
if (!data.export_dir) data.export_dir = null;
|
|
664
716
|
if (!data.import_dir) data.import_dir = null;
|
|
665
|
-
if (!data.private_address) {
|
|
666
|
-
data.private_address = data.public_address || "127.0.0.1";
|
|
667
|
-
}
|
|
668
717
|
return data
|
|
669
718
|
}
|
|
670
719
|
|
|
@@ -685,6 +734,7 @@ async function getAddresses(data) {
|
|
|
685
734
|
let os = require("os");
|
|
686
735
|
let interfaces = os.networkInterfaces();
|
|
687
736
|
let private_ip4, public_ip4, private_ip6, public_ip6;
|
|
737
|
+
let private_if4, private_subnet_mask, private_broadcast_address;
|
|
688
738
|
for (let name in interfaces) {
|
|
689
739
|
if (name == 'lo') continue;
|
|
690
740
|
for (let dev of interfaces[name]) {
|
|
@@ -692,6 +742,21 @@ async function getAddresses(data) {
|
|
|
692
742
|
case 'IPv4':
|
|
693
743
|
if (isPrivate(dev.address) && !private_ip4) {
|
|
694
744
|
private_ip4 = dev.address;
|
|
745
|
+
private_if4 = name;
|
|
746
|
+
private_subnet_mask = dev.netmask;
|
|
747
|
+
let a = private_ip4.split('.');
|
|
748
|
+
let b = private_subnet_mask.split('.');
|
|
749
|
+
let i = 0;
|
|
750
|
+
let br = [];
|
|
751
|
+
for (let c of b) {
|
|
752
|
+
if (c == '255') {
|
|
753
|
+
br.push(a[i])
|
|
754
|
+
}else{
|
|
755
|
+
br.push('255')
|
|
756
|
+
}
|
|
757
|
+
i++;
|
|
758
|
+
}
|
|
759
|
+
private_broadcast_address = br.join('.')
|
|
695
760
|
}
|
|
696
761
|
if (!isPrivate(dev.address) && !public_ip4) {
|
|
697
762
|
public_ip4 = dev.address;
|
|
@@ -708,16 +773,47 @@ async function getAddresses(data) {
|
|
|
708
773
|
}
|
|
709
774
|
}
|
|
710
775
|
}
|
|
711
|
-
data.private_ip4 = data.private_ip4 || private_ip4;
|
|
712
|
-
data.private_ip6 = data.private_ip6 || private_ip6;
|
|
713
|
-
data.local_address = data.private_ip4;
|
|
714
776
|
|
|
715
|
-
data.
|
|
716
|
-
data.
|
|
777
|
+
data.private_ip6 = args.private_ip6 || PRIVATE_IP6 || private_ip6;
|
|
778
|
+
data.private_ip4 = args.private_ip4 || PRIVATE_IP4 || private_ip4;
|
|
779
|
+
data.private_if4 = args.private_ip4 || PRIVATE_IF4 || private_if4;
|
|
780
|
+
data.private_if4 = args.private_ip4 || PRIVATE_IF4 || private_if4;
|
|
781
|
+
data.private_broadcast_address = private_broadcast_address || '255.255.255.255';
|
|
782
|
+
data.private_subnet_mask = private_subnet_mask || '255.255.255.0';
|
|
783
|
+
|
|
784
|
+
data.public_ip4 = args.public_ip4 || PUBLIC_IP4 || public_ip4;
|
|
785
|
+
data.public_ip6 = args.public_ip6 || PUBLIC_IP6 || public_ip6;
|
|
786
|
+
|
|
787
|
+
/** Named extra settings */
|
|
788
|
+
data.allow_recursion = 'localhost;';
|
|
789
|
+
|
|
790
|
+
if (data.public_ip4) {
|
|
791
|
+
data.allow_recursion = `${data.allow_recursion} ${data.public_ip4};`
|
|
792
|
+
let a = data.public_ip4.split('.');
|
|
793
|
+
a.pop();
|
|
794
|
+
data.reverse_public_ip4 = a.reverse().join('.');
|
|
795
|
+
} else {
|
|
796
|
+
data.reverse_public_ip4 = ""
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (!data.public_ip6) {
|
|
800
|
+
data.public_ip6 = "";
|
|
801
|
+
}
|
|
802
|
+
if (data.private_ip4) {
|
|
803
|
+
data.allow_recursion = `${data.allow_recursion} ${data.private_ip4};`
|
|
804
|
+
let a = data.private_ip4.split('.');
|
|
805
|
+
a.pop();
|
|
806
|
+
data.reverse_private_ip4 = a.reverse().join('.');
|
|
807
|
+
} else {
|
|
808
|
+
data.reverse_private_ip4 = ""
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
if (!data.public_ip6) {
|
|
812
|
+
data.public_ip6 = "";
|
|
813
|
+
}
|
|
717
814
|
|
|
718
815
|
return data;
|
|
719
816
|
}
|
|
720
|
-
|
|
721
817
|
/**
|
|
722
818
|
*
|
|
723
819
|
* @returns
|
|
@@ -731,7 +827,7 @@ function main() {
|
|
|
731
827
|
data = { ...data, ...makeConfData(data) };
|
|
732
828
|
data = await getAddresses(data);
|
|
733
829
|
let func = [];
|
|
734
|
-
if (args.only_infra || args.no_jitsi
|
|
830
|
+
if (args.only_infra || args.no_jitsi) {
|
|
735
831
|
func.push(writeInfraConf)
|
|
736
832
|
} else {
|
|
737
833
|
func = [writeInfraConf, writeJitsiConf];
|