pmcf 1.87.3 → 1.88.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.87.3",
3
+ "version": "1.88.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/cluster.mjs CHANGED
@@ -110,6 +110,12 @@ export class Cluster extends Host {
110
110
  cfg.push(" auth_type PASS");
111
111
  cfg.push(" auth_pass pass1234");
112
112
  cfg.push(" }");
113
+
114
+
115
+ cfg.push(` notify_master "/usr/bin/systemctl start ${host.name}-master.target"`);
116
+ cfg.push(` notify_backup "/usr/bin/systemctl start ${host.name}-backup.target"`);
117
+ cfg.push(` notify_fault "/usr/bin/systemctl start ${host.name}-fault.target"`);
118
+
113
119
  cfg.push("}");
114
120
  cfg.push("");
115
121
 
@@ -150,6 +156,33 @@ export class Cluster extends Host {
150
156
  cfg
151
157
  );
152
158
 
159
+ await writeLines(
160
+ join(packageStagingDir, "/usr/lib/systemd/system"),
161
+ `${this.name}-master.target`,
162
+ [
163
+ "[Unit]",
164
+ `Description: Services to be activated in master state of cluster ${this.name}`
165
+ ]
166
+ );
167
+
168
+ await writeLines(
169
+ join(packageStagingDir, "/usr/lib/systemd/system"),
170
+ `${this.name}-backup.target`,
171
+ [
172
+ "[Unit]",
173
+ `Description: Services to be activated in backup state of cluster ${this.name}`
174
+ ]
175
+ );
176
+
177
+ await writeLines(
178
+ join(packageStagingDir, "/usr/lib/systemd/system"),
179
+ `${this.name}-fault.target`,
180
+ [
181
+ "[Unit]",
182
+ `Description: Services to be activated in fault state of cluster ${this.name}`
183
+ ]
184
+ );
185
+
153
186
  yield result;
154
187
  }
155
188
  }
package/src/dns.mjs CHANGED
@@ -41,6 +41,22 @@ const DNSServiceTypeDefinition = {
41
41
 
42
42
  const DNS_SERVICE_FILTER = { type: DNSServiceTypeDefinition.name };
43
43
 
44
+ function addressList(objects) {
45
+ return Array.from(objects).map(object =>
46
+ typeof object === "string" ? object : object.name
47
+ );
48
+ }
49
+
50
+ function addressesStatement(prefix, objects, generateEmpty = false) {
51
+ const body = addressList(objects).map(name => ` ${name};`);
52
+
53
+ if (body.length || generateEmpty) {
54
+ return [`${prefix} {`, body, "};"];
55
+ }
56
+
57
+ return [];
58
+ }
59
+
44
60
  export class DNSService extends Base {
45
61
  allowedUpdates = [];
46
62
  recordTTL = "1W";
@@ -146,11 +162,10 @@ export class DNSService extends Base {
146
162
  }
147
163
  };
148
164
 
149
- const options = [
150
- "forwarders {",
151
- ...serviceAddresses(this.source, DNS_SERVICE_FILTER).map(a => ` ${a};`),
152
- "};"
153
- ];
165
+ const options = addressesStatement(
166
+ "forwarders",
167
+ serviceAddresses(this.source, DNS_SERVICE_FILTER)
168
+ );
154
169
  if (options.length > 2) {
155
170
  await writeLines(
156
171
  join(p1, "etc/named/options"),
@@ -160,22 +175,15 @@ export class DNSService extends Base {
160
175
  }
161
176
 
162
177
  const acls = [
163
- "acl trusted {",
164
- ...Array.from(subnets(this.trusted)).map(subnet => ` ${subnet.name};`),
165
- "};",
166
- "",
167
- "acl protected {",
168
- ...Array.from(subnets(this.protected)).map(subnet => ` ${subnet.name};`),
169
- "};",
170
- "",
171
- "acl open {",
172
- "};"
173
- ];
178
+ addressesStatement("acl trusted", subnets(this.trusted)),
179
+ addressesStatement("acl protected", subnets(this.protected)),
180
+ addressesStatement("acl open", [], true)
181
+ ].flat();
174
182
 
175
- if (options.length > 8) {
183
+ if (acls.length) {
176
184
  await writeLines(join(p1, "etc/named"), `0-acl-${name}.conf`, acls);
177
185
  }
178
- if (options.length > 2 || acls.length > 8) {
186
+ if (options.length || acls.length) {
179
187
  yield packageData;
180
188
  }
181
189
 
package/src/service.mjs CHANGED
@@ -54,7 +54,8 @@ const ServiceTypeDefinition = {
54
54
  priority: { type: "number", collection: false, writeable: true },
55
55
  weight: { type: "number", collection: false, writeable: true },
56
56
  srvPrefix: { type: "string", collection: false, writeable: false },
57
- tls: { type: "string", collection: false, writeable: false }
57
+ tls: { type: "string", collection: false, writeable: false },
58
+ systemd: { type: "string", collection: true, writeable: true }
58
59
  }
59
60
  };
60
61
 
@@ -65,6 +66,7 @@ export class Service extends Base {
65
66
  #type;
66
67
  #port;
67
68
  #ipAddresses;
69
+ #systemd;
68
70
 
69
71
  static {
70
72
  addType(this);
@@ -98,6 +100,10 @@ export class Service extends Base {
98
100
  data.ipAddresses = this.#ipAddresses;
99
101
  }
100
102
 
103
+ if (this.#systemd) {
104
+ data.systemd = this.#systemd;
105
+ }
106
+
101
107
  // @ts-ignore
102
108
  return new this.constructor(owner, data);
103
109
  }
@@ -191,6 +197,11 @@ export class Service extends Base {
191
197
  return ServiceTypes[this.type]?.tls || false;
192
198
  }
193
199
 
200
+ get systemdServices()
201
+ {
202
+ return this.#systemd;
203
+ }
204
+
194
205
  get srvPrefix() {
195
206
  const st = ServiceTypes[this.type];
196
207
  if (st?.protocol) {
@@ -97,6 +97,11 @@ export class Service extends Base {
97
97
  collection: boolean;
98
98
  writeable: boolean;
99
99
  };
100
+ systemd: {
101
+ type: string;
102
+ collection: boolean;
103
+ writeable: boolean;
104
+ };
100
105
  cidrAddresses: {
101
106
  type: string;
102
107
  collection: boolean;
@@ -138,6 +143,7 @@ export class Service extends Base {
138
143
  get master(): any;
139
144
  get protocol(): any;
140
145
  get tls(): any;
146
+ get systemdServices(): any;
141
147
  get srvPrefix(): string;
142
148
  dnsRecordsForDomainName(domainName: any, hasSVRRecords: any): {
143
149
  key: any;