pmcf 4.5.3 → 4.5.5
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 +1 -1
- package/src/hooks.mjs +8 -8
- package/src/host.mjs +7 -7
- package/src/location.mjs +6 -5
- package/src/services/openldap.mjs +23 -27
- package/types/hooks.d.mts +2 -2
- package/types/host.d.mts +0 -1
- package/types/location.d.mts +0 -1
- package/types/services/openldap.d.mts +1 -1
package/package.json
CHANGED
package/src/hooks.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { createReadStream } from "node:fs";
|
|
2
2
|
import { extractFunctions } from "npm-pkgbuild";
|
|
3
3
|
|
|
4
|
-
export async function loadHooks(
|
|
4
|
+
export async function loadHooks(packageData, file) {
|
|
5
5
|
for await (const f of extractFunctions(createReadStream(file, "utf8"))) {
|
|
6
|
-
addHook(
|
|
6
|
+
addHook(packageData, f.name, f.body);
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
return hooks;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
export function addHook(
|
|
13
|
-
|
|
10
|
+
export function addHook(packageData, name, content) {
|
|
11
|
+
packageData.properties.hooks ||= {};
|
|
12
|
+
|
|
13
|
+
const hook = packageData.properties.hooks[name];
|
|
14
14
|
if (hook) {
|
|
15
15
|
content = hook + "\n" + content;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
hooks[name] = content;
|
|
18
|
+
packageData.properties.hooks[name] = content;
|
|
19
19
|
|
|
20
|
-
return hooks;
|
|
20
|
+
return packageData.properties.hooks;
|
|
21
21
|
}
|
package/src/host.mjs
CHANGED
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
domainFromDominName,
|
|
18
18
|
domainName,
|
|
19
19
|
writeLines,
|
|
20
|
-
sectionLines,
|
|
21
20
|
asArray
|
|
22
21
|
} from "./utils.mjs";
|
|
23
22
|
import { loadHooks } from "./hooks.mjs";
|
|
@@ -451,14 +450,15 @@ export class Host extends ServiceOwner {
|
|
|
451
450
|
provides: [...this.provides],
|
|
452
451
|
replaces: [...this.replaces],
|
|
453
452
|
requires: [],
|
|
454
|
-
backup: "root/.ssh/known_hosts"
|
|
455
|
-
hooks: await loadHooks(
|
|
456
|
-
{},
|
|
457
|
-
new URL("host.install", import.meta.url).pathname
|
|
458
|
-
)
|
|
453
|
+
backup: "root/.ssh/known_hosts"
|
|
459
454
|
}
|
|
460
455
|
};
|
|
461
456
|
|
|
457
|
+
await loadHooks(
|
|
458
|
+
packageData,
|
|
459
|
+
new URL("host.install", import.meta.url).pathname
|
|
460
|
+
);
|
|
461
|
+
|
|
462
462
|
for (const ni of this.networkInterfaces.values()) {
|
|
463
463
|
await ni.systemdDefinitions(packageData);
|
|
464
464
|
}
|
|
@@ -478,7 +478,7 @@ export class Host extends ServiceOwner {
|
|
|
478
478
|
await writeLines(dir, configFileName, content);
|
|
479
479
|
|
|
480
480
|
addHook(
|
|
481
|
-
packageData
|
|
481
|
+
packageData,
|
|
482
482
|
"post_install",
|
|
483
483
|
`systemctl enable ${serviceName}`
|
|
484
484
|
);
|
package/src/location.mjs
CHANGED
|
@@ -55,14 +55,15 @@ export class Location extends Owner {
|
|
|
55
55
|
access: "private",
|
|
56
56
|
dependencies: { jq: ">=1.8" },
|
|
57
57
|
provides: ["location", "mf-location"],
|
|
58
|
-
replaces: [`mf-location-${this.name}`]
|
|
59
|
-
hooks: await loadHooks(
|
|
60
|
-
{},
|
|
61
|
-
new URL("location.install", import.meta.url).pathname
|
|
62
|
-
)
|
|
58
|
+
replaces: [`mf-location-${this.name}`]
|
|
63
59
|
}
|
|
64
60
|
};
|
|
65
61
|
|
|
62
|
+
await loadHooks(
|
|
63
|
+
packageData,
|
|
64
|
+
new URL("location.install", import.meta.url).pathname
|
|
65
|
+
);
|
|
66
|
+
|
|
66
67
|
yield packageData;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
@@ -98,6 +98,25 @@ export class OpenLDAPService extends Service {
|
|
|
98
98
|
this._uri = value;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
templateContent(entryProperties, directoryProperties) {
|
|
102
|
+
const transformers = [
|
|
103
|
+
createExpressionTransformer(e => true, {
|
|
104
|
+
base: this.baseDN,
|
|
105
|
+
uri: this.uri
|
|
106
|
+
})
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
return [...this.allExtends(), this].map(e => {
|
|
110
|
+
const dir = join(e.directory, "content") + "/";
|
|
111
|
+
console.log("DIR", dir);
|
|
112
|
+
|
|
113
|
+
return transform(
|
|
114
|
+
new FileContentProvider(dir, entryProperties, directoryProperties),
|
|
115
|
+
transformers
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
101
120
|
async *preparePackages(dir) {
|
|
102
121
|
const host = this.host;
|
|
103
122
|
const name = host.name;
|
|
@@ -114,33 +133,11 @@ export class OpenLDAPService extends Service {
|
|
|
114
133
|
owner,
|
|
115
134
|
group
|
|
116
135
|
};
|
|
117
|
-
const transformers = [
|
|
118
|
-
createExpressionTransformer(e => true, {
|
|
119
|
-
base: this.baseDN,
|
|
120
|
-
uri: this.uri
|
|
121
|
-
})
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
const templateDirs = [];
|
|
125
|
-
for (const e of [...this.allExtends(), this]) {
|
|
126
|
-
const dir = join(e.directory, "content") + "/";
|
|
127
|
-
console.log("DIR", dir);
|
|
128
|
-
templateDirs.push(
|
|
129
|
-
transform(
|
|
130
|
-
new FileContentProvider(
|
|
131
|
-
{ transformers, dir },
|
|
132
|
-
entryProperties,
|
|
133
|
-
directoryProperties
|
|
134
|
-
),
|
|
135
|
-
transformers
|
|
136
|
-
)
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
136
|
|
|
140
137
|
const packageData = {
|
|
141
138
|
dir,
|
|
142
139
|
sources: [
|
|
143
|
-
...
|
|
140
|
+
...this.templateContent(entryProperties, directoryProperties),
|
|
144
141
|
new FileContentProvider(dir + "/", entryProperties, directoryProperties)
|
|
145
142
|
],
|
|
146
143
|
outputs: this.outputs,
|
|
@@ -148,19 +145,18 @@ export class OpenLDAPService extends Service {
|
|
|
148
145
|
name: `${this.typeName}-${this.location.name}-${name}`,
|
|
149
146
|
description: `${this.typeName} definitions for ${this.fullName}@${name}`,
|
|
150
147
|
access: "private",
|
|
151
|
-
dependencies: ["openldap>=2.6.10"]
|
|
152
|
-
hooks: {}
|
|
148
|
+
dependencies: ["openldap>=2.6.10"]
|
|
153
149
|
}
|
|
154
150
|
};
|
|
155
151
|
|
|
156
152
|
addHook(
|
|
157
|
-
packageData
|
|
153
|
+
packageData,
|
|
158
154
|
"post_upgrade",
|
|
159
155
|
`setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
|
|
160
156
|
);
|
|
161
157
|
|
|
162
158
|
addHook(
|
|
163
|
-
packageData
|
|
159
|
+
packageData,
|
|
164
160
|
"post_install",
|
|
165
161
|
`setfacl -m u:${owner}:r /etc/letsencrypt/archive/*/privkey*.pem`
|
|
166
162
|
);
|
package/types/hooks.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function loadHooks(
|
|
2
|
-
export function addHook(
|
|
1
|
+
export function loadHooks(packageData: any, file: any): Promise<void>;
|
|
2
|
+
export function addHook(packageData: any, name: any, content: any): any;
|
package/types/host.d.mts
CHANGED
package/types/location.d.mts
CHANGED
|
@@ -874,6 +874,7 @@ export class OpenLDAPService extends Service {
|
|
|
874
874
|
set uri(value: any);
|
|
875
875
|
get uri(): any;
|
|
876
876
|
_uri: any;
|
|
877
|
+
templateContent(entryProperties: any, directoryProperties: any): any[];
|
|
877
878
|
preparePackages(dir: any): AsyncGenerator<{
|
|
878
879
|
dir: any;
|
|
879
880
|
sources: any[];
|
|
@@ -883,7 +884,6 @@ export class OpenLDAPService extends Service {
|
|
|
883
884
|
description: string;
|
|
884
885
|
access: string;
|
|
885
886
|
dependencies: string[];
|
|
886
|
-
hooks: {};
|
|
887
887
|
};
|
|
888
888
|
}, void, unknown>;
|
|
889
889
|
}
|