@lethevimlet/sshift 1.0.13 → 1.0.14
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
|
@@ -302,6 +302,32 @@ function registerSystemEndpoints(app, io) {
|
|
|
302
302
|
const updateScriptPath = path.join(dataDir, '.sshift-update.sh');
|
|
303
303
|
const updateLogPath = path.join(dataDir, '.sshift-update.log');
|
|
304
304
|
|
|
305
|
+
// Detect if running under systemd (moved before script template so the
|
|
306
|
+
// isSystemdManaged and systemdUnit variables are available for interpolation)
|
|
307
|
+
let isSystemdManaged = false;
|
|
308
|
+
let systemdUnit = '';
|
|
309
|
+
try {
|
|
310
|
+
// Check if this process is managed by systemd via cgroup
|
|
311
|
+
const myCgroup = fs.readFileSync(`/proc/${process.pid}/cgroup`, 'utf8');
|
|
312
|
+
if (myCgroup.includes('sshift')) {
|
|
313
|
+
isSystemdManaged = true;
|
|
314
|
+
systemdUnit = 'sshift.service';
|
|
315
|
+
console.log('[UPDATE] Detected systemd-managed process, unit:', systemdUnit);
|
|
316
|
+
} else if (process.ppid === 1) {
|
|
317
|
+
// Parent is init (systemd), check for sshift service
|
|
318
|
+
try {
|
|
319
|
+
require('child_process').execSync('systemctl is-enabled sshift.service 2>/dev/null', { encoding: 'utf8' });
|
|
320
|
+
isSystemdManaged = true;
|
|
321
|
+
systemdUnit = 'sshift.service';
|
|
322
|
+
console.log('[UPDATE] Detected systemd service:', systemdUnit);
|
|
323
|
+
} catch (e) {
|
|
324
|
+
// Not a systemd service
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
} catch (e) {
|
|
328
|
+
// /proc not available (non-Linux), ignore
|
|
329
|
+
}
|
|
330
|
+
|
|
305
331
|
// Build PATH for the update script to ensure npm and node are findable
|
|
306
332
|
const pathDirs = [];
|
|
307
333
|
if (process.env.PATH) pathDirs.push(...process.env.PATH.split(':'));
|
|
@@ -436,32 +462,6 @@ fi
|
|
|
436
462
|
console.log('[UPDATE] npm path:', npmBinPath);
|
|
437
463
|
console.log('[UPDATE] sshift restart path:', sshiftBinPath);
|
|
438
464
|
console.log('[UPDATE] Log file:', updateLogPath);
|
|
439
|
-
|
|
440
|
-
// Detect if running under systemd
|
|
441
|
-
let isSystemdManaged = false;
|
|
442
|
-
let systemdUnit = '';
|
|
443
|
-
try {
|
|
444
|
-
const { execSync: execSync2 } = require('child_process');
|
|
445
|
-
// Check if this process is managed by systemd
|
|
446
|
-
const myCgroup = fs.readFileSync(`/proc/${process.pid}/cgroup`, 'utf8');
|
|
447
|
-
if (myCgroup.includes('sshift')) {
|
|
448
|
-
isSystemdManaged = true;
|
|
449
|
-
systemdUnit = 'sshift.service';
|
|
450
|
-
console.log('[UPDATE] Detected systemd-managed process, unit:', systemdUnit);
|
|
451
|
-
} else if (process.ppid === 1) {
|
|
452
|
-
// Parent is init (systemd), check for sshift service
|
|
453
|
-
try {
|
|
454
|
-
execSync2('systemctl is-enabled sshift.service 2>/dev/null', { encoding: 'utf8' });
|
|
455
|
-
isSystemdManaged = true;
|
|
456
|
-
systemdUnit = 'sshift.service';
|
|
457
|
-
console.log('[UPDATE] Detected systemd service:', systemdUnit);
|
|
458
|
-
} catch (e) {
|
|
459
|
-
// Not a systemd service
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
} catch (e) {
|
|
463
|
-
// /proc not available (non-Linux), ignore
|
|
464
|
-
}
|
|
465
465
|
|
|
466
466
|
let spawnFailed = false;
|
|
467
467
|
let spawnCommand, spawnArgs;
|