feat(cli): Add initial MOXYTOOL implementation, packaging, install/uninstall scripts, CI and release workflows
This commit is contained in:
112
ts/moxytool.cli.ts
Normal file
112
ts/moxytool.cli.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import * as plugins from './moxytool.plugins.ts';
|
||||
import * as paths from './moxytool.paths.ts';
|
||||
import { logger } from './moxytool.logging.ts';
|
||||
|
||||
export const runCli = async () => {
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
|
||||
const smartcliInstance = new plugins.smartcli.Smartcli();
|
||||
|
||||
// Standard command (no arguments)
|
||||
smartcliInstance.standardCommand().subscribe(async () => {
|
||||
logger.log('info', 'MOXYTOOL - Proxmox Administration Tool');
|
||||
logger.log('info', '');
|
||||
logger.log('info', 'Available commands:');
|
||||
logger.log('info', '* vgpu-setup - Install and configure Proxmox vGPU support');
|
||||
logger.log('info', '');
|
||||
logger.log('info', 'Usage: moxytool <command> [options]');
|
||||
});
|
||||
|
||||
// vGPU setup command
|
||||
smartcliInstance.addCommand('vgpu-setup').subscribe(async (argvArg) => {
|
||||
logger.log('ok', 'Starting Proxmox vGPU setup process');
|
||||
logger.log('info', 'This will install vGPU support for NVIDIA GPUs on Proxmox');
|
||||
logger.log('info', '');
|
||||
|
||||
// Check for arguments
|
||||
const step = argvArg.step;
|
||||
const url = argvArg.url;
|
||||
const file = argvArg.file;
|
||||
const debug = argvArg.debug;
|
||||
|
||||
// Check if running on Proxmox
|
||||
try {
|
||||
const result = await smartshellInstance.exec('which pveversion');
|
||||
if (result.exitCode !== 0) {
|
||||
logger.log('error', 'This system does not appear to be running Proxmox');
|
||||
logger.log('error', 'Please run this command on a Proxmox host');
|
||||
Deno.exit(1);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.log('error', 'Failed to verify Proxmox installation');
|
||||
logger.log('error', 'Please ensure you are running this on a Proxmox host');
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
// Create temporary directory
|
||||
const tmpDir = '/tmp/moxytool-vgpu-setup';
|
||||
await smartshellInstance.exec(`mkdir -p ${tmpDir}`);
|
||||
|
||||
try {
|
||||
// Step 1: Clone and run the installer script
|
||||
logger.log('info', 'Step 1: Downloading Proxmox vGPU installer (supports v9)...');
|
||||
const cloneResult = await smartshellInstance.exec(
|
||||
`cd ${tmpDir} && git clone https://github.com/anomixer/proxmox-vgpu-installer.git`,
|
||||
);
|
||||
|
||||
if (cloneResult.exitCode !== 0) {
|
||||
logger.log('error', 'Failed to clone the installer repository');
|
||||
logger.log('error', cloneResult.stderr || 'Unknown error');
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
logger.log('ok', 'Installer downloaded successfully');
|
||||
logger.log('info', '');
|
||||
|
||||
// Build command with arguments
|
||||
let command = 'bash proxmox-installer.sh';
|
||||
if (step) {
|
||||
command += ` --step ${step}`;
|
||||
}
|
||||
if (url) {
|
||||
command += ` --url ${url}`;
|
||||
}
|
||||
if (file) {
|
||||
command += ` --file ${file}`;
|
||||
}
|
||||
if (debug) {
|
||||
command += ' --debug';
|
||||
}
|
||||
|
||||
logger.log('info', 'Running installer script...');
|
||||
logger.log('info', 'Please follow the interactive prompts');
|
||||
logger.log('info', '');
|
||||
|
||||
// Run the installer script interactively
|
||||
const installResult = await smartshellInstance.exec(
|
||||
`cd ${tmpDir}/proxmox-vgpu-installer && ${command}`,
|
||||
);
|
||||
|
||||
if (installResult.exitCode !== 0) {
|
||||
logger.log('error', 'Installer script failed');
|
||||
logger.log('error', installResult.stderr || 'Unknown error');
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
logger.log('ok', 'vGPU setup process completed');
|
||||
logger.log('info', '');
|
||||
logger.log('info', 'Next steps:');
|
||||
logger.log('info', '1. If prompted, reboot your system');
|
||||
logger.log('info', '2. After reboot, run this command again to continue setup');
|
||||
logger.log('info', '3. Verify installation with: mdevctl types');
|
||||
logger.log('info', '4. Configure your VMs with vGPU in the Proxmox web UI');
|
||||
} catch (error) {
|
||||
logger.log('error', `Setup failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||
Deno.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
smartcliInstance.startParse();
|
||||
};
|
||||
Reference in New Issue
Block a user