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