@drumee/setup-infra 1.0.13 → 1.0.14

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.
Files changed (34) hide show
  1. package/bin/init-acme +13 -5
  2. package/bin/init-private +40 -0
  3. package/bin/prosody +1 -1
  4. package/index.js +295 -162
  5. package/package.json +3 -4
  6. package/templates/etc/bind/named.conf.options +1 -1
  7. package/templates/etc/bind/named.conf.private +21 -0
  8. package/templates/etc/bind/{named.conf.local → named.conf.public} +2 -2
  9. package/templates/etc/dkimkeys/dkim.key +1 -1
  10. package/templates/etc/drumee/conf.d/myDrumee.json.tpl +1 -1
  11. package/templates/etc/drumee/dnsapi.sh.tpl +1 -1
  12. package/templates/etc/drumee/drumee.sh.tpl +24 -17
  13. package/templates/etc/drumee/env.json +1 -1
  14. package/templates/etc/drumee/infrastructure/routes/main.conf.tpl +23 -13
  15. package/templates/etc/drumee/ssl/{main.conf.tpl → private.conf.tpl} +2 -4
  16. package/templates/etc/drumee/ssl/public.conf.tpl +10 -0
  17. package/templates/etc/mysql/mariadb.conf.d/50-client.cnf +21 -0
  18. package/templates/etc/mysql/mariadb.conf.d/50-server.cnf +2 -1
  19. package/templates/etc/nginx/nginx.conf +1 -1
  20. package/templates/etc/nginx/sites-enabled/jitsi.conf.tpl +4 -4
  21. package/templates/etc/nginx/sites-enabled/{loopback.tpl → localhost.conf} +9 -10
  22. package/templates/etc/nginx/sites-enabled/pivate.jitsi.conf.tpl +28 -0
  23. package/templates/etc/nginx/sites-enabled/private.conf.tpl +40 -0
  24. package/templates/etc/nginx/sites-enabled/{drumee.conf.tpl → public.conf.tpl} +8 -8
  25. package/templates/etc/nginx/sites-enabled/public.jitsi.conf.tpl +28 -0
  26. package/templates/etc/postfix/main.cf +1 -1
  27. package/templates/etc/prosody/conf.d/private.cfg.lua.tpl +162 -0
  28. package/templates/etc/prosody/conf.d/public.cfg.lua.tpl +162 -0
  29. package/templates/index.js +19 -13
  30. package/templates/utils.js +192 -0
  31. package/templates/var/lib/bind/private-reverse.tpl +17 -0
  32. package/templates/var/lib/bind/prvate.tpl +70 -0
  33. /package/templates/var/lib/bind/{reverse.tpl → public-reverse.tpl} +0 -0
  34. /package/templates/var/lib/bind/{domain.tpl → public.tpl} +0 -0
@@ -0,0 +1,162 @@
1
+ admins = {
2
+ "jigasi@auth.<%= public_jitsi %>",
3
+ "jibri@auth.<%= public_jitsi %>",
4
+ "focus@auth.<%= public_jitsi %>",
5
+ "jvb@auth.<%= public_jitsi %>"
6
+ }
7
+
8
+ unlimited_jids = {
9
+ "focus@auth.<%= public_jitsi %>",
10
+ "jvb@auth.<%= public_jitsi %>"
11
+ }
12
+
13
+ plugin_paths = { "/usr/share/jitsi-meet/prosody-plugins/", "/prosody-plugins-custom" }
14
+
15
+ muc_mapper_domain_base = "<%= public_jitsi %>";
16
+ muc_mapper_domain_prefix = "muc";
17
+ http_default_host = "<%= public_jitsi %>"
18
+ consider_bosh_secure = true;
19
+ consider_websocket_secure = true;
20
+
21
+ VirtualHost "<%= public_jitsi %>"
22
+ authentication = "internal_hashed"
23
+ ssl = {
24
+ key = "<%= certs_dir %>/<%= public_jitsi %>_ecc/<%= public_jitsi %>.key";
25
+ certificate = "<%= certs_dir %>/<%= public_jitsi %>_ecc/<%= public_jitsi %>.cer";
26
+ }
27
+ modules_enabled = {
28
+ "bosh";
29
+ "websocket";
30
+ "smacks"; -- XEP-0198: Stream Management
31
+ "pubsub";
32
+ "ping";
33
+ "speakerstats";
34
+ "conference_duration";
35
+ "room_metadata";
36
+ "end_conference";
37
+ "muc_lobby_rooms";
38
+ "muc_breakout_rooms";
39
+ "av_moderation";
40
+ "turncredentials";
41
+ }
42
+ main_muc = "muc.<%= public_jitsi %>"
43
+ lobby_muc = "lobby.<%= public_jitsi %>"
44
+ breakout_rooms_muc = "breakout.<%= public_jitsi %>"
45
+ speakerstats_component = "speakerstats.<%= public_jitsi %>"
46
+ conference_duration_component = "conferenceduration.<%= public_jitsi %>"
47
+ end_conference_component = "endconference.<%= public_jitsi %>"
48
+ av_moderation_component = "avmoderation.<%= public_jitsi %>"
49
+ turncredentials_secret = "<%= turn_sercret %>"
50
+ c2s_require_encryption = false
51
+
52
+
53
+ VirtualHost "guest.<%= public_jitsi %>"
54
+ authentication = "anonymous"
55
+ ssl = {
56
+ key = "/usr/share/acme/certs/<%= public_jitsi %>_ecc/<%= public_jitsi %>.key";
57
+ certificate = "/usr/share/acme/certs/<%= public_jitsi %>_ecc/<%= public_jitsi %>.cer";
58
+ }
59
+ modules_enabled = {
60
+ "bosh";
61
+ "websocket";
62
+ "smacks"; -- XEP-0198: Stream Management
63
+ "pubsub";
64
+ "ping";
65
+ "speakerstats";
66
+ "conference_duration";
67
+ "room_metadata";
68
+ "end_conference";
69
+ "muc_lobby_rooms";
70
+ "muc_breakout_rooms";
71
+ "av_moderation";
72
+ "turncredentials";
73
+ }
74
+ main_muc = "muc.<%= public_jitsi %>"
75
+ lobby_muc = "lobby.<%= public_jitsi %>"
76
+ breakout_rooms_muc = "breakout.<%= public_jitsi %>"
77
+ speakerstats_component = "speakerstats.<%= public_jitsi %>"
78
+ conference_duration_component = "conferenceduration.<%= public_jitsi %>"
79
+ end_conference_component = "endconference.<%= public_jitsi %>"
80
+ av_moderation_component = "avmoderation.<%= public_jitsi %>"
81
+ turncredentials_secret = "<%= turn_sercret %>"
82
+ c2s_require_encryption = false
83
+
84
+
85
+ VirtualHost "auth.<%= public_jitsi %>"
86
+ ssl = {
87
+ key = "<%= certs_dir %>/<%= public_jitsi %>_ecc/<%= public_jitsi %>.key";
88
+ certificate = "<%= certs_dir %>/<%= public_jitsi %>_ecc/fullchain.cer";
89
+ }
90
+ modules_enabled = {
91
+ "limits_exception";
92
+ }
93
+ authentication = "internal_hashed"
94
+
95
+
96
+
97
+ Component "internal-muc.<%= public_jitsi %>" "muc"
98
+ storage = "memory"
99
+ modules_enabled = {
100
+ "ping";
101
+ }
102
+ restrict_room_creation = true
103
+ muc_room_locking = false
104
+ muc_room_default_public_jids = true
105
+
106
+ Component "muc.<%= public_jitsi %>" "muc"
107
+ restrict_room_creation = true
108
+ storage = "memory"
109
+ modules_enabled = {
110
+ "muc_meeting_id";
111
+ "polls";
112
+ "muc_domain_mapper";
113
+ "muc_password_whitelist";
114
+ }
115
+
116
+ -- The size of the cache that saves state for IP addresses
117
+ rate_limit_cache_size = 10000;
118
+ muc_room_cache_size = 1000
119
+ muc_room_locking = false
120
+ muc_room_default_public_jids = true
121
+ muc_password_whitelist = {
122
+ "focus@<no value>"
123
+ }
124
+
125
+ Component "focus.<%= public_jitsi %>" "client_proxy"
126
+ target_address = "focus@auth.<%= public_jitsi %>"
127
+
128
+ Component "speakerstats.<%= public_jitsi %>" "speakerstats_component"
129
+ muc_component = "muc.<%= public_jitsi %>"
130
+
131
+ Component "conferenceduration.<%= public_jitsi %>" "conference_duration_component"
132
+ muc_component = "muc.<%= public_jitsi %>"
133
+
134
+
135
+ Component "endconference.<%= public_jitsi %>" "end_conference"
136
+ muc_component = "muc.<%= public_jitsi %>"
137
+
138
+
139
+ Component "lobby.<%= public_jitsi %>" "muc"
140
+ storage = "memory"
141
+ restrict_room_creation = true
142
+ muc_room_locking = false
143
+ muc_room_default_public_jids = true
144
+ modules_enabled = {
145
+ }
146
+
147
+
148
+ Component "breakout.<%= public_jitsi %>" "muc"
149
+ storage = "memory"
150
+ restrict_room_creation = true
151
+ muc_room_locking = false
152
+ muc_room_default_public_jids = true
153
+ modules_enabled = {
154
+ "muc_meeting_id";
155
+ "muc_domain_mapper";
156
+ "polls";
157
+ }
158
+
159
+
160
+ Component "metadata.<%= public_jitsi %>" "room_metadata_component"
161
+ muc_component = "muc.<%= public_jitsi %>"
162
+ breakout_rooms_component = "breakout.<%= public_jitsi %>"
@@ -1,17 +1,18 @@
1
- _ = require("lodash");
2
- Shell = require("shelljs");
3
- const { mkdirSync, existsSync, writeSync, openSync, close, readFileSync } = require("fs");
1
+ const {
2
+ mkdirSync, existsSync, writeSync, openSync, close, readFileSync
3
+ } = require("fs");
4
4
  const { env } = process;
5
- const { resolve, join, dirname } = require("path");
6
- const ARGV = require('minimist')(process.argv.slice(2));
5
+ const { template, isEmpty } = require("lodash");
7
6
 
7
+ const { resolve, join, dirname } = require("path");
8
+ const { args} = require('./utils')
8
9
  /**
9
10
  *
10
11
  * @param {*} p
11
12
  * @returns
12
13
  */
13
14
  function chroot(p) {
14
- let root = ARGV.chroot || env.dev_root;
15
+ let root = args.outdir || args.chroot || env.DRUMEE_CONF_BASE;
15
16
  if (root) {
16
17
  if (p) return join(root, p);
17
18
  return join(root);
@@ -25,7 +26,6 @@ function chroot(p) {
25
26
  */
26
27
  function makedir(dname) {
27
28
  if (!existsSync(dname)) {
28
- //console.log(`Should make dir ${dname}`);
29
29
  mkdirSync(dname, { recursive: true });
30
30
  }
31
31
  };
@@ -53,8 +53,9 @@ function render(data, name, parse) {
53
53
  }
54
54
  //console.log("RENDERING", __dirname, name, tpl);
55
55
  let str = readFileSync(tpl);
56
+
56
57
  try {
57
- let res = _.template(String(str).toString())(data);
58
+ let res = template(String(str).toString())(data);
58
59
  if (parse && typeof res === "string") {
59
60
  return JSON.parse(res);
60
61
  }
@@ -79,14 +80,18 @@ function write(data, fn, tpl_name, chr) {
79
80
  let d = new Date();
80
81
  data.date = d.toISOString().split('T')[0];
81
82
 
82
- console.log("Writing config into " + filename);
83
83
  let fd = openSync(filename, "w+");
84
- if (ARGV.readonly) {
85
- console.log("Readonly", fn, tpl_name);
84
+ if (args.readonly) {
85
+ console.log(`READ ONLY using template ${tpl_name}, fn=${fn}`);
86
+ if (args.readonly > 1) {
87
+ console.log(data);
88
+ console.log("END OF FILE", filename);
89
+ }
86
90
  return
87
91
  }
88
92
 
89
- if (_.isEmpty(tpl_name)) {
93
+ console.log("Writing config into " + filename);
94
+ if (isEmpty(tpl_name)) {
90
95
  writeSync(fd, data);
91
96
  } else {
92
97
  writeSync(fd, render(data, tpl_name));
@@ -98,5 +103,6 @@ function write(data, fn, tpl_name, chr) {
98
103
  module.exports = {
99
104
  write,
100
105
  chroot,
101
- render
106
+ render,
107
+ makedir,
102
108
  };
@@ -0,0 +1,192 @@
1
+ const argparse = require("argparse");
2
+ const { existsSync } = require("fs");
3
+ const { readFileSync } = require(`jsonfile`);
4
+ const {
5
+ BACKUP_STORAGE,
6
+ DRUMEE_DATA_DIR,
7
+ DRUMEE_DB_DIR,
8
+ MAX_BODY_SIZE,
9
+ PRIVATE_DOMAIN,
10
+ PRIVATE_IP4,
11
+ PUBLIC_DOMAIN,
12
+ PUBLIC_IP4,
13
+ PUBLIC_IP6,
14
+ DRUMEE_ROOT,
15
+ HTTP_PORT,
16
+ HTTPS_PORT,
17
+ FORCE_INSTALL,
18
+ ADMIN_EMAIL,
19
+ DRUMEE_DESCRIPTION
20
+ } = process.env;
21
+
22
+ const parser = new argparse.ArgumentParser({
23
+ description: "Drumee Infrastructure Helper",
24
+ add_help: true,
25
+ });
26
+
27
+ parser.add_argument("--admin_email", {
28
+ type: String,
29
+ default: ADMIN_EMAIL || "admin@localhost",
30
+ help: "Drumee Instance Admin User Email",
31
+ });
32
+
33
+ parser.add_argument("--description", {
34
+ type: String,
35
+ default: DRUMEE_DESCRIPTION || "My Drumee Team Server",
36
+ help: "Drumee Instance Description",
37
+ });
38
+
39
+ parser.add_argument("--readonly", {
40
+ type: "int",
41
+ default: 0,
42
+ help: "Print content instead of actually writing to files",
43
+ });
44
+
45
+ parser.add_argument("--chroot", {
46
+ type: String,
47
+ default: '/',
48
+ help: "Output root. Defaulted to /",
49
+ });
50
+
51
+ parser.add_argument("--reconfigure", {
52
+ type: "int",
53
+ default: FORCE_INSTALL || 0,
54
+ help: "Override existing configs",
55
+ });
56
+
57
+ parser.add_argument("--outdir", {
58
+ type: String,
59
+ default: '/',
60
+ help: "If set, takes precedent on chroot. Output root. Defaulted to /",
61
+ });
62
+
63
+ parser.add_argument("--public-domain", {
64
+ type: String,
65
+ default: PUBLIC_DOMAIN,
66
+ help: "Public domain name",
67
+ });
68
+
69
+ parser.add_argument("--private-domain", {
70
+ type: String,
71
+ default: PRIVATE_DOMAIN,
72
+ help: "Private domain name",
73
+ });
74
+
75
+ parser.add_argument("--local-domain", {
76
+ type: String,
77
+ default: PRIVATE_DOMAIN,
78
+ help: "",
79
+ });
80
+
81
+ parser.add_argument("--public-ip4", {
82
+ type: String,
83
+ default: PUBLIC_IP4,
84
+ help: "Public IPV4",
85
+ });
86
+
87
+ parser.add_argument("--public-ip6", {
88
+ type: String,
89
+ default: PUBLIC_IP6,
90
+ help: "Public IPV6",
91
+ });
92
+
93
+ parser.add_argument("--private-ip4", {
94
+ type: String,
95
+ default: PRIVATE_IP4,
96
+ help: "Private IPV4",
97
+ });
98
+
99
+ parser.add_argument("--envfile", {
100
+ type: String,
101
+ help: "Dataset required to install Drumee",
102
+ });
103
+
104
+ parser.add_argument("--only-infra", {
105
+ type: "int",
106
+ default: 0,
107
+ help: "If set, write only configs related to infra. Same as no-jitsi",
108
+ });
109
+
110
+ parser.add_argument("--localhost", {
111
+ type: "int",
112
+ default: 0,
113
+ help: "If set, write minimal configs, no jitsi, no bind",
114
+ });
115
+
116
+ parser.add_argument("--http-port", {
117
+ type: "int",
118
+ default: HTTP_PORT || 80,
119
+ help: "If set, write minimal configs, no jitsi, no bind",
120
+ });
121
+
122
+ parser.add_argument("--https-port", {
123
+ type: "int",
124
+ default: HTTPS_PORT || 443,
125
+ help: "If set, write minimal configs, no jitsi, no bind",
126
+ });
127
+
128
+ parser.add_argument("--data-dir", {
129
+ type: String,
130
+ default: DRUMEE_DATA_DIR || "/var/lib/drumee/data",
131
+ help: "Partition or directory dedicated to store drumee data",
132
+ });
133
+
134
+ parser.add_argument("--db-dir", {
135
+ type: String,
136
+ default: DRUMEE_DB_DIR || "/var/lib/mysql",
137
+ help: "Partition or directory dedicated to store drumee database",
138
+ });
139
+
140
+ parser.add_argument("--drumee-root", {
141
+ type: String,
142
+ default: DRUMEE_ROOT || "/var/lib/drumee",
143
+ help: "Drumee main base",
144
+ });
145
+
146
+
147
+ parser.add_argument("--no-jitsi", {
148
+ type: "int",
149
+ default: 0,
150
+ help: "If set, won't write configs related to jisit. Same as only-infra",
151
+ });
152
+
153
+ parser.add_argument("--max-body-size", {
154
+ type: String,
155
+ default: MAX_BODY_SIZE || '10G',
156
+ help: "If set, won't write configs related to jisit. Same as only-infra",
157
+ });
158
+
159
+ parser.add_argument("--backup-storage", {
160
+ type: String,
161
+ default: BACKUP_STORAGE || '10G',
162
+ help: "If set, the partition or directiry will used to backup Drumee data",
163
+ });
164
+
165
+ const args = parser.parse_args();
166
+
167
+ /**
168
+ *
169
+ */
170
+ function hasExistingSettings(envfile = '/etc/drumee/drumee.json') {
171
+ if (!existsSync(envfile)) return false;
172
+ const { domain_name } = readFileSync(envfile);
173
+ if (!domain_name) return false;
174
+ if (args.reconfigure == 1) {
175
+ console.log(
176
+ `There is already a Drumee instance installed on this server but you selected reconfigure\n`,
177
+ `ALL EXISTING DATA related to ${domain_name} WILL BE LOST\n`,
178
+ );
179
+ return false;
180
+ }
181
+ console.log(
182
+ `There is already a Drumee instance installed on this server\n`,
183
+ `domain name = ${domain_name}\n`,
184
+ `Use --reconfigure=1 \n`,
185
+ `********************************************\n`,
186
+ `* WARNING : ALL EXISTING DATA WILL BE LOST *\n`,
187
+ `********************************************\n`,
188
+ );
189
+ return true;
190
+ }
191
+
192
+ module.exports = { args, parser, hasExistingSettings };
@@ -0,0 +1,17 @@
1
+ $TTL 3D
2
+ $ORIGIN <%= private_reverse_ip4 %>.
3
+ ;
4
+ @ IN SOA ns1.<%= private_domain %>. master.<%= private_domain %>. (
5
+ <%= serial %> ; serial, today date + today serial
6
+ 1H ; refresh, seconds
7
+ 2H ; retry, seconds
8
+ 4W ; expire, seconds
9
+ 1D ) ; minimum, seconds
10
+ ;
11
+ ;
12
+ @ IN NS ns1.<%= private_domain %>.
13
+ @ IN NS ns2.<%= private_domain %>.
14
+
15
+ 2 IN PTR ns1.<%= private_domain %>.
16
+ 3 IN PTR ns2.<%= private_domain %>.
17
+ 3 IN PTR smtp.<%= private_domain %>.
@@ -0,0 +1,70 @@
1
+ $TTL 3D
2
+ $ORIGIN <%= private_domain %>.
3
+ ;
4
+ @ IN SOA ns1.<%= private_domain %>. master.<%= private_domain %>. (
5
+ <%= serial %> ; serial, today date + today serial
6
+ 1H ; refresh, seconds
7
+ 2H ; retry, seconds
8
+ 4W ; expire, seconds
9
+ 1D ) ; minimum, seconds
10
+ ;
11
+ ;
12
+ @ 60 IN NS ns1.<%= private_domain %>.
13
+ @ 60 IN NS ns2.<%= private_domain %>.
14
+ ;
15
+ <% if (typeof(private_ip4) !== "undefined" && private_ip4 != "" ) { %>
16
+ ; A records
17
+ @ 60 IN A <%= private_ip4 %>
18
+ ns1 60 IN A <%= private_ip4 %>
19
+ ns2 60 IN A <%= private_ip4 %>
20
+ smtp 60 IN A <%= private_ip4 %>
21
+ jit 60 IN A <%= private_ip4 %>
22
+ * 60 IN A <%= private_ip4 %>
23
+ ;
24
+ <% } %>
25
+ <% if (typeof(private_ip6) !== "undefined" && private_ip6 != "" ) { %>
26
+ ; AAAA records
27
+ @ 60 IN AAAA <%= private_ip6 %>
28
+ ns1 60 IN AAAA <%= private_ip6 %>
29
+ ns2 60 IN AAAA <%= private_ip6 %>
30
+ smtp 60 IN AAAA <%= private_ip6 %>
31
+ jit 60 IN AAAA <%= private_ip6 %>
32
+ * 60 IN AAAA <%= private_ip6 %>
33
+ <% } %>
34
+ ;
35
+ ; CNAME
36
+ ;
37
+ www IN CNAME <%= private_domain %>.
38
+ ;
39
+ ; MX records
40
+ ;
41
+ @ 60 IN MX 10 smtp.<%= private_domain %>.
42
+
43
+ ; TXT records
44
+ _acme-challenge 60 IN TXT "acme-challenge"
45
+ @ 60 IN TXT "v=spf1 a ~all"
46
+ @ 60 IN TXT (<%= dkim_key %>)
47
+ ;
48
+ ;
49
+ ; DKIM
50
+ smtp._domainkey 60 IN TXT (<%= dkim_key %>)
51
+ dkim._domainkey 60 IN TXT (<%= dkim_key %>)
52
+ ;
53
+ ;
54
+ ; DMARC
55
+ _dmarc 60 IN TXT "v=DMARC1; p=quarantine; sp=quarantine; aspf=s"
56
+ ;
57
+ ;
58
+ ; Jitsi subdomain
59
+ $ORIGIN <%= jitsi_domain %>.
60
+ ;
61
+ <% if (typeof(private_ip4) !== "undefined" && private_ip4 != "" ) { %>
62
+ * 60 IN A <%= private_ip4 %>
63
+ <% } %>
64
+ <% if (typeof(private_ip6) !== "undefined" && private_ip6 != "" ) { %>
65
+ * 60 IN AAAA <%= private_ip6 %>
66
+ <% } %>
67
+ ;
68
+ ; TXT records
69
+ _acme-challenge 60 IN TXT "jit-acme-challenge"
70
+