mb-service-linux 2.0.0-dev-20260701-6127784 → 2.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/CHANGELOG.md +4 -2
- package/dist/module.js +45 -6
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -33,14 +33,16 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
33
33
|
- [bun]: Add Bun runtime detection and Bun global plugin install/uninstall support.
|
|
34
34
|
- [service]: Create the user systemd directory before writing a user-owned service file.
|
|
35
35
|
- [service]: Detect conflicting root-owned and user-owned service files before managing the service.
|
|
36
|
+
- [service]: Check for `package.json` before running package manager `link` and `unlink`.
|
|
37
|
+
- [service]: Run package manager `link` and `unlink` commands for development links.
|
|
38
|
+
- [service]: Require root privileges for npm `link` and `unlink` commands on Linux.
|
|
39
|
+
- [service]: Show a `loginctl enable-linger` hint after creating a user-owned service.
|
|
36
40
|
|
|
37
41
|
### Changed
|
|
38
42
|
|
|
39
43
|
- [service]: Use `systemctl --user` and `journalctl --user` when managing a user-owned service.
|
|
40
44
|
- [service]: Require either a root-owned or user-owned service file before running service management commands.
|
|
41
45
|
- [readme]: Document root-owned, user-owned, and Bun service setup flows.
|
|
42
|
-
- [service]: Run package manager `link` and `unlink` commands for development links.
|
|
43
|
-
- [service]: Require root privileges for npm `link` and `unlink` commands on Linux.
|
|
44
46
|
|
|
45
47
|
<a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
|
|
46
48
|
|
package/dist/module.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
1
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
3
3
|
const HAS_BUN_GLOBAL = typeof Bun !== 'undefined';
|
|
4
|
+
const MB_SERVICE_VERSION = '2.0.0';
|
|
4
5
|
export function isBun() {
|
|
5
6
|
return HAS_BUN_GLOBAL || typeof process?.versions?.bun === 'string';
|
|
6
7
|
}
|
|
8
|
+
export function bunAvailable() {
|
|
9
|
+
if (isBun()) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
const home = process.env.HOME ?? '';
|
|
13
|
+
if (home && existsSync(`${home}/.bun/bin/bun`))
|
|
14
|
+
return true;
|
|
15
|
+
try {
|
|
16
|
+
execFileSync('bun', ['--version'], { stdio: 'ignore' });
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
7
23
|
function isRoot() {
|
|
8
24
|
return process.getuid?.() === 0;
|
|
9
25
|
}
|
|
@@ -19,6 +35,9 @@ function getServicePath(root) {
|
|
|
19
35
|
function getUserServiceDirectory() {
|
|
20
36
|
return `${process.env.HOME}/.config/systemd/user`;
|
|
21
37
|
}
|
|
38
|
+
function getDiagnosticUser() {
|
|
39
|
+
return process.env.SUDO_USER ?? process.env.USER ?? 'unknown';
|
|
40
|
+
}
|
|
22
41
|
function existsServiceFile(root) {
|
|
23
42
|
return existsSync(getServicePath(root));
|
|
24
43
|
}
|
|
@@ -43,7 +62,7 @@ export function main() {
|
|
|
43
62
|
console.error('Matterbridge service file does not exist.\n' +
|
|
44
63
|
'Run "sudo mb-service create" if you want to create a root-owned service file.\n' +
|
|
45
64
|
'Run "mb-service create" without sudo to create a user-owned service file.\n' +
|
|
46
|
-
'Run "
|
|
65
|
+
'Run "bun --bun run mb-service create" to create a user-owned service file when using Bun.');
|
|
47
66
|
return;
|
|
48
67
|
}
|
|
49
68
|
if (!isBun() && existsServiceFile(true) && !isRoot()) {
|
|
@@ -136,7 +155,16 @@ export function main() {
|
|
|
136
155
|
}
|
|
137
156
|
}
|
|
138
157
|
function printHelp() {
|
|
139
|
-
console.log(`\x1b[
|
|
158
|
+
console.log(`\x1b[90mEnvironment:\n` +
|
|
159
|
+
` mb-service version: ${MB_SERVICE_VERSION}\n` +
|
|
160
|
+
` Runtime: ${isBun() ? 'Bun' : 'Node.js'}\n` +
|
|
161
|
+
` Node version: ${process.version}${isBun() ? ' (reported by Bun for Node.js compatibility)' : ''}\n` +
|
|
162
|
+
` Bun available: ${bunAvailable() ? 'yes' : 'no'}\n` +
|
|
163
|
+
` Bun version: ${process.versions.bun ?? 'not running'}\n` +
|
|
164
|
+
` Running as root: ${isRoot() ? 'yes' : 'no'}\n` +
|
|
165
|
+
` Service user: ${getDiagnosticUser()}\n` +
|
|
166
|
+
` Root service file: ${existsServiceFile(true) ? 'found' : 'not found'}\n` +
|
|
167
|
+
` User service file: ${existsServiceFile(false) ? 'found' : 'not found'}\x1b[0m`);
|
|
140
168
|
console.log(`Usage: mb-service [start|stop|restart|logs|status]\n\n` +
|
|
141
169
|
` Please provide a command:\n` +
|
|
142
170
|
` start start the matterbridge service\n` +
|
|
@@ -165,7 +193,7 @@ function createServiceConfig(root) {
|
|
|
165
193
|
`[Service]\n` +
|
|
166
194
|
`Type=simple\n` +
|
|
167
195
|
`ExecStart=matterbridge --service\n` +
|
|
168
|
-
`WorkingDirectory
|
|
196
|
+
`WorkingDirectory=%h\n` +
|
|
169
197
|
`StandardOutput=inherit\n` +
|
|
170
198
|
`StandardError=inherit\n` +
|
|
171
199
|
`Restart=always\n` +
|
|
@@ -182,8 +210,8 @@ function createServiceConfig(root) {
|
|
|
182
210
|
`StartLimitBurst=5\n` +
|
|
183
211
|
`[Service]\n` +
|
|
184
212
|
`Type=simple\n` +
|
|
185
|
-
(isBun() ? `ExecStart
|
|
186
|
-
`WorkingDirectory
|
|
213
|
+
(isBun() ? `ExecStart=%h/.bun/bin/bun --bun run %h/.bun/bin/matterbridge --service\n` : `ExecStart=matterbridge --service\n`) +
|
|
214
|
+
`WorkingDirectory=%h\n` +
|
|
187
215
|
`StandardOutput=inherit\n` +
|
|
188
216
|
`StandardError=inherit\n` +
|
|
189
217
|
`Restart=always\n` +
|
|
@@ -205,6 +233,9 @@ function createServiceConfig(root) {
|
|
|
205
233
|
}
|
|
206
234
|
writeFileSync(servicePath, root ? rootConfig : userConfig, { mode: 0o644 });
|
|
207
235
|
console.log(`Service configuration written to ${servicePath} successfully for user ${user}.`);
|
|
236
|
+
if (!root) {
|
|
237
|
+
console.warn(`To keep the user service active after logout, run once: sudo loginctl enable-linger ${user}`);
|
|
238
|
+
}
|
|
208
239
|
}
|
|
209
240
|
catch (err) {
|
|
210
241
|
console.error(`Failed to write service file: ${String(err)}`);
|
|
@@ -279,6 +310,10 @@ function uninstallGlobalPackage(pkg) {
|
|
|
279
310
|
}
|
|
280
311
|
}
|
|
281
312
|
function linkPackage() {
|
|
313
|
+
if (!existsSync('package.json')) {
|
|
314
|
+
console.error('Cannot link package: package.json does not exist in the current directory.');
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
282
317
|
if (!isBun() && !isRoot()) {
|
|
283
318
|
console.error('Linking global packages requires root privileges. Please run this command with sudo.');
|
|
284
319
|
return;
|
|
@@ -289,6 +324,10 @@ function linkPackage() {
|
|
|
289
324
|
}
|
|
290
325
|
}
|
|
291
326
|
function unlinkPackage() {
|
|
327
|
+
if (!existsSync('package.json')) {
|
|
328
|
+
console.error('Cannot unlink package: package.json does not exist in the current directory.');
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
292
331
|
if (!isBun() && !isRoot()) {
|
|
293
332
|
console.error('Unlinking global packages requires root privileges. Please run this command with sudo.');
|
|
294
333
|
return;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mb-service-linux",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "mb-service-linux",
|
|
9
|
-
"version": "2.0.0
|
|
9
|
+
"version": "2.0.0",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"bin": {
|
|
12
12
|
"mb-service": "bin/mb-service"
|