Files
ProxMenux/AppImage/app/api/gpu/nvidia/install/route.ts

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-11-30 19:15:07 +01:00
import { NextResponse } from "next/server"
2025-11-30 19:40:42 +01:00
import { exec } from "child_process"
import { promisify } from "util"
const execAsync = promisify(exec)
2025-11-30 19:15:07 +01:00
export async function POST() {
try {
2025-11-30 19:40:42 +01:00
const scriptPath = "/usr/local/share/proxmenux/scripts/gpu_tpu/nvidia_installer.sh"
const webLogPath = "/tmp/nvidia_web_install.log"
const { stdout, stderr } = await execAsync(`EXECUTION_MODE=web WEB_LOG=${webLogPath} bash ${scriptPath}`, {
2025-11-30 19:15:07 +01:00
env: {
2025-11-30 19:40:42 +01:00
...process.env,
2025-11-30 19:15:07 +01:00
EXECUTION_MODE: "web",
2025-11-30 19:40:42 +01:00
WEB_LOG: webLogPath,
2025-11-30 19:15:07 +01:00
},
2025-11-30 19:40:42 +01:00
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
2025-11-30 19:15:07 +01:00
})
2025-11-30 19:40:42 +01:00
return NextResponse.json({
success: true,
message: "NVIDIA drivers installation completed",
output: stdout,
log_file: webLogPath,
})
} catch (error: any) {
console.error("[v0] NVIDIA installation error:", error)
2025-11-30 19:15:07 +01:00
return NextResponse.json(
{
success: false,
2025-11-30 19:40:42 +01:00
error: error.message || "Installation failed",
output: error.stdout || "",
stderr: error.stderr || "",
2025-11-30 19:15:07 +01:00
},
{ status: 500 },
)
}
}