From 1387ca262b4e1fd73aa12eec7b7e3981a273f146 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Sun, 19 Oct 2025 14:37:32 +0000 Subject: [PATCH] =?UTF-8?q?fix(migration):=20update=20systemd=20service=20?= =?UTF-8?q?file=20during=20v3=E2=86=92v4=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical fixes for v3→v4 migration: 1. install.sh: Auto-update systemd service file during migration - Calls 'nupst service enable' before restarting service - Only when migrating from v3 (OLD_NODE_INSTALL=1) - Ensures service file has correct v4 paths 2. ts/systemd.ts: Fix hardcoded v3 paths in service template - ExecStart: /opt/nupst/bin/nupst daemon-start (v3, broken) → /usr/local/bin/nupst service start-daemon (v4, correct) - Description: Updated to 'Deno-powered UPS Monitoring Tool' - Added RestartSec=10 (prevent rapid restart loops) - Removed NODE_ENV=production (not needed for Deno) - WorkingDirectory: /tmp → /opt/nupst Without these fixes: - Service fails to start after migration - Service file points to non-existent /opt/nupst/bin/nupst - Users must manually run 'nupst service enable' Discovered via Docker migration testing in test/manualdocker/ --- install.sh | 8 ++++++++ ts/systemd.ts | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 56c12b8..6cf2d59 100644 --- a/install.sh +++ b/install.sh @@ -340,6 +340,14 @@ fi echo "" +# Update systemd service file if migrating from v3 +if [ $SERVICE_WAS_RUNNING -eq 1 ] && [ $OLD_NODE_INSTALL -eq 1 ]; then + echo "Updating systemd service file for v4..." + $BINARY_PATH service enable > /dev/null 2>&1 + echo "Service file updated." + echo "" +fi + # Restart service if it was running before update if [ $SERVICE_WAS_RUNNING -eq 1 ]; then echo "Restarting NUPST service..." diff --git a/ts/systemd.ts b/ts/systemd.ts index 2d8c6c7..0afa057 100644 --- a/ts/systemd.ts +++ b/ts/systemd.ts @@ -15,17 +15,17 @@ export class NupstSystemd { /** Template for the systemd service file */ private readonly serviceTemplate = `[Unit] -Description=Node.js UPS Shutdown Tool for Multiple UPS Devices +Description=NUPST - Deno-powered UPS Monitoring Tool After=network.target [Service] -ExecStart=/opt/nupst/bin/nupst daemon-start +ExecStart=/usr/local/bin/nupst service start-daemon Restart=always +RestartSec=10 User=root Group=root Environment=PATH=/usr/bin:/usr/local/bin -Environment=NODE_ENV=production -WorkingDirectory=/tmp +WorkingDirectory=/opt/nupst [Install] WantedBy=multi-user.target