fix: chemin complet /usr/sbin/pct pour les sessions SSH non-interactives

pct n'est pas dans le PATH SSH par défaut (exit 127).
Corrigé dans GetPackages, GetTargets et executeUpdate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
enzo 2026-03-21 01:23:29 +01:00
parent 8019b1475d
commit 8ff6fb0e8c

View file

@ -77,7 +77,7 @@ func (h *UpdatesHandler) GetTargets(w http.ResponseWriter, r *http.Request) {
{ID: "host", Name: "Proxmox Host", Status: "running"}, {ID: "host", Name: "Proxmox Host", Status: "running"},
} }
output, err := h.sshPool.RunCommand(sshHost, sshUser, sshPass, "pct list 2>/dev/null") output, err := h.sshPool.RunCommand(sshHost, sshUser, sshPass, "/usr/sbin/pct list 2>/dev/null")
if err == nil { if err == nil {
for _, line := range strings.Split(output, "\n") { for _, line := range strings.Split(output, "\n") {
line = strings.TrimSpace(line) line = strings.TrimSpace(line)
@ -130,7 +130,7 @@ func (h *UpdatesHandler) GetPackages(w http.ResponseWriter, r *http.Request) {
command = "apt list --upgradable 2>/dev/null" command = "apt list --upgradable 2>/dev/null"
case len(target) > 4 && target[:4] == "lxc:": case len(target) > 4 && target[:4] == "lxc:":
lxcID := target[4:] lxcID := target[4:]
command = fmt.Sprintf("pct exec %s -- apt list --upgradable 2>/dev/null", lxcID) command = fmt.Sprintf("/usr/sbin/pct exec %s -- apt list --upgradable 2>/dev/null", lxcID)
default: default:
JSONError(w, "Cible invalide", http.StatusBadRequest) JSONError(w, "Cible invalide", http.StatusBadRequest)
return return
@ -289,14 +289,14 @@ func (h *UpdatesHandler) executeUpdate(jobID, target, sshHost, sshUser, sshPass
case len(target) > 4 && target[:4] == "lxc:": case len(target) > 4 && target[:4] == "lxc:":
lxcID := target[4:] lxcID := target[4:]
command = fmt.Sprintf( command = fmt.Sprintf(
"pct exec %s -- bash -c 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y'", "/usr/sbin/pct exec %s -- bash -c 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y'",
lxcID, lxcID,
) )
case target == "all": case target == "all":
command = `for ct in $(pct list | awk 'NR>1 {print $1}'); do command = `for ct in $(/usr/sbin/pct list | awk 'NR>1 {print $1}'); do
echo "=== LXC $ct ===" echo "=== LXC $ct ==="
pct exec $ct -- bash -c 'DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y' 2>/dev/null || echo "SKIP LXC $ct" /usr/sbin/pct exec $ct -- bash -c 'DEBIAN_FRONTEND=noninteractive apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y' 2>/dev/null || echo "SKIP LXC $ct"
done` done`
default: default: