fix: readme
All checks were successful
Release / release (push) Successful in 26s

This commit is contained in:
2026-03-17 14:26:49 +01:00
parent f30d75141d
commit 13457ceb5a
3 changed files with 46 additions and 20 deletions

View File

@@ -1,33 +1,43 @@
import { exec } from "child_process"
type DiskSource = {
key: string
key: "remote" | "local"
label: string
command: string
args?: string[]
}
const diskSources: DiskSource[] = [
{
key: "remote",
label: "Serveur distant",
command: "ssh",
args: []
label: "Serveur distant"
},
{
key: "local",
label: "Machine locale",
command: "bash",
args: []
label: "Machine locale"
}
]
function getDefaultCommand(source: DiskSource) {
const localScriptDir = process.env.DISK_LOCAL_SCRIPT_DIR || "/home/malio/Malio-ops/CheckStorage"
const remoteHost = process.env.DISK_REMOTE_HOST || "malio-b"
const remoteScriptDir = process.env.DISK_REMOTE_SCRIPT_DIR || "/home/malio-b/Malio-ops/CheckStorage"
if (source.key === "local") {
return `cd ${localScriptDir} && bash check-storage.sh`
}
return `ssh ${remoteHost} "cd ${remoteScriptDir} && ./check-storage.sh"`
}
function getEnvCommand(source: DiskSource) {
const envKey = `DISK_COMMAND_${source.key.toUpperCase()}`
const legacyEnvKey =
source.key === "remote" ? "DISK_REMOTE_COMMAND" : source.key === "local" ? "DISK_LOCAL_COMMAND" : ""
return process.env[envKey] || (legacyEnvKey ? process.env[legacyEnvKey] : undefined) || null
return (
process.env[envKey] ||
(legacyEnvKey ? process.env[legacyEnvKey] : undefined) ||
getDefaultCommand(source)
)
}
function runShellCommand(command: string): Promise<string> {