Compare commits
No commits in common. "5bb775b17d2eaa4943bb39151d94d23f49315a61" and "4ad383884c160142c5f4026ab60f9c8821117cc0" have entirely different histories.
5bb775b17d
...
4ad383884c
@ -1,11 +1,5 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 2025-03-25 - 2.5.0 - feat(cli)
|
|
||||||
Automatically restart running NUPST service after configuration changes in interactive setup
|
|
||||||
|
|
||||||
- Added restartServiceIfRunning() to check and restart the service if it's active.
|
|
||||||
- Invoked the restart function post-setup to apply configuration changes immediately.
|
|
||||||
|
|
||||||
## 2025-03-25 - 2.4.8 - fix(installer)
|
## 2025-03-25 - 2.4.8 - fix(installer)
|
||||||
Improve Git dependency handling and repository cloning in install.sh
|
Improve Git dependency handling and repository cloning in install.sh
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/nupst",
|
"name": "@serve.zone/nupst",
|
||||||
"version": "2.5.0",
|
"version": "2.4.8",
|
||||||
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@serve.zone/nupst',
|
name: '@serve.zone/nupst',
|
||||||
version: '2.5.0',
|
version: '2.4.8',
|
||||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||||
}
|
}
|
||||||
|
41
ts/cli.ts
41
ts/cli.ts
@ -533,9 +533,6 @@ Options:
|
|||||||
// Test the connection if requested
|
// Test the connection if requested
|
||||||
await this.optionallyTestConnection(config, prompt);
|
await this.optionallyTestConnection(config, prompt);
|
||||||
|
|
||||||
// Check if service is running and restart it if needed
|
|
||||||
await this.restartServiceIfRunning();
|
|
||||||
|
|
||||||
console.log('\nSetup complete!');
|
console.log('\nSetup complete!');
|
||||||
await this.optionallyEnableService(prompt);
|
await this.optionallyEnableService(prompt);
|
||||||
}
|
}
|
||||||
@ -836,44 +833,6 @@ Options:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the systemd service is running and restart it if it is
|
|
||||||
* This is useful after configuration changes
|
|
||||||
*/
|
|
||||||
private async restartServiceIfRunning(): Promise<void> {
|
|
||||||
try {
|
|
||||||
// Check if the service is active
|
|
||||||
const isActive = execSync('systemctl is-active nupst.service || true').toString().trim() === 'active';
|
|
||||||
|
|
||||||
if (isActive) {
|
|
||||||
// Service is running, restart it
|
|
||||||
console.log('┌─ Service Update ─────────────────────────┐');
|
|
||||||
console.log('│ Configuration has changed.');
|
|
||||||
console.log('│ Restarting NUPST service to apply changes...');
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (process.getuid && process.getuid() === 0) {
|
|
||||||
// We have root access, restart directly
|
|
||||||
execSync('systemctl restart nupst.service');
|
|
||||||
console.log('│ Service restarted successfully.');
|
|
||||||
} else {
|
|
||||||
// No root access, show instructions
|
|
||||||
console.log('│ Please restart the service with:');
|
|
||||||
console.log('│ sudo systemctl restart nupst.service');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log(`│ Error restarting service: ${error.message}`);
|
|
||||||
console.log('│ You may need to restart the service manually:');
|
|
||||||
console.log('│ sudo systemctl restart nupst.service');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('└──────────────────────────────────────────┘');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
// Ignore errors checking service status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionally enable and start systemd service
|
* Optionally enable and start systemd service
|
||||||
* @param prompt Function to prompt for user input
|
* @param prompt Function to prompt for user input
|
||||||
|
Loading…
x
Reference in New Issue
Block a user