@lethevimlet/sshift 1.0.10 → 1.0.12
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
|
@@ -372,35 +372,24 @@ if ($IsScheduled) {
|
|
|
372
372
|
const psScriptPath = updateScriptPath.replace('.sh', '.ps1');
|
|
373
373
|
fs.writeFileSync(psScriptPath, psScript, 'utf8');
|
|
374
374
|
} else {
|
|
375
|
-
|
|
375
|
+
const updateScript = `#!/bin/sh
|
|
376
376
|
LOG="${updateLogPath}"
|
|
377
377
|
MARKER="${updateMarker}"
|
|
378
378
|
NPM_BIN="${npmBinPath}"
|
|
379
379
|
SSHIFT_FALLBACK="${sshiftBinPath}"
|
|
380
380
|
NODE_BIN="${nodeExe}"
|
|
381
381
|
OLD_VERSION="${oldVersion}"
|
|
382
|
+
SYSTEMD_MANAGED="${isSystemdManaged ? '1' : '0'}"
|
|
383
|
+
SYSTEMD_UNIT="${systemdUnit}"
|
|
382
384
|
|
|
383
385
|
echo "$(date): Starting sshift update (from v${oldVersion})..." > "$LOG"
|
|
384
386
|
echo "$(date): npm path: $NPM_BIN" >> "$LOG"
|
|
385
387
|
echo "$(date): node path: $NODE_BIN" >> "$LOG"
|
|
386
388
|
echo "$(date): sshift fallback: $SSHIFT_FALLBACK" >> "$LOG"
|
|
389
|
+
echo "$(date): systemd_managed: $SYSTEMD_MANAGED" >> "$LOG"
|
|
387
390
|
|
|
388
|
-
|
|
389
|
-
SYSTEMD_UNIT
|
|
390
|
-
if command -v systemctl >/dev/null 2>&1; then
|
|
391
|
-
SYSTEMD_UNIT="$(systemctl show -p Id -value sshift.service 2>/dev/null || true)"
|
|
392
|
-
if [ -z "$SYSTEMD_UNIT" ]; then
|
|
393
|
-
# Try to find sshift in systemd by looking at the running process
|
|
394
|
-
_my_pid="$$"
|
|
395
|
-
_my_cgroup="$(cat /proc/$_my_pid/cgroup 2>/dev/null | grep -o 'name=systemd.*sshift[.]service' | head -1)"
|
|
396
|
-
if [ -n "$_my_cgroup" ]; then
|
|
397
|
-
SYSTEMD_UNIT="sshift.service"
|
|
398
|
-
fi
|
|
399
|
-
fi
|
|
400
|
-
fi
|
|
401
|
-
|
|
402
|
-
if [ -n "$SYSTEMD_UNIT" ]; then
|
|
403
|
-
echo "$(date): Detected systemd service: $SYSTEMD_UNIT" >> "$LOG"
|
|
391
|
+
if [ "$SYSTEMD_MANAGED" = "1" ]; then
|
|
392
|
+
echo "$(date): Detected systemd-managed service: $SYSTEMD_UNIT" >> "$LOG"
|
|
404
393
|
# Stop the service before updating to prevent systemd from restarting old version
|
|
405
394
|
echo "$(date): Stopping $SYSTEMD_UNIT..." >> "$LOG"
|
|
406
395
|
systemctl stop "$SYSTEMD_UNIT" >> "$LOG" 2>&1 || true
|
|
@@ -417,7 +406,7 @@ if ! "$NPM_BIN" install -g @lethevimlet/sshift@latest >> "$LOG" 2>&1; then
|
|
|
417
406
|
echo "npm install failed" >> "$LOG"
|
|
418
407
|
rm -f "$MARKER"
|
|
419
408
|
# Always restart the server — the old version is still installed
|
|
420
|
-
if [
|
|
409
|
+
if [ "$SYSTEMD_MANAGED" = "1" ]; then
|
|
421
410
|
echo "$(date): Restarting via systemd (old version)" >> "$LOG"
|
|
422
411
|
systemctl start "$SYSTEMD_UNIT" >> "$LOG" 2>&1
|
|
423
412
|
else
|
|
@@ -431,7 +420,7 @@ echo "$(date): npm install completed successfully" >> "$LOG"
|
|
|
431
420
|
# Remove the update marker before restart
|
|
432
421
|
rm -f "$MARKER"
|
|
433
422
|
|
|
434
|
-
if [
|
|
423
|
+
if [ "$SYSTEMD_MANAGED" = "1" ]; then
|
|
435
424
|
echo "$(date): Restarting via systemd" >> "$LOG"
|
|
436
425
|
systemctl start "$SYSTEMD_UNIT" >> "$LOG" 2>&1
|
|
437
426
|
else
|