pmcf 3.21.2 → 4.0.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": "3.21.2",
3
+ "version": "4.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/module.mjs CHANGED
@@ -27,7 +27,7 @@ export * from "./services/influxdb.mjs";
27
27
  export * from "./services/mosquitto.mjs";
28
28
  export * from "./services/headscale.mjs";
29
29
  export * from "./services/tailscale.mjs";
30
- export * from "./services/systemd-journal.mjs";
30
+ export * from "./services/systemd-journald.mjs";
31
31
  export * from "./services/systemd-journal-remote.mjs";
32
32
  export * from "./services/systemd-journal-upload.mjs";
33
33
  export * from "./services/systemd-timesyncd.mjs";
@@ -1,8 +1,13 @@
1
1
  import { join } from "node:path";
2
2
  import { FileContentProvider } from "npm-pkgbuild";
3
- import { boolean_attribute_writable_true, addType } from "pacc";
3
+ import {
4
+ boolean_attribute_writable_true,
5
+ port_attribute,
6
+ string_attribute_writable,
7
+ addType
8
+ } from "pacc";
4
9
  import { addServiceType } from "pmcf";
5
- import { writeLines } from "../utils.mjs";
10
+ import { writeLines, filterConfigurable } from "../utils.mjs";
6
11
  import { Service, ServiceTypeDefinition } from "../service.mjs";
7
12
 
8
13
  const MosquittoServiceTypeDefinition = {
@@ -12,13 +17,30 @@ const MosquittoServiceTypeDefinition = {
12
17
  owners: ServiceTypeDefinition.owners,
13
18
  key: "name",
14
19
  attributes: {
15
- log_timestamp: {
20
+ /*log_timestamp: {
16
21
  ...boolean_attribute_writable_true,
17
- isCommonOption: true
22
+ configurable: true
18
23
  },
19
24
  allow_anonymous: {
20
25
  ...boolean_attribute_writable_true,
21
- isCommonOption: true
26
+ configurable: true
27
+ },*/
28
+ listener: {
29
+ ...port_attribute,
30
+ writable: true,
31
+ configurable: true
32
+ },
33
+ persistence_location: {
34
+ ...string_attribute_writable,
35
+ configurable: true
36
+ },
37
+ password_file: {
38
+ ...string_attribute_writable,
39
+ configurable: true
40
+ },
41
+ acl_file: {
42
+ ...string_attribute_writable,
43
+ configurable: true
22
44
  }
23
45
  },
24
46
  service: {
@@ -40,6 +62,10 @@ export class MosquittoService extends Service {
40
62
  return MosquittoServiceTypeDefinition.name;
41
63
  }
42
64
 
65
+ get listener() {
66
+ return this.endpoint("mqtt").port;
67
+ }
68
+
43
69
  async *preparePackages(dir) {
44
70
  const host = this.host;
45
71
  const name = host.name;
@@ -56,24 +82,14 @@ export class MosquittoService extends Service {
56
82
  }
57
83
  };
58
84
 
59
- const lines = Object.entries(MosquittoServiceTypeDefinition.attributes)
60
- .filter(
61
- ([key, attribute]) =>
62
- attribute.isCommonOption && this[key] !== undefined
85
+ await writeLines(
86
+ join(dir, "etc", "mosquitto"),
87
+ "mosquitto.conf",
88
+ Object.entries(this.getProperties(filterConfigurable)).map(
89
+ ([name, value]) => `${name} ${value}`
63
90
  )
64
- .map(([key]) => `${key}: ${this[key]}`);
65
-
66
- const endpoint = this.endpoint("mqtt");
67
-
68
- lines.push(
69
- `listener ${endpoint.port}`,
70
- "persistence_location /var/lib/mosquitto",
71
- "password_file /etc/mosquitto/passwd",
72
- "acl_file /etc/mosquitto/acl"
73
91
  );
74
92
 
75
- await writeLines(join(dir, "etc", "mosquitto"), "mosquitto.conf", lines);
76
-
77
93
  yield packageData;
78
94
  }
79
95
  }
@@ -105,12 +105,10 @@ export class SystemdJournalRemoteService extends Service {
105
105
  * @returns {Object}
106
106
  */
107
107
  systemdConfigs(name) {
108
- return [
109
- {
110
- serviceName: "systemd-journal-remote.service",
111
- configFileName: `etc/systemd/journal-remote.conf.d/${name}.conf`,
112
- content: ["Remote", this.getProperties(filterConfigurable)]
113
- }
114
- ];
108
+ return {
109
+ serviceName: `${this.type}.service`,
110
+ configFileName: `etc/systemd/journal-remote.conf.d/${name}.conf`,
111
+ content: ["Remote", this.getProperties(filterConfigurable)]
112
+ };
115
113
  }
116
114
  }
@@ -73,7 +73,7 @@ export class SystemdJournalUploadService extends Service {
73
73
  */
74
74
  systemdConfigs(name) {
75
75
  return {
76
- serviceName: "systemd-journal-upload.service",
76
+ serviceName: `${this.type}.service`,
77
77
  configFileName: `etc/systemd/journal-upload.conf.d/${name}.conf`,
78
78
  content: ["Upload", this.getProperties(filterConfigurable)]
79
79
  };
@@ -7,7 +7,7 @@ import { Service, ServiceTypeDefinition, addServiceType } from "pmcf";
7
7
  import { filterConfigurable } from "../utils.mjs";
8
8
 
9
9
  const SystemdJournalServiceTypeDefinition = {
10
- name: "systemd-journal",
10
+ name: "systemd-journald",
11
11
  extends: ServiceTypeDefinition,
12
12
  specializationOf: ServiceTypeDefinition,
13
13
  owners: ServiceTypeDefinition.owners,
@@ -109,7 +109,7 @@ const SystemdJournalServiceTypeDefinition = {
109
109
  service: {}
110
110
  };
111
111
 
112
- export class SystemdJournalService extends Service {
112
+ export class SystemdJournaldService extends Service {
113
113
  static {
114
114
  addType(this);
115
115
  addServiceType(this.typeDefinition.service, this.typeDefinition.name);
@@ -129,7 +129,7 @@ export class SystemdJournalService extends Service {
129
129
 
130
130
  systemdConfigs(name) {
131
131
  return {
132
- serviceName: "systemd-journald.service",
132
+ serviceName: `${this.type}.service`,
133
133
  configFileName: `etc/systemd/journal.conf.d/${name}.conf`,
134
134
  content: ["Journal", this.getProperties(filterConfigurable)]
135
135
  };
@@ -76,7 +76,7 @@ export class SystemdResolvedService extends ExtraSourceService {
76
76
  };
77
77
 
78
78
  return {
79
- serviceName: "systemd-resolved.service",
79
+ serviceName: `${this.type}.service`,
80
80
  configFileName: `etc/systemd/resolved.conf.d/${name}.conf`,
81
81
  content: [
82
82
  "Resolve",
@@ -19,13 +19,13 @@ const SystemdTimesyncdServiceTypeDefinition = {
19
19
  owners: ServiceTypeDefinition.owners,
20
20
 
21
21
  attributes: {
22
- NTP: {...string_attribute_writable, configurable: true },
23
- FallbackNTP: {...string_attribute_writable, configurable: true },
24
- RootDistanceMaxSec: {...duration_attribute_writable, configurable: true },
25
- PollIntervalMinSec: {...duration_attribute_writable, configurable: true },
26
- PollIntervalMaxSec: {...duration_attribute_writable, configurable: true },
27
- ConnectionRetrySec: {...duration_attribute_writable, configurable: true },
28
- SaveIntervalSec: {...duration_attribute_writable, configurable: true }
22
+ NTP: { ...string_attribute_writable, configurable: true },
23
+ FallbackNTP: { ...string_attribute_writable, configurable: true },
24
+ RootDistanceMaxSec: { ...duration_attribute_writable, configurable: true },
25
+ PollIntervalMinSec: { ...duration_attribute_writable, configurable: true },
26
+ PollIntervalMaxSec: { ...duration_attribute_writable, configurable: true },
27
+ ConnectionRetrySec: { ...duration_attribute_writable, configurable: true },
28
+ SaveIntervalSec: { ...duration_attribute_writable, configurable: true }
29
29
  },
30
30
  service: {}
31
31
  };
@@ -61,7 +61,7 @@ export class SystemdTimesyncdService extends ExtraSourceService {
61
61
  };
62
62
 
63
63
  return {
64
- serviceName: "systemd-timesyncd.service",
64
+ serviceName: `${this.type}.service`,
65
65
  configFileName: `etc/systemd/timesyncd.conf.d/${name}.conf`,
66
66
  content: [
67
67
  "Time",
@@ -27,7 +27,7 @@ export * from "./services/influxdb.mjs";
27
27
  export * from "./services/mosquitto.mjs";
28
28
  export * from "./services/headscale.mjs";
29
29
  export * from "./services/tailscale.mjs";
30
- export * from "./services/systemd-journal.mjs";
30
+ export * from "./services/systemd-journald.mjs";
31
31
  export * from "./services/systemd-journal-remote.mjs";
32
32
  export * from "./services/systemd-journal-upload.mjs";
33
33
  export * from "./services/systemd-timesyncd.mjs";
@@ -743,8 +743,52 @@ export class MosquittoService extends Service {
743
743
  })[];
744
744
  key: string;
745
745
  attributes: {
746
- log_timestamp: {
747
- isCommonOption: boolean;
746
+ listener: {
747
+ writable: boolean;
748
+ configurable: boolean;
749
+ type: object;
750
+ isKey: boolean;
751
+ mandatory: boolean;
752
+ collection: boolean;
753
+ private?: boolean;
754
+ credential?: boolean;
755
+ persistent?: boolean;
756
+ depends?: string;
757
+ description?: string;
758
+ default?: any;
759
+ set?: Function;
760
+ get?: Function;
761
+ toInternal?: Function;
762
+ toExternal?: Function;
763
+ values?: Set<any>;
764
+ externalName?: string;
765
+ env?: string[] | string;
766
+ additionalValues?: object;
767
+ };
768
+ persistence_location: {
769
+ configurable: boolean;
770
+ type: object;
771
+ isKey: boolean;
772
+ writable: boolean;
773
+ mandatory: boolean;
774
+ collection: boolean;
775
+ private?: boolean;
776
+ credential?: boolean;
777
+ persistent?: boolean;
778
+ depends?: string;
779
+ description?: string;
780
+ default?: any;
781
+ set?: Function;
782
+ get?: Function;
783
+ toInternal?: Function;
784
+ toExternal?: Function;
785
+ values?: Set<any>;
786
+ externalName?: string;
787
+ env?: string[] | string;
788
+ additionalValues?: object;
789
+ };
790
+ password_file: {
791
+ configurable: boolean;
748
792
  type: object;
749
793
  isKey: boolean;
750
794
  writable: boolean;
@@ -765,8 +809,8 @@ export class MosquittoService extends Service {
765
809
  env?: string[] | string;
766
810
  additionalValues?: object;
767
811
  };
768
- allow_anonymous: {
769
- isCommonOption: boolean;
812
+ acl_file: {
813
+ configurable: boolean;
770
814
  type: object;
771
815
  isKey: boolean;
772
816
  writable: boolean;
@@ -793,6 +837,7 @@ export class MosquittoService extends Service {
793
837
  };
794
838
  };
795
839
  get type(): string;
840
+ get listener(): any;
796
841
  preparePackages(dir: any): AsyncGenerator<{
797
842
  dir: any;
798
843
  sources: FileContentProvider[];
@@ -1,4 +1,4 @@
1
- export class SystemdJournalService extends Service {
1
+ export class SystemdJournaldService extends Service {
2
2
  static get typeDefinition(): {
3
3
  name: string;
4
4
  extends: {