pmcf 6.59.2 → 6.60.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": "6.59.2",
3
+ "version": "6.60.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -16,6 +16,7 @@ import {
16
16
  import { PROTOCOL_TCP, PROTOCOL_UDP, PROTOCOL_QUIC } from "./constants.mjs";
17
17
 
18
18
  export const SCOPE_SYSTEMD_NETWORKD = "systemd-networkd";
19
+ export const SCOPE_SYSTEMD_TIMESYNCD = "systemd-timesyncd";
19
20
 
20
21
  export const networkAddressType = "network|host|network_interface";
21
22
 
@@ -1,3 +1,4 @@
1
+ import { join } from "node:path";
1
2
  import {
2
3
  FAMILY_IPV4,
3
4
  FAMILY_IPV6,
@@ -10,7 +11,8 @@ import {
10
11
  number_attribute_writable,
11
12
  priority_attribute,
12
13
  default_collection_attribute_writable,
13
- asArray
14
+ asArray,
15
+ boolean_attribute_writable_false
14
16
  } from "pacc";
15
17
  import {
16
18
  base,
@@ -42,6 +44,12 @@ import {
42
44
  } from "./dns-utils.mjs";
43
45
 
44
46
  export class credential extends base {
47
+ static attributes = {
48
+ systemdCredential: {
49
+ ...boolean_attribute_writable_false,
50
+ name: "systemdCredential"
51
+ }
52
+ };
45
53
  static {
46
54
  addType(this);
47
55
  }
@@ -66,7 +74,7 @@ export class CoreService extends base {
66
74
  }
67
75
  static attributes = {
68
76
  ...networkAddressAttributes,
69
- // networkInterfaces: networkInterfaces_attribute,
77
+ // networkInterfaces: networkInterfaces_attribute,
70
78
 
71
79
  ...endpointAttributes,
72
80
  extends: {
@@ -270,6 +278,25 @@ export class CoreService extends base {
270
278
  return serviceTypes(ServiceTypes[this.type]);
271
279
  }
272
280
 
281
+ async writeSystemdCredentialConfig(dir, name) {
282
+ let lines = [];
283
+ for (const [name, cred] of this.credentials) {
284
+ if (cred.systemdCredential) {
285
+ lines.push(
286
+ `LoadCredentialEncrypted=${name}:/etc/credstore.encrypted/${name}`
287
+ );
288
+ }
289
+ }
290
+
291
+ if (lines.length) {
292
+ await writeLines(
293
+ join(dir, `etc/systemd/system/${name}.service.d`),
294
+ `credentials.conf`,
295
+ lines
296
+ );
297
+ }
298
+ }
299
+
273
300
  get systemdService() {
274
301
  return (
275
302
  this.attribute("_systemdService") ??
@@ -4,8 +4,10 @@ import {
4
4
  string_attribute_writable,
5
5
  string_set_attribute_writable
6
6
  } from "pacc";
7
- import { addType, CoreService, base } from "pmcf";
7
+ import { base } from "../base.mjs";
8
+ import { CoreService } from "../core-service.mjs";
8
9
  import { owner_attribute } from "../common-attributes.mjs";
10
+ import { addType } from "../type.mjs";
9
11
 
10
12
  class alpm_repository extends base {
11
13
  static attributes = {
@@ -404,7 +404,9 @@ export class kea extends CoreService {
404
404
 
405
405
  if (addr && subnet.matchesAddress(addr)) {
406
406
  ip =
407
- family === "6" ? { "ip-addresses": [addr] } : { "ip-address": addr };
407
+ family === "6"
408
+ ? { "ip-addresses": [addr] }
409
+ : { "ip-address": addr };
408
410
  }
409
411
 
410
412
  let ids = { "hw-address": k };
@@ -468,6 +470,9 @@ export class kea extends CoreService {
468
470
 
469
471
  const packageData = await this.preparePackage(dir);
470
472
 
473
+ await this.writeSystemdCredentialConfig(dir, "kea-dhcp4");
474
+ await this.writeSystemdCredentialConfig(dir, "kea-dhcp6");
475
+
471
476
  for (const [name, data] of Object.entries({
472
477
  "kea-dhcp-ddns": ddns,
473
478
  "kea-dhcp4": dhcp4,
@@ -1,40 +1,46 @@
1
1
  import { string_attribute_writable, duration_attribute_writable } from "pacc";
2
- import { ExtraSourceService, serviceEndpoints, addType } from "pmcf";
3
- import { filterConfigurable, sectionLines } from "../utils.mjs";
2
+ import { ExtraSourceService, serviceEndpoints } from "pmcf";
3
+ import { sectionLines } from "../utils.mjs";
4
+ import { SCOPE_SYSTEMD_TIMESYNCD } from "../common-attributes.mjs";
5
+ import { addType } from "../type.mjs";
4
6
 
5
7
  export class SystemdTimesyncdService extends ExtraSourceService {
6
8
  static name = "systemd-timesyncd";
7
9
  static attributes = {
8
- NTP: { ...string_attribute_writable, name: "NTP", configurable: true },
10
+ NTP: {
11
+ ...string_attribute_writable,
12
+ name: "NTP",
13
+ scope: SCOPE_SYSTEMD_TIMESYNCD
14
+ },
9
15
  FallbackNTP: {
10
16
  ...string_attribute_writable,
11
17
  name: "FallbackNTP",
12
- configurable: true
18
+ scope: SCOPE_SYSTEMD_TIMESYNCD
13
19
  },
14
20
  RootDistanceMaxSec: {
15
21
  ...duration_attribute_writable,
16
22
  name: "RootDistanceMaxSec",
17
- configurable: true
23
+ scope: SCOPE_SYSTEMD_TIMESYNCD
18
24
  },
19
25
  PollIntervalMinSec: {
20
26
  ...duration_attribute_writable,
21
27
  name: "PollIntervalMinSec",
22
- configurable: true
28
+ scope: SCOPE_SYSTEMD_TIMESYNCD
23
29
  },
24
30
  PollIntervalMaxSec: {
25
31
  ...duration_attribute_writable,
26
32
  name: "PollIntervalMaxSec",
27
- configurable: true
33
+ scope: SCOPE_SYSTEMD_TIMESYNCD
28
34
  },
29
35
  ConnectionRetrySec: {
30
36
  ...duration_attribute_writable,
31
37
  name: "ConnectionRetrySec",
32
- configurable: true
38
+ scope: SCOPE_SYSTEMD_TIMESYNCD
33
39
  },
34
40
  SaveIntervalSec: {
35
41
  ...duration_attribute_writable,
36
42
  name: "SaveIntervalSec",
37
- configurable: true
43
+ scope: SCOPE_SYSTEMD_TIMESYNCD
38
44
  }
39
45
  };
40
46
  static service = {
@@ -63,7 +69,9 @@ export class SystemdTimesyncdService extends ExtraSourceService {
63
69
  content: sectionLines("Time", {
64
70
  NTP: serviceEndpoints(this, options(300, 399)),
65
71
  FallbackNTP: serviceEndpoints(this, options(100, 199)),
66
- ...this.getAttributes(filterConfigurable)
72
+ ...this.getAttributes(
73
+ attribute => attribute.scope === SCOPE_SYSTEMD_TIMESYNCD
74
+ )
67
75
  })
68
76
  };
69
77
  }