mb-service-linux 2.0.1 → 2.0.2

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 CHANGED
@@ -24,6 +24,22 @@ If you like this project and find it useful, please consider giving it a star on
24
24
 
25
25
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="120"></a>
26
26
 
27
+ ## [2.0.2] - 2026-07-04
28
+
29
+ ### Added
30
+
31
+ - [service]: Create the Matterbridge directories (~/Matterbridge, ~/.matterbridge, ~/.mattercert) on create and change their ownership to the service user.
32
+ - [service]: Add SyslogIdentifier to the service file.
33
+
34
+ ### Changed
35
+
36
+ - [service]: Set WorkingDirectory to the Matterbridge directory in the home of the service user.
37
+ - [service]: Send stdout and stderr to the journal in the service file.
38
+ - [package]: Update dependencies.
39
+ - [package]: Upgrade package.
40
+
41
+ <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
42
+
27
43
  ## [2.0.1] - 2026-07-01
28
44
 
29
45
  ### Added
@@ -32,6 +48,10 @@ If you like this project and find it useful, please consider giving it a star on
32
48
  - [service]: Add Environment PATH to the service file.
33
49
  - [service]: Add network-online.target to the service file.
34
50
 
51
+ ### Changed
52
+
53
+ - [help]: Update usage instructions in help output to include additional commands.
54
+
35
55
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
36
56
 
37
57
  ## [2.0.0] - 2026-07-01
package/dist/module.js CHANGED
@@ -41,6 +41,9 @@ function getServicePath(root) {
41
41
  function getUserServiceDirectory() {
42
42
  return `${process.env.HOME}/.config/systemd/user`;
43
43
  }
44
+ function getUserHomeDirectory(user) {
45
+ return user === 'root' ? '/root' : `/home/${user}`;
46
+ }
44
47
  function getDiagnosticUser() {
45
48
  return process.env.SUDO_USER ?? process.env.USER ?? 'unknown';
46
49
  }
@@ -171,7 +174,7 @@ function printHelp() {
171
174
  ` Service user: ${getDiagnosticUser()}\n` +
172
175
  ` Root service file: ${existsServiceFile(true) ? `found at "${getServicePath(true)}"` : 'not found'}\n` +
173
176
  ` User service file: ${existsServiceFile(false) ? `found at "${getServicePath(false)}"` : 'not found'}\x1b[0m`);
174
- console.log(`Usage: mb-service [start|stop|restart|logs|status]\n\n` +
177
+ console.log(`Usage: mb-service [create|start|stop|restart|enable|disable|install|uninstall|add|remove|link|unlink|logs|status]\n\n` +
175
178
  ` Please provide a command:\n` +
176
179
  ` start start the matterbridge service\n` +
177
180
  ` stop stop the matterbridge service\n` +
@@ -190,6 +193,11 @@ function printHelp() {
190
193
  }
191
194
  function createServiceConfig(root) {
192
195
  const user = process.env.SUDO_USER || process.env.USER;
196
+ if (!user) {
197
+ console.error('Could not determine the user to run the service. Please set SUDO_USER or USER environment variable.');
198
+ return;
199
+ }
200
+ const home = getUserHomeDirectory(user);
193
201
  const rootConfig = `[Unit]\n` +
194
202
  `Description=matterbridge\n` +
195
203
  `After=network-online.target\n` +
@@ -202,10 +210,11 @@ function createServiceConfig(root) {
202
210
  `# PATH for any child process Matterbridge/plugins spawn (bun/node/npm lookups).\n` +
203
211
  `Environment="PATH=/usr/local/bin:/usr/bin:/bin"\n` +
204
212
  `ExecStart=matterbridge --service\n` +
205
- `WorkingDirectory=%h\n` +
213
+ `WorkingDirectory=${home}/Matterbridge\n` +
206
214
  `# Logs go to the journal (should be persistent). Read with: journalctl -u matterbridge -n 1000 -f --output cat\n` +
207
- `StandardOutput=inherit\n` +
208
- `StandardError=inherit\n` +
215
+ `StandardOutput=journal\n` +
216
+ `StandardError=journal\n` +
217
+ `SyslogIdentifier=matterbridge\n` +
209
218
  `Restart=always\n` +
210
219
  `RestartSec=5\n` +
211
220
  `TimeoutStopSec=60\n` +
@@ -229,10 +238,11 @@ function createServiceConfig(root) {
229
238
  `# --bun forces the Bun runtime even though the matterbridge bin has a node shebang,\n` +
230
239
  `# and shims any \`node\` the process spawns to Bun as well.\n` +
231
240
  (isBun() ? `ExecStart=%h/.bun/bin/bun --bun %h/.bun/bin/matterbridge --service\n` : `ExecStart=matterbridge --service\n`) +
232
- `WorkingDirectory=%h\n` +
241
+ `WorkingDirectory=${home}/Matterbridge\n` +
233
242
  `# Logs go to the journal (should be persistent). Read with: journalctl --user -u matterbridge -n 1000 -f --output cat\n` +
234
- `StandardOutput=inherit\n` +
235
- `StandardError=inherit\n` +
243
+ `StandardOutput=journal\n` +
244
+ `StandardError=journal\n` +
245
+ `SyslogIdentifier=matterbridge\n` +
236
246
  `Restart=always\n` +
237
247
  `RestartSec=5\n` +
238
248
  `TimeoutStopSec=60\n` +
@@ -240,14 +250,26 @@ function createServiceConfig(root) {
240
250
  `[Install]\n` +
241
251
  `WantedBy=default.target\n`;
242
252
  const servicePath = getServicePath(root);
243
- if (!user) {
244
- console.error('Could not determine the user to run the service. Please set SUDO_USER or USER environment variable.');
245
- return;
246
- }
247
253
  if (existsSync(servicePath)) {
248
254
  console.log(`Service configuration already exists at ${servicePath}. No changes made.`);
249
255
  return;
250
256
  }
257
+ const matterbridgeDirectories = [`${home}/Matterbridge`, `${home}/.matterbridge`, `${home}/.mattercert`];
258
+ try {
259
+ for (const directory of matterbridgeDirectories) {
260
+ mkdirSync(directory, { recursive: true });
261
+ }
262
+ if (root) {
263
+ const chown = spawnSync('chown', ['-R', `${user}:${user}`, ...matterbridgeDirectories], { stdio: 'inherit' });
264
+ if (chown.error) {
265
+ console.error('Failed to change the ownership of the Matterbridge directories:', chown.error.message);
266
+ }
267
+ }
268
+ }
269
+ catch (err) {
270
+ console.error(`Failed to create the Matterbridge directories: ${String(err)}`);
271
+ process.exit(1);
272
+ }
251
273
  try {
252
274
  if (!root) {
253
275
  mkdirSync(getUserServiceDirectory(), { recursive: true });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "mb-service-linux",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "mb-service-linux",
9
- "version": "2.0.1",
9
+ "version": "2.0.2",
10
10
  "license": "Apache-2.0",
11
11
  "bin": {
12
12
  "mb-service": "bin/mb-service"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mb-service-linux",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Matterbridge service command line interface",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",