feat(installer/cli): Add OS detection and git auto-installation support to install.sh and improve service setup prompt in CLI

This commit is contained in:
2025-03-25 11:25:03 +00:00
parent c7db209da7
commit bd5b85f6b0
4 changed files with 105 additions and 6 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@serve.zone/nupst',
version: '2.2.0',
version: '2.3.0',
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
}

View File

@ -834,7 +834,7 @@ Options:
}
/**
* Optionally enable systemd service
* Optionally enable and start systemd service
* @param prompt Function to prompt for user input
*/
private async optionallyEnableService(prompt: (question: string) => Promise<string>): Promise<void> {
@ -843,8 +843,21 @@ Options:
} else {
const setupService = await prompt('Would you like to enable NUPST as a system service? (y/N): ');
if (setupService.toLowerCase() === 'y') {
await this.nupst.getSystemd().install();
console.log('Service installed. Use "nupst start" to start the service.');
try {
await this.nupst.getSystemd().install();
console.log('Service installed and enabled to start on boot.');
// Ask if the user wants to start the service now
const startService = await prompt('Would you like to start the NUPST service now? (Y/n): ');
if (startService.toLowerCase() !== 'n') {
await this.nupst.getSystemd().start();
console.log('NUPST service started successfully.');
} else {
console.log('Service not started. Use "nupst start" to start the service manually.');
}
} catch (error) {
console.error(`Failed to setup service: ${error.message}`);
}
}
}
}