|
|
|
@@ -134,6 +134,45 @@ WantedBy=multi-user.target
|
|
|
|
|
* Get status of the systemd service and UPS
|
|
|
|
|
* @param debugMode Whether to enable debug mode for SNMP
|
|
|
|
|
*/
|
|
|
|
|
/**
|
|
|
|
|
* Display version information and update status
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
private async displayVersionInfo(): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
const nupst = this.daemon.getNupstSnmp().getNupst();
|
|
|
|
|
const version = nupst.getVersion();
|
|
|
|
|
|
|
|
|
|
// Check for updates
|
|
|
|
|
const updateAvailable = await nupst.checkForUpdates();
|
|
|
|
|
|
|
|
|
|
// Display version info
|
|
|
|
|
if (updateAvailable) {
|
|
|
|
|
const updateStatus = nupst.getUpdateStatus();
|
|
|
|
|
logger.log('');
|
|
|
|
|
logger.log(
|
|
|
|
|
`${theme.dim('NUPST')} ${theme.dim('v' + version)} ${symbols.warning} ${theme.statusWarning(`Update available: v${updateStatus.latestVersion}`)}`,
|
|
|
|
|
);
|
|
|
|
|
logger.log(` ${theme.dim('Run')} ${theme.command('sudo nupst update')} ${theme.dim('to upgrade')}`);
|
|
|
|
|
} else {
|
|
|
|
|
logger.log('');
|
|
|
|
|
logger.log(
|
|
|
|
|
`${theme.dim('NUPST')} ${theme.dim('v' + version)} ${symbols.success} ${theme.success('Up to date')}`,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// If version check fails, show at least the current version
|
|
|
|
|
try {
|
|
|
|
|
const nupst = this.daemon.getNupstSnmp().getNupst();
|
|
|
|
|
const version = nupst.getVersion();
|
|
|
|
|
logger.log('');
|
|
|
|
|
logger.log(`${theme.dim('NUPST')} ${theme.dim('v' + version)}`);
|
|
|
|
|
} catch (_innerError) {
|
|
|
|
|
// Silently fail if we can't even get the version
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async getStatus(debugMode: boolean = false): Promise<void> {
|
|
|
|
|
try {
|
|
|
|
|
// Enable debug mode if requested
|
|
|
|
@@ -144,7 +183,10 @@ WantedBy=multi-user.target
|
|
|
|
|
this.daemon.getNupstSnmp().enableDebug();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if config exists first
|
|
|
|
|
// Display version and update status first
|
|
|
|
|
await this.displayVersionInfo();
|
|
|
|
|
|
|
|
|
|
// Check if config exists
|
|
|
|
|
try {
|
|
|
|
|
await this.checkConfigExists();
|
|
|
|
|
} catch (error) {
|
|
|
|
|