Compare commits

...

4 Commits

Author SHA1 Message Date
b37e1aae6c chore(release): bump version to 4.0.1
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
Release / build-and-release (push) Successful in 43s
CI / Build All Platforms (push) Successful in 51s
2025-10-19 14:50:39 +00:00
7076829747 fix(install): detect enabled services even when failed/stopped during migration
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 49s
Previously only checked 'is-active' which missed failed/stopped services.
Now checks 'is-enabled' OR 'is-active' to ensure service file gets updated
during v3→v4 migration regardless of service state.
2025-10-19 14:43:44 +00:00
1387ca262b fix(migration): update systemd service file during v3→v4 migration
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 47s
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/
2025-10-19 14:37:32 +00:00
684f034aee ci(release): auto-delete existing release before creating new one
All checks were successful
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 46s
- Checks if release already exists for the tag
- Automatically deletes conflicting release if found
- Prevents duplicate/stale releases when recreating tags
- Ensures fresh binaries when tag is recreated

This fixes the issue where recreating a tag would keep old
release with outdated binaries.
2025-10-19 14:33:58 +00:00
4 changed files with 44 additions and 9 deletions

View File

@@ -152,6 +152,29 @@ jobs:
echo "Release notes:"
cat /tmp/release_notes.md
- name: Delete existing release if it exists
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "Checking for existing release $VERSION..."
# Try to get existing release by tag
EXISTING_RELEASE_ID=$(curl -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/nupst/releases/tags/$VERSION" \
| jq -r '.id // empty')
if [ -n "$EXISTING_RELEASE_ID" ]; then
echo "Found existing release (ID: $EXISTING_RELEASE_ID), deleting..."
curl -X DELETE -s \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://code.foss.global/api/v1/repos/serve.zone/nupst/releases/$EXISTING_RELEASE_ID"
echo "Existing release deleted"
sleep 2
else
echo "No existing release found, proceeding with creation"
fi
- name: Create Gitea Release
run: |
VERSION="${{ steps.version.outputs.version }}"

View File

@@ -1,6 +1,6 @@
{
"name": "@serve.zone/nupst",
"version": "4.0.0",
"version": "4.0.1",
"exports": "./mod.ts",
"tasks": {
"dev": "deno run --allow-all mod.ts",

View File

@@ -243,11 +243,15 @@ if [ -d "$INSTALL_DIR" ]; then
echo "Updating existing installation at $INSTALL_DIR..."
# Check if service is running and stop it
if systemctl is-active --quiet nupst 2>/dev/null; then
echo "Stopping NUPST service..."
systemctl stop nupst
# Check if service exists (enabled or running) and stop it if active
if systemctl is-enabled --quiet nupst 2>/dev/null || systemctl is-active --quiet nupst 2>/dev/null; then
SERVICE_WAS_RUNNING=1
if systemctl is-active --quiet nupst 2>/dev/null; then
echo "Stopping NUPST service..."
systemctl stop nupst
else
echo "Service is installed but not currently running (will be updated)..."
fi
fi
# Clean up old Node.js installation files
@@ -340,6 +344,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..."

View File

@@ -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