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:
@ -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'
|
||||
}
|
||||
|
19
ts/cli.ts
19
ts/cli.ts
@ -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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user