mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update AppImage
This commit is contained in:
@@ -1,37 +1,69 @@
|
|||||||
import { NextResponse } from "next/server"
|
import { NextResponse } from "next/server"
|
||||||
import { exec } from "child_process"
|
|
||||||
import { promisify } from "util"
|
|
||||||
|
|
||||||
const execAsync = promisify(exec)
|
|
||||||
|
|
||||||
export async function POST() {
|
export async function POST() {
|
||||||
try {
|
try {
|
||||||
const scriptPath = "/usr/local/share/proxmenux/scripts/gpu_tpu/nvidia_installer.sh"
|
// Port 8008 is the production port for Flask server
|
||||||
const webLogPath = "/tmp/nvidia_web_install.log"
|
const API_PORT = "8008"
|
||||||
|
|
||||||
const { stdout, stderr } = await execAsync(`EXECUTION_MODE=web WEB_LOG=${webLogPath} bash ${scriptPath}`, {
|
// Use window.location from request headers to detect proxy
|
||||||
env: {
|
let flaskUrl: string
|
||||||
...process.env,
|
|
||||||
EXECUTION_MODE: "web",
|
// For server-side execution, use localhost
|
||||||
WEB_LOG: webLogPath,
|
// In production, the request will come with proper headers
|
||||||
|
if (typeof window === "undefined") {
|
||||||
|
flaskUrl = `http://localhost:${API_PORT}/api/scripts/execute`
|
||||||
|
} else {
|
||||||
|
const { protocol, hostname, port } = window.location
|
||||||
|
const isStandardPort = port === "" || port === "80" || port === "443"
|
||||||
|
|
||||||
|
if (isStandardPort) {
|
||||||
|
// Behind proxy - use relative URL
|
||||||
|
flaskUrl = "/api/scripts/execute"
|
||||||
|
} else {
|
||||||
|
// Direct access
|
||||||
|
flaskUrl = `${protocol}//${hostname}:${API_PORT}/api/scripts/execute`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("[v0] Starting NVIDIA driver installation via:", flaskUrl)
|
||||||
|
|
||||||
|
const response = await fetch(flaskUrl, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
maxBuffer: 10 * 1024 * 1024, // 10MB buffer
|
body: JSON.stringify({
|
||||||
|
script_path: "/usr/local/share/proxmenux/scripts/gpu_tpu/nvidia_installer.sh",
|
||||||
|
env: {
|
||||||
|
EXECUTION_MODE: "web",
|
||||||
|
WEB_LOG: "/tmp/nvidia_web_install.log",
|
||||||
|
},
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Flask API error: ${response.statusText}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
|
||||||
|
if (!data.success) {
|
||||||
|
throw new Error(data.error || "Failed to start installation")
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("[v0] NVIDIA installation started, session_id:", data.session_id)
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "NVIDIA drivers installation completed",
|
session_id: data.session_id,
|
||||||
output: stdout,
|
message: "NVIDIA installation started",
|
||||||
log_file: webLogPath,
|
|
||||||
})
|
})
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("[v0] NVIDIA installation error:", error)
|
console.error("[v0] NVIDIA installation error:", error)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message || "Installation failed",
|
error: error.message || "Failed to start NVIDIA driver installation. Please try manually.",
|
||||||
output: error.stdout || "",
|
|
||||||
stderr: error.stderr || "",
|
|
||||||
},
|
},
|
||||||
{ status: 500 },
|
{ status: 500 },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
* Can be changed to 8009 for beta testing
|
* Can be changed to 8009 for beta testing
|
||||||
* This can also be set via NEXT_PUBLIC_API_PORT environment variable
|
* This can also be set via NEXT_PUBLIC_API_PORT environment variable
|
||||||
*/
|
*/
|
||||||
export const API_PORT = process.env.NEXT_PUBLIC_API_PORT || "8009"
|
export const API_PORT = process.env.NEXT_PUBLIC_API_PORT || "8008"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the base URL for API calls
|
* Gets the base URL for API calls
|
||||||
|
|||||||
@@ -6436,4 +6436,4 @@ if __name__ == '__main__':
|
|||||||
# Print only essential information
|
# Print only essential information
|
||||||
# print("API endpoints available at: /api/system, /api/system-info, /api/storage, /api/proxmox-storage, /api/network, /api/vms, /api/logs, /api/health, /api/hardware, /api/prometheus, /api/node/metrics")
|
# print("API endpoints available at: /api/system, /api/system-info, /api/storage, /api/proxmox-storage, /api/network, /api/vms, /api/logs, /api/health, /api/hardware, /api/prometheus, /api/node/metrics")
|
||||||
|
|
||||||
app.run(host='0.0.0.0', port=8009, debug=False)
|
app.run(host='0.0.0.0', port=8008, debug=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user