pmcf 2.7.0 → 2.8.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": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/host.mjs CHANGED
@@ -107,7 +107,7 @@ export class Host extends Base {
107
107
  if (data.extends) {
108
108
  this.finalize(() => {
109
109
  for (const host of this.extends) {
110
- if(host === this) {
110
+ if (host === this) {
111
111
  this.error("Cant extend myself");
112
112
  }
113
113
  host.execFinalize();
@@ -637,11 +637,13 @@ export class NetworkInterface extends Base {
637
637
  return this;
638
638
  }
639
639
 
640
+ extendedProperty(name) {
641
+ return this.extends.find(i => i[name])?.[name];
642
+ }
643
+
640
644
  get network() {
641
645
  return (
642
- this._network ??
643
- this.extends.find(i => i.network)?.network ??
644
- this.host.network
646
+ this._network ?? this.extendedProperty("_network") ?? this.host.network
645
647
  );
646
648
  }
647
649
 
@@ -656,7 +658,7 @@ export class NetworkInterface extends Base {
656
658
  get scope() {
657
659
  return (
658
660
  this._scope ??
659
- this.extends.find(i => i.scope)?.scope ??
661
+ this.extendedProperty("_scope") ??
660
662
  this.network?.scope ??
661
663
  "global"
662
664
  );
@@ -667,7 +669,7 @@ export class NetworkInterface extends Base {
667
669
  }
668
670
 
669
671
  get hwaddr() {
670
- return this._hwaddr ?? this.extends.find(i => i._hwaddr)?._hwaddr;
672
+ return this._hwaddr ?? this.extendedProperty("_hwaddr");
671
673
  }
672
674
 
673
675
  set metric(value) {
@@ -675,7 +677,12 @@ export class NetworkInterface extends Base {
675
677
  }
676
678
 
677
679
  get metric() {
678
- return this._metric ?? this.network?.metric ?? 1004;
680
+ return (
681
+ this._metric ??
682
+ this.extendedProperty("_metric") ??
683
+ this.network?.metric ??
684
+ 1004
685
+ );
679
686
  }
680
687
 
681
688
  set ssid(value) {
@@ -683,9 +690,7 @@ export class NetworkInterface extends Base {
683
690
  }
684
691
 
685
692
  get ssid() {
686
- return (
687
- this._ssid ?? this.extends.find(i => i.ssid)?.ssid ?? this.network?.ssid
688
- );
693
+ return this._ssid ?? this.extendedProperty("_ssid") ?? this.network?.ssid;
689
694
  }
690
695
 
691
696
  set psk(value) {
@@ -693,7 +698,7 @@ export class NetworkInterface extends Base {
693
698
  }
694
699
 
695
700
  get psk() {
696
- return this._psk ?? this.extends.find(i => i.psk)?.psk ?? this.network?.psk;
701
+ return this._psk ?? this.extendedProperty("_psk") ?? this.network?.psk;
697
702
  }
698
703
 
699
704
  set kind(value) {
@@ -702,7 +707,7 @@ export class NetworkInterface extends Base {
702
707
 
703
708
  get kind() {
704
709
  return (
705
- this._kind ?? this.extends.find(i => i.kind)?.kind ?? this.network?.kind
710
+ this._kind ?? this.extendedProperty("_kind") ?? this.network?.kind
706
711
  );
707
712
  }
708
713
  }
@@ -1,6 +1,12 @@
1
+ import { join } from "node:path";
2
+ import { FileContentProvider } from "npm-pkgbuild";
1
3
  import { addType } from "../types.mjs";
2
4
  import { ServiceTypeDefinition, serviceAddresses } from "../service.mjs";
3
- import { ExtraSourceService, ExtraSourceServiceTypeDefinition } from "../extra-source-service.mjs";
5
+ import {
6
+ ExtraSourceService,
7
+ ExtraSourceServiceTypeDefinition
8
+ } from "../extra-source-service.mjs";
9
+ import { writeLines } from "../utils.mjs";
4
10
 
5
11
  const NTPServiceTypeDefinition = {
6
12
  name: "ntp",
@@ -47,4 +53,45 @@ export class NTPService extends ExtraSourceService {
47
53
  }
48
54
  ];
49
55
  }
56
+
57
+ async *preparePackages(dir) {
58
+ const network = this.network;
59
+ const host = this.server;
60
+ const name = host.name;
61
+
62
+ console.log("chrony", host.name, network.name);
63
+
64
+ const packageData = {
65
+ dir,
66
+ sources: [new FileContentProvider(dir + "/")[Symbol.asyncIterator]()],
67
+ outputs: this.outputs,
68
+ properties: {
69
+ name: `chrony-${this.location.name}-${host.name}`,
70
+ description: `chrony definitions for ${this.fullName}@${name}`,
71
+ access: "private",
72
+ dependencies: ["chrony>=4.6.1"]
73
+ }
74
+ };
75
+
76
+ const lines = [
77
+ ...serviceAddresses(this, {
78
+ ...NTP_SERVICE_FILTER,
79
+ priority: ">=10"
80
+ }).map(address => `server ${address} iburst`),
81
+ `mailonchange ${this.administratorEmail} 0.5`,
82
+ "local stratum 10",
83
+ "leapsectz right/UTC",
84
+ "makestep 1.0 3",
85
+ "ratelimit interval 3 burst 8",
86
+ "cmdratelimit interval -4 burst 16",
87
+ "driftfile /var/lib/chrony/drift",
88
+ "ntsdumpdir /var/lib/chrony",
89
+ "dumpdir /var/lib/chrony",
90
+ "pidfile /run/chrony/chronyd.pid"
91
+ ];
92
+
93
+ await writeLines(join(dir, "etc"), "chrony.conf", lines);
94
+
95
+ yield packageData;
96
+ }
50
97
  }
package/types/host.d.mts CHANGED
@@ -432,6 +432,7 @@ export class NetworkInterface extends Base {
432
432
  get hostName(): any;
433
433
  get domainNames(): any;
434
434
  get network_interface(): this;
435
+ extendedProperty(name: any): any;
435
436
  set network(network: any);
436
437
  get network(): any;
437
438
  set scope(value: any);
@@ -264,5 +264,16 @@ export class NTPService extends ExtraSourceService {
264
264
  get systemdConfig(): (string | {
265
265
  NTP: string;
266
266
  })[];
267
+ preparePackages(dir: any): AsyncGenerator<{
268
+ dir: any;
269
+ sources: AsyncIterable<import("content-entry").ContentEntry>[];
270
+ outputs: Set<typeof import("npm-pkgbuild").ARCH | typeof import("npm-pkgbuild").DOCKER>;
271
+ properties: {
272
+ name: string;
273
+ description: string;
274
+ access: string;
275
+ dependencies: string[];
276
+ };
277
+ }, void, unknown>;
267
278
  }
268
279
  import { ExtraSourceService } from "../extra-source-service.mjs";