iobroker.bee 0.2.2 → 0.2.4
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/README.md +32 -4
- package/admin/jsonConfig.json +23 -5
- package/build/lib/commands.js +12 -0
- package/build/lib/commands.js.map +1 -1
- package/build/lib/instances.js +67 -0
- package/build/lib/instances.js.map +1 -0
- package/build/lib/inventory.js +14 -2
- package/build/lib/inventory.js.map +1 -1
- package/build/lib/jobs.js +122 -3
- package/build/lib/jobs.js.map +1 -1
- package/build/lib/node.js +239 -0
- package/build/lib/node.js.map +1 -0
- package/build/lib/planner.js +25 -7
- package/build/lib/planner.js.map +1 -1
- package/build/lib/preflight.js +7 -0
- package/build/lib/preflight.js.map +1 -1
- package/build/lib/protocol.js.map +1 -1
- package/build/main.js +67 -9
- package/build/main.js.map +1 -1
- package/build/runner.js +8 -0
- package/build/runner.js.map +1 -1
- package/io-package.json +10 -2
- package/package.json +3 -2
- package/scripts/node-update.sh +134 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NODE_VERDICT = exports.NODE_STATUS = void 0;
|
|
7
|
+
exports.majorOf = majorOf;
|
|
8
|
+
exports.nodeStep = nodeStep;
|
|
9
|
+
exports.serviceOf = serviceOf;
|
|
10
|
+
exports.nodeBlockers = nodeBlockers;
|
|
11
|
+
exports.engineConflicts = engineConflicts;
|
|
12
|
+
exports.readEngines = readEngines;
|
|
13
|
+
exports.nodeFacts = nodeFacts;
|
|
14
|
+
exports.nodeUnit = nodeUnit;
|
|
15
|
+
exports.launchNodeUpdate = launchNodeUpdate;
|
|
16
|
+
exports.unitActive = unitActive;
|
|
17
|
+
exports.readNodeStatus = readNodeStatus;
|
|
18
|
+
exports.readVerdict = readVerdict;
|
|
19
|
+
exports.writeVerdict = writeVerdict;
|
|
20
|
+
const node_child_process_1 = require("node:child_process");
|
|
21
|
+
const node_fs_1 = require("node:fs");
|
|
22
|
+
const promises_1 = require("node:fs/promises");
|
|
23
|
+
const node_path_1 = require("node:path");
|
|
24
|
+
const semver_1 = __importDefault(require("semver"));
|
|
25
|
+
const util_1 = require("./util");
|
|
26
|
+
/**
|
|
27
|
+
* Update of Node.js to the major line of the profile (DesiredProfile.node), only upwards.
|
|
28
|
+
*
|
|
29
|
+
* Node.js comes from the package nodejs of NodeSource, as the installer of ioBroker sets it up. The update
|
|
30
|
+
* stops ioBroker, so the agent cannot do it itself: it starts scripts/node-update.sh as root in a systemd
|
|
31
|
+
* unit of its own (sudo systemd-run, which the installer allows the user iobroker). After the restart the
|
|
32
|
+
* agent checks under the new Node.js that the instances that ran before run again and writes its verdict;
|
|
33
|
+
* without a positive verdict the script installs the old package again. Files in the data directory:
|
|
34
|
+
* node-status.json (script), node-verdict.json (agent), node-update.log.
|
|
35
|
+
*/
|
|
36
|
+
exports.NODE_STATUS = 'node-status.json';
|
|
37
|
+
exports.NODE_VERDICT = 'node-verdict.json';
|
|
38
|
+
const NODE_SCRIPT = 'node-update.sh';
|
|
39
|
+
/** Major line of a version, e.g. 22 for "v22.11.0", "22" or "22.x" */
|
|
40
|
+
function majorOf(version) {
|
|
41
|
+
return semver_1.default.coerce(version ?? '')?.major || null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The step that brings Node.js to the major line of the profile; null if it runs that line already, or a
|
|
45
|
+
* newer one (no downgrades)
|
|
46
|
+
*
|
|
47
|
+
* @param target DesiredProfile.node, e.g. "22"
|
|
48
|
+
* @param current process.version
|
|
49
|
+
*/
|
|
50
|
+
function nodeStep(target, current) {
|
|
51
|
+
const want = majorOf(target);
|
|
52
|
+
const have = majorOf(current);
|
|
53
|
+
if (!want || !have || want <= have) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return { action: 'node', from: current, to: String(want), status: 'pending' };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The systemd service ioBroker runs in, from /proc/self/cgroup, e.g. "iobroker.service"
|
|
60
|
+
*
|
|
61
|
+
* @param cgroup content of /proc/self/cgroup
|
|
62
|
+
*/
|
|
63
|
+
function serviceOf(cgroup) {
|
|
64
|
+
return /\/system\.slice\/([^/\s]+\.service)/.exec(cgroup)?.[1] ?? null;
|
|
65
|
+
}
|
|
66
|
+
/** Reasons that block the update of Node.js; empty if it can run */
|
|
67
|
+
function nodeBlockers(f) {
|
|
68
|
+
if (f.platform !== 'linux') {
|
|
69
|
+
return ['nur unter Linux möglich'];
|
|
70
|
+
}
|
|
71
|
+
const errors = [];
|
|
72
|
+
if (!f.service) {
|
|
73
|
+
errors.push('ioBroker läuft nicht als systemd-Dienst');
|
|
74
|
+
}
|
|
75
|
+
if (!f.sudo) {
|
|
76
|
+
errors.push('kein sudo ohne Passwort für systemd-run (Installation mit --hardened?)');
|
|
77
|
+
}
|
|
78
|
+
if (!f.packaged || !f.source) {
|
|
79
|
+
errors.push('Node.js stammt nicht aus dem Paket nodejs von NodeSource');
|
|
80
|
+
}
|
|
81
|
+
else if (f.arch !== 'amd64' && f.arch !== 'arm64') {
|
|
82
|
+
errors.push(`NodeSource bietet für ${f.arch || 'diese Architektur'} kein Node.js an (nur amd64 und arm64)`);
|
|
83
|
+
}
|
|
84
|
+
if (f.held) {
|
|
85
|
+
errors.push('das Paket nodejs ist auf hold gesetzt');
|
|
86
|
+
}
|
|
87
|
+
if (!f.offDeviceBackup) {
|
|
88
|
+
errors.push('keine Sicherung außerhalb des Geräts (BackItUp)');
|
|
89
|
+
}
|
|
90
|
+
return errors;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Installed packages whose engines.node excludes the major line
|
|
94
|
+
*
|
|
95
|
+
* @param target major line, e.g. 22
|
|
96
|
+
* @param engines per package its version and engines.node
|
|
97
|
+
*/
|
|
98
|
+
function engineConflicts(target, engines) {
|
|
99
|
+
const line = `^${target}.0.0`;
|
|
100
|
+
return Object.entries(engines)
|
|
101
|
+
.filter(([, e]) => !!e.node && !!semver_1.default.validRange(e.node) && !semver_1.default.intersects(e.node, line))
|
|
102
|
+
.map(([name, e]) => `${name}@${e.version} verlangt Node ${e.node}`);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Version and engines.node of installed packages iobroker.<name>
|
|
106
|
+
*
|
|
107
|
+
* @param cwd directory of ioBroker, e.g. /opt/iobroker
|
|
108
|
+
* @param names adapters, "js-controller" for the controller
|
|
109
|
+
*/
|
|
110
|
+
function readEngines(cwd, names) {
|
|
111
|
+
const result = {};
|
|
112
|
+
for (const name of names) {
|
|
113
|
+
try {
|
|
114
|
+
const pkg = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(cwd, 'node_modules', `iobroker.${name}`, 'package.json'), 'utf8'));
|
|
115
|
+
const node = pkg.engines?.node;
|
|
116
|
+
result[name] = { version: String(pkg.version), ...(typeof node === 'string' ? { node } : {}) };
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// not installed as a package of its own
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
function run(cmd, args, timeout = 15_000) {
|
|
125
|
+
return new Promise(resolve => {
|
|
126
|
+
(0, node_child_process_1.execFile)(cmd, args, { timeout, windowsHide: true }, (error, stdout, stderr) => resolve({ ok: !error, out: String(stdout).trim(), err: String(stderr).trim() || error?.message || '' }));
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const isRoot = () => process.getuid?.() === 0;
|
|
130
|
+
/** Root runs systemd-run itself, everybody else with sudo -n */
|
|
131
|
+
function asRoot(args) {
|
|
132
|
+
return isRoot() ? [args[0], args.slice(1)] : ['sudo', ['-n', ...args]];
|
|
133
|
+
}
|
|
134
|
+
function realpath(path) {
|
|
135
|
+
try {
|
|
136
|
+
return (0, node_fs_1.realpathSync)(path);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const SOURCES = ['/etc/apt/sources.list.d/nodesource.sources', '/etc/apt/sources.list.d/nodesource.list'];
|
|
143
|
+
/**
|
|
144
|
+
* Looks at this system
|
|
145
|
+
*
|
|
146
|
+
* @param offDeviceBackup Inventory.backup.offDevice
|
|
147
|
+
*/
|
|
148
|
+
async function nodeFacts(offDeviceBackup) {
|
|
149
|
+
const facts = {
|
|
150
|
+
platform: process.platform,
|
|
151
|
+
service: null,
|
|
152
|
+
sudo: false,
|
|
153
|
+
arch: null,
|
|
154
|
+
packaged: false,
|
|
155
|
+
source: false,
|
|
156
|
+
held: false,
|
|
157
|
+
offDeviceBackup,
|
|
158
|
+
};
|
|
159
|
+
if (process.platform !== 'linux') {
|
|
160
|
+
return facts;
|
|
161
|
+
}
|
|
162
|
+
const binary = realpath(process.execPath);
|
|
163
|
+
const [cgroup, sudo, arch, owner, held] = await Promise.all([
|
|
164
|
+
(0, promises_1.readFile)('/proc/self/cgroup', 'utf8').catch(() => ''),
|
|
165
|
+
run(...asRoot(['systemd-run', '--version'])),
|
|
166
|
+
run('dpkg', ['--print-architecture']),
|
|
167
|
+
binary ? run('dpkg', ['-S', binary]) : Promise.resolve({ ok: false, out: '', err: '' }),
|
|
168
|
+
run('apt-mark', ['showhold', 'nodejs']),
|
|
169
|
+
]);
|
|
170
|
+
facts.service = serviceOf(cgroup);
|
|
171
|
+
facts.sudo = sudo.ok;
|
|
172
|
+
facts.arch = arch.ok ? arch.out : null;
|
|
173
|
+
facts.packaged = !!binary && binary === realpath('/usr/bin/node') && owner.ok && owner.out.startsWith('nodejs:');
|
|
174
|
+
facts.source = SOURCES.some(f => (0, node_fs_1.existsSync)(f) && /deb\.nodesource\.com\/node_\d+\.x/.test((0, node_fs_1.readFileSync)(f, 'utf8')));
|
|
175
|
+
facts.held = held.ok && held.out.split('\n').some(l => l.trim() === 'nodejs');
|
|
176
|
+
return facts;
|
|
177
|
+
}
|
|
178
|
+
/** Name of the systemd unit for an update of Node.js */
|
|
179
|
+
function nodeUnit(now = Date.now()) {
|
|
180
|
+
return `bee-node-${now}`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Starts scripts/node-update.sh as root in a unit of its own. It stops ioBroker, so this process ends soon.
|
|
184
|
+
*
|
|
185
|
+
* @param o what to start
|
|
186
|
+
* @param o.dir data directory of the agent
|
|
187
|
+
* @param o.target major line
|
|
188
|
+
* @param o.service systemd service of ioBroker
|
|
189
|
+
* @param o.unit name of the unit, see nodeUnit
|
|
190
|
+
* @param o.waitSeconds how long the script waits for the verdict of the agent
|
|
191
|
+
*/
|
|
192
|
+
async function launchNodeUpdate(o) {
|
|
193
|
+
await (0, promises_1.rm)((0, node_path_1.join)(o.dir, exports.NODE_STATUS), { force: true });
|
|
194
|
+
await (0, promises_1.rm)((0, node_path_1.join)(o.dir, exports.NODE_VERDICT), { force: true });
|
|
195
|
+
// a copy: the package of the agent may change while the script runs
|
|
196
|
+
const script = (0, node_path_1.join)(o.dir, NODE_SCRIPT);
|
|
197
|
+
await (0, promises_1.copyFile)((0, node_path_1.join)(__dirname, '..', '..', 'scripts', NODE_SCRIPT), script);
|
|
198
|
+
const r = await run(...asRoot([
|
|
199
|
+
'systemd-run',
|
|
200
|
+
`--unit=${o.unit}`,
|
|
201
|
+
'--collect',
|
|
202
|
+
'--quiet',
|
|
203
|
+
`--description=ioBroker.bee: Node.js ${o.target}`,
|
|
204
|
+
'/bin/bash',
|
|
205
|
+
script,
|
|
206
|
+
o.dir,
|
|
207
|
+
o.target,
|
|
208
|
+
o.service,
|
|
209
|
+
String(o.waitSeconds),
|
|
210
|
+
]));
|
|
211
|
+
if (!r.ok) {
|
|
212
|
+
throw new Error(`systemd-run: ${r.err || r.out || 'fehlgeschlagen'}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Whether the unit of the script is still there (it is removed when the script ends) */
|
|
216
|
+
async function unitActive(unit) {
|
|
217
|
+
return (await run('systemctl', ['is-active', '--quiet', unit])).ok;
|
|
218
|
+
}
|
|
219
|
+
function readNodeStatus(dir) {
|
|
220
|
+
return (0, util_1.readJson)((0, node_path_1.join)(dir, exports.NODE_STATUS));
|
|
221
|
+
}
|
|
222
|
+
/** Whether the agent already gave its verdict to the script, and which */
|
|
223
|
+
async function readVerdict(dir) {
|
|
224
|
+
return (0, util_1.readJson)((0, node_path_1.join)(dir, exports.NODE_VERDICT));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The verdict of the agent under the new Node.js. On one line: the script reads it with grep and sed.
|
|
228
|
+
*
|
|
229
|
+
* @param dir data directory of the agent
|
|
230
|
+
* @param ok the instances run, the script keeps the new Node.js
|
|
231
|
+
* @param reason otherwise why, the script goes back to the old one
|
|
232
|
+
*/
|
|
233
|
+
async function writeVerdict(dir, ok, reason = '') {
|
|
234
|
+
const file = (0, node_path_1.join)(dir, exports.NODE_VERDICT);
|
|
235
|
+
const data = ok ? { ok: true } : { ok: false, reason: reason.replace(/["\\\r\n]/g, ' ').slice(0, 400) };
|
|
236
|
+
await (0, promises_1.writeFile)(`${file}.tmp`, `${JSON.stringify(data)}\n`);
|
|
237
|
+
await (0, promises_1.rename)(`${file}.tmp`, file);
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/lib/node.ts"],"names":[],"mappings":";;;;;;AAiCA,0BAEC;AASD,4BAOC;AAOD,8BAEC;AAsBD,oCAuBC;AAQD,0CAKC;AAQD,kCAYC;AAgCD,8BA+BC;AAGD,4BAEC;AAYD,4CA8BC;AAGD,gCAEC;AAED,wCAEC;AAGD,kCAEC;AASD,oCAKC;AApRD,2DAA8C;AAC9C,qCAAiE;AACjE,+CAA6E;AAC7E,yCAAiC;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|
10
10
|
const semver_1 = __importDefault(require("semver"));
|
|
11
|
+
const node_1 = require("./node");
|
|
11
12
|
const util_1 = require("./util");
|
|
12
13
|
/** Adapters installed locally that are neither in the profile, tolerated, nor scheduled for removal */
|
|
13
14
|
function foreignAdapters(desired, installed) {
|
|
@@ -23,7 +24,7 @@ function foreignAdapters(desired, installed) {
|
|
|
23
24
|
.sort();
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
* Steps to reach the profile.
|
|
27
|
+
* Steps to reach the profile. Node.js comes first, the agent (bee) always last.
|
|
27
28
|
*
|
|
28
29
|
* @param desired desired state of the server
|
|
29
30
|
* @param installed installed versions
|
|
@@ -31,8 +32,9 @@ function foreignAdapters(desired, installed) {
|
|
|
31
32
|
* @param from where the adapters were installed from (installedFrom); with a package of the server and the
|
|
32
33
|
* same version installed from somewhere else, the package is installed once more (a build that kept
|
|
33
34
|
* the version number). Only given as long as that was not tried yet for this job.
|
|
35
|
+
* @param node the running Node.js (process.version); with it a step to the major line of the profile
|
|
34
36
|
*/
|
|
35
|
-
function computePlan(desired, installed, selfName = 'bee', from) {
|
|
37
|
+
function computePlan(desired, installed, selfName = 'bee', from, node) {
|
|
36
38
|
const steps = [];
|
|
37
39
|
if (!desired.profile) {
|
|
38
40
|
return steps;
|
|
@@ -63,12 +65,15 @@ function computePlan(desired, installed, selfName = 'bee', from) {
|
|
|
63
65
|
}
|
|
64
66
|
// removals first (frees space), then installs/updates alphabetically, the agent last
|
|
65
67
|
const rank = (s) => (s.adapter === selfName ? 2 : s.action === 'remove' ? 0 : 1);
|
|
66
|
-
|
|
68
|
+
steps.sort((a, b) => rank(a) - rank(b) || a.adapter.localeCompare(b.adapter));
|
|
69
|
+
// Node.js before everything else: the new versions may need it
|
|
70
|
+
const step = node ? (0, node_1.nodeStep)(desired.profile.node, node) : null;
|
|
71
|
+
return step ? [step, ...steps] : steps;
|
|
67
72
|
}
|
|
68
|
-
/** Steps that restore the previous state after a failed rollout (reverse order) */
|
|
73
|
+
/** Steps that restore the previous state after a failed rollout (reverse order); Node.js stays */
|
|
69
74
|
function rollbackPlan(steps) {
|
|
70
75
|
return steps
|
|
71
|
-
.filter(s => s.action !== 'backup' && s.status === 'ok')
|
|
76
|
+
.filter(s => s.action !== 'backup' && s.action !== 'node' && s.status === 'ok')
|
|
72
77
|
.reverse()
|
|
73
78
|
.map(s => {
|
|
74
79
|
if (s.action === 'install') {
|
|
@@ -90,6 +95,12 @@ function rollbackPlan(steps) {
|
|
|
90
95
|
* Checks the dependencies of all target versions against the state after the plan
|
|
91
96
|
* (io-package.json dependencies, globalDependencies and engines.node of the target version).
|
|
92
97
|
*
|
|
98
|
+
* @param desired desired state of the server
|
|
99
|
+
* @param installed installed versions
|
|
100
|
+
* @param env versions on the system
|
|
101
|
+
* @param env.jsController installed js-controller
|
|
102
|
+
* @param env.node running Node.js
|
|
103
|
+
* @param env.nodeMajor the major line the plan brings Node.js to before the adapters
|
|
93
104
|
* @returns list of violations; empty if everything fits
|
|
94
105
|
*/
|
|
95
106
|
function checkDependencies(desired, installed, env) {
|
|
@@ -108,8 +119,15 @@ function checkDependencies(desired, installed, env) {
|
|
|
108
119
|
if (installed[name] === a.version) {
|
|
109
120
|
continue;
|
|
110
121
|
}
|
|
111
|
-
if (a.node && semver_1.default.validRange(a.node)
|
|
112
|
-
|
|
122
|
+
if (a.node && semver_1.default.validRange(a.node)) {
|
|
123
|
+
if (env.nodeMajor) {
|
|
124
|
+
if (!semver_1.default.intersects(a.node, `^${env.nodeMajor}.0.0`)) {
|
|
125
|
+
errors.push(`${name}@${a.version} verlangt Node ${a.node}, geplant ist Node ${env.nodeMajor}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (!semver_1.default.satisfies(env.node, a.node)) {
|
|
129
|
+
errors.push(`${name}@${a.version} verlangt Node ${a.node}, installiert ist ${env.node}`);
|
|
130
|
+
}
|
|
113
131
|
}
|
|
114
132
|
for (const dep of [...(a.dependencies || []), ...(a.globalDependencies || [])]) {
|
|
115
133
|
for (const [depName, range] of Object.entries(dep)) {
|
package/build/lib/planner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/lib/planner.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/lib/planner.ts"],"names":[],"mappings":";;;;;AAeA,0CAcC;AAaD,kCAyCC;AAGD,oCAmBC;AAcD,8CAyCC;AAhKD,oDAA4B;AAC5B,iCAAkC;AAElC,iCAAyC;AAWzC,uGAAuG;AACvG,SAAgB,eAAe,CAAC,OAAuB,EAAE,SAAoB;IACzE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SACxB,MAAM,CACH,CAAC,CAAC,EAAE,CACA,CAAC,OAAO,CAAC,OAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC7B,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9B,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3B,2DAA2D;QAC3D,CAAC,KAAK,eAAe,CAC5B;SACA,IAAI,EAAE,CAAC;AAChB,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,WAAW,CACvB,OAAuB,EACvB,SAAoB,EACpB,QAAQ,GAAG,KAAK,EAChB,IAAyC,EACzC,IAAa;IAEb,MAAM,KAAK,GAAc,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpE,MAAM,O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C,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;oBACjG,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,OAAO,YAAY,OAAO,IAAI,KAAK,mBAAmB,IAAI,EAAE,CAAC,CAAC;gBAC3F,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/build/lib/preflight.js
CHANGED
|
@@ -57,6 +57,13 @@ async function preflight(input) {
|
|
|
57
57
|
if (input.dependencyErrors.length) {
|
|
58
58
|
return { ok: false, kind: 'block', reason: `Abhängigkeiten: ${input.dependencyErrors.join('; ')}` };
|
|
59
59
|
}
|
|
60
|
+
if (input.nodeErrors?.errors.length) {
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
kind: 'block',
|
|
64
|
+
reason: `Update auf Node.js ${input.nodeErrors.target} nicht möglich: ${input.nodeErrors.errors.join('; ')}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
60
67
|
const free = await freeDiskMb(input.diskPath);
|
|
61
68
|
if (free !== null && free < input.minFreeMb) {
|
|
62
69
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/lib/preflight.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/lib/preflight.ts"],"names":[],"mappings":";;AA8CA,0BAyBC;AAED,gCAOC;AAED,8BA2CC;AA7HD,+CAA0C;AAC1C,iCAAkC;AAkClC,SAAS,MAAM,CAAC,KAAa;IACzB,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,MAAM,CAAC;IACx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G,KAAK,KAAK,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACzG,CAAC;IACL,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/lib/protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAMH,kCAEC;AAED,oCAEC;AASD,4CAWC;
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/lib/protocol.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAMH,kCAEC;AAED,oCAEC;AASD,4CAWC;AAkHD,wCAMC;AAtJY,QAAA,gBAAgB,GAAG,CAAC,CAAC;AAIlC,SAAgB,WAAW,CAAC,QAAgB,EAAE,QAAgB,EAAE,KAAY;IACxE,OAAO,SAAS,QAAQ,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;AACpD,CAAC;AAED,SAAgB,YAAY,CAAC,QAAgB;IACzC,OAAO,SAAS,QAAQ,UAAU,CAAC;AACvC,CAAC;AAED,kFAAkF;AACrE,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEtC;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,CAAC,GAAG,KAAK;SACV,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC;SACzB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE;SACN,KAAK,CAAC,CAAC,EAAE,0BAAkB,CAAC;SAC5B,IAAI,EAAE,CAAC;IACZ,OAAO,CAAC,IAAI,SAAS,CAAC;AAC1B,CAAC;AA8GD;;;GAGG;AACH,SAAgB,cAAc,CAAC,IAAY;IACvC,MAAM,CAAC,GAAG,uEAAuE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACpG,IAAI,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,iEAAiE;AACpD,QAAA,WAAW,GAAG,gCAAgC,CAAC;AAwG/C,QAAA,YAAY,GAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAetE,0DAA0D;AAC7C,QAAA,WAAW,GAAG,SAAS,CAAC;AAyBxB,QAAA,mBAAmB,GAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
|
package/build/main.js
CHANGED
|
@@ -38,13 +38,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const utils = __importStar(require("@iobroker/adapter-core"));
|
|
40
40
|
const node_fs_1 = require("node:fs");
|
|
41
|
+
const promises_1 = require("node:fs/promises");
|
|
41
42
|
const node_os_1 = __importDefault(require("node:os"));
|
|
42
43
|
const node_path_1 = require("node:path");
|
|
43
44
|
const commands_1 = require("./lib/commands");
|
|
44
45
|
const console_1 = require("./lib/console");
|
|
46
|
+
const instances_1 = require("./lib/instances");
|
|
45
47
|
const enrollment_1 = require("./lib/enrollment");
|
|
46
48
|
const inventory_1 = require("./lib/inventory");
|
|
47
49
|
const jobs_1 = require("./lib/jobs");
|
|
50
|
+
const node_1 = require("./lib/node");
|
|
48
51
|
const packages_1 = require("./lib/packages");
|
|
49
52
|
const planner_1 = require("./lib/planner");
|
|
50
53
|
const preflight_1 = require("./lib/preflight");
|
|
@@ -53,6 +56,15 @@ const remote_1 = require("./lib/remote");
|
|
|
53
56
|
const transport_1 = require("./lib/transport");
|
|
54
57
|
const tunnel_1 = require("./lib/tunnel");
|
|
55
58
|
const util_1 = require("./lib/util");
|
|
59
|
+
/** Host of the broker for the status, e.g. "bee.iobroker.click" */
|
|
60
|
+
function hostOf(url) {
|
|
61
|
+
try {
|
|
62
|
+
return new URL(url || '').hostname || 'der Flottenverwaltung';
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return 'der Flottenverwaltung';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
56
68
|
class BeeAdapter extends utils.Adapter {
|
|
57
69
|
dataDir = '';
|
|
58
70
|
creds = null;
|
|
@@ -107,6 +119,16 @@ class BeeAdapter extends utils.Adapter {
|
|
|
107
119
|
instancesOf: adapter => this.instancesOf(adapter),
|
|
108
120
|
errorsSince: (ts, adapters) => this.errorLog.filter(e => e.ts >= ts && adapters.some(a => e.from.startsWith(`${a}.`))),
|
|
109
121
|
onFinished: (job, result) => this.onJobFinished(job, result),
|
|
122
|
+
running: async () => (await this.instancesOf()).filter(i => i.alive).map(i => i.id),
|
|
123
|
+
launchNode: async (target, unit, waitSeconds) => {
|
|
124
|
+
const service = (0, node_1.serviceOf)(await (0, promises_1.readFile)('/proc/self/cgroup', 'utf8').catch(() => ''));
|
|
125
|
+
if (!service) {
|
|
126
|
+
throw new Error('ioBroker läuft nicht als systemd-Dienst');
|
|
127
|
+
}
|
|
128
|
+
this.log.warn(`Node.js is updated to ${target}: ioBroker (${service}) restarts (fleet management)`);
|
|
129
|
+
await (0, node_1.launchNodeUpdate)({ dir: this.dataDir, target, service, unit, waitSeconds });
|
|
130
|
+
},
|
|
131
|
+
unitActive: unit => (0, node_1.unitActive)(unit),
|
|
110
132
|
});
|
|
111
133
|
await this.jobs.load();
|
|
112
134
|
await this.jobs.setHalt(!!this.control?.halt);
|
|
@@ -216,7 +238,7 @@ class BeeAdapter extends utils.Adapter {
|
|
|
216
238
|
async onConnected() {
|
|
217
239
|
this.log.info('Connected to beekeeper');
|
|
218
240
|
await this.setState('info.connection', true, true);
|
|
219
|
-
await this.setState('info.status',
|
|
241
|
+
await this.setState('info.status', `Verbunden mit ${hostOf(this.creds?.mqttUrl)}`, true);
|
|
220
242
|
await this.heartbeat();
|
|
221
243
|
await this.sendInventory(true);
|
|
222
244
|
// results produced while offline
|
|
@@ -501,7 +523,8 @@ class BeeAdapter extends utils.Adapter {
|
|
|
501
523
|
await this.setState('info.remoteAccess', active.length > 0, true);
|
|
502
524
|
await this.setState('info.remoteAccessBy', active
|
|
503
525
|
.map(t => `${remote_1.ACCESS_LABEL[t.kind]}${t.instance ? ` (${t.instance})` : ''}${this.shellText(t)}: ${t.by}, ${t.purpose} (bis ${new Date(t.expiresAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })})`)
|
|
504
|
-
|
|
526
|
+
// in the settings an empty value would show the label alone
|
|
527
|
+
.join('; ') || 'keiner', true);
|
|
505
528
|
}
|
|
506
529
|
// ------------------------------------------------------------------ inventory and heartbeat
|
|
507
530
|
async inventory() {
|
|
@@ -602,10 +625,16 @@ class BeeAdapter extends utils.Adapter {
|
|
|
602
625
|
this.errorLog.splice(0, this.errorLog.length - 500);
|
|
603
626
|
}
|
|
604
627
|
}
|
|
628
|
+
/**
|
|
629
|
+
* Enabled instances with a process of their own on this host and whether they run
|
|
630
|
+
*
|
|
631
|
+
* @param adapter only of this adapter; missing: all
|
|
632
|
+
*/
|
|
605
633
|
async instancesOf(adapter) {
|
|
634
|
+
const prefix = adapter ? `system.adapter.${adapter}.` : 'system.adapter.';
|
|
606
635
|
const res = await this.getObjectViewAsync('system', 'instance', {
|
|
607
|
-
startkey:
|
|
608
|
-
endkey:
|
|
636
|
+
startkey: prefix,
|
|
637
|
+
endkey: `${prefix}香`,
|
|
609
638
|
});
|
|
610
639
|
const list = [];
|
|
611
640
|
for (const row of res.rows) {
|
|
@@ -613,15 +642,23 @@ class BeeAdapter extends utils.Adapter {
|
|
|
613
642
|
if (!obj?.common.enabled || obj.common.host !== this.host) {
|
|
614
643
|
continue;
|
|
615
644
|
}
|
|
616
|
-
// scheduled instances are not running permanently
|
|
617
|
-
if (obj.common.mode !== 'daemon') {
|
|
645
|
+
// scheduled instances are not running permanently, and for files for web nothing runs at all
|
|
646
|
+
if (obj.common.mode !== 'daemon' || (0, instances_1.onlyWww)(obj)) {
|
|
618
647
|
continue;
|
|
619
648
|
}
|
|
620
|
-
const alive = await this.getForeignStateAsync(
|
|
621
|
-
list.push({ id: obj._id.replace('system.adapter.', ''), alive
|
|
649
|
+
const alive = await (0, instances_1.instanceRunning)(obj, id => this.getForeignStateAsync(id), () => this.webInstances());
|
|
650
|
+
list.push({ id: obj._id.replace('system.adapter.', ''), alive });
|
|
622
651
|
}
|
|
623
652
|
return list;
|
|
624
653
|
}
|
|
654
|
+
/** Enabled web instances, e.g. ["web.0"], for web extensions that run in every one of them */
|
|
655
|
+
async webInstances() {
|
|
656
|
+
const res = await this.getObjectViewAsync('system', 'instance', {
|
|
657
|
+
startkey: 'system.adapter.web.',
|
|
658
|
+
endkey: 'system.adapter.web.香',
|
|
659
|
+
});
|
|
660
|
+
return res.rows.filter(r => r.value?.common.enabled).map(r => r.id.replace('system.adapter.', ''));
|
|
661
|
+
}
|
|
625
662
|
// ------------------------------------------------------------------ reconciliation
|
|
626
663
|
async report(state, detail, steps) {
|
|
627
664
|
const d = this.desired;
|
|
@@ -708,7 +745,7 @@ class BeeAdapter extends utils.Adapter {
|
|
|
708
745
|
const from = this.persisted.results[key] === 'done'
|
|
709
746
|
? undefined
|
|
710
747
|
: Object.fromEntries(Object.entries(inv.software.adapters).map(([n, a]) => [n, a.installedFrom]));
|
|
711
|
-
const plan = (0, planner_1.computePlan)(d, installed, this.name, from);
|
|
748
|
+
const plan = (0, planner_1.computePlan)(d, installed, this.name, from, process.version);
|
|
712
749
|
await this.setState('info.onTarget', plan.length === 0, true);
|
|
713
750
|
if (d.mode === 'self') {
|
|
714
751
|
// self-managed: no automatic rollout, only a hint about the new state
|
|
@@ -743,6 +780,7 @@ class BeeAdapter extends utils.Adapter {
|
|
|
743
780
|
}
|
|
744
781
|
// drift after an earlier success (e.g. manual change): converge again
|
|
745
782
|
delete this.persisted.results[key];
|
|
783
|
+
const nodeTarget = plan.find(s => s.action === 'node')?.to ?? undefined;
|
|
746
784
|
const pf = await (0, preflight_1.preflight)({
|
|
747
785
|
now: new Date(),
|
|
748
786
|
halted: !!this.control?.halt,
|
|
@@ -759,7 +797,11 @@ class BeeAdapter extends utils.Adapter {
|
|
|
759
797
|
dependencyErrors: (0, planner_1.checkDependencies)(d, installed, {
|
|
760
798
|
jsController: inv.software.jsController,
|
|
761
799
|
node: process.version,
|
|
800
|
+
nodeMajor: nodeTarget ? Number(nodeTarget) : undefined,
|
|
762
801
|
}),
|
|
802
|
+
nodeErrors: nodeTarget
|
|
803
|
+
? { target: nodeTarget, errors: await this.nodeErrors(nodeTarget, inv, plan) }
|
|
804
|
+
: undefined,
|
|
763
805
|
});
|
|
764
806
|
if (!pf.ok) {
|
|
765
807
|
if (pf.kind === 'block') {
|
|
@@ -796,6 +838,22 @@ class BeeAdapter extends utils.Adapter {
|
|
|
796
838
|
await this.report('preflight', `${plan.length} Schritte geplant, Vorprüfung bestanden`, plan);
|
|
797
839
|
await this.jobs.start(d, plan, this.config.backupBeforeUpdate !== false, files);
|
|
798
840
|
}
|
|
841
|
+
/**
|
|
842
|
+
* Why Node.js cannot go to the major line: the system, and installed packages that exclude it
|
|
843
|
+
* (those the plan changes are checked with their new version by checkDependencies)
|
|
844
|
+
*
|
|
845
|
+
* @param target major line
|
|
846
|
+
* @param inv inventory
|
|
847
|
+
* @param plan steps of the job
|
|
848
|
+
*/
|
|
849
|
+
async nodeErrors(target, inv, plan) {
|
|
850
|
+
const changed = new Set(plan.map(s => s.adapter));
|
|
851
|
+
const names = ['js-controller', ...Object.keys(inv.software.adapters).filter(n => !changed.has(n))];
|
|
852
|
+
return [
|
|
853
|
+
...(0, node_1.nodeBlockers)(await (0, node_1.nodeFacts)(inv.backup.offDevice)),
|
|
854
|
+
...(0, node_1.engineConflicts)(Number(target), (0, node_1.readEngines)((0, node_path_1.join)(utils.controllerDir, '..', '..'), names)),
|
|
855
|
+
];
|
|
856
|
+
}
|
|
799
857
|
// ------------------------------------------------------------------ states, notifications
|
|
800
858
|
async updateInfoStates() {
|
|
801
859
|
await this.setState('info.deviceId', this.creds?.deviceId || '', true);
|