fix: descargar a /tmp primero para evitar error 23 en contenedores

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-25 09:17:59 -05:00
co-authored by Claude Sonnet 4.6
parent 2ff4d314de
commit 00d1e6121b
+10 -6
View File
@@ -84,22 +84,26 @@ fi
info "Descargando agente desde ${DOWNLOAD_URL}..."
DEST="${INSTALL_DIR}/usite-agent"
TMP_DEST="/tmp/usite-agent-download-$$"
if command -v curl &>/dev/null; then
HTTP_CODE=$(curl -fsSL --write-out "%{http_code}" "$DOWNLOAD_URL" -o "$DEST" 2>/tmp/curl_err) || {
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DEST" 2>/tmp/curl_err || {
CURL_ERR=$(cat /tmp/curl_err 2>/dev/null)
error "No se pudo descargar (HTTP ${HTTP_CODE:-?}). ${CURL_ERR}\nVerifica: df -h ${INSTALL_DIR}"
rm -f "$TMP_DEST"
error "No se pudo descargar: ${CURL_ERR}"
}
elif command -v wget &>/dev/null; then
wget -q "$DOWNLOAD_URL" -O "$DEST" || error "No se pudo descargar con wget"
wget -q "$DOWNLOAD_URL" -O "$TMP_DEST" || { rm -f "$TMP_DEST"; error "No se pudo descargar con wget"; }
else
error "Se requiere curl o wget"
fi
# Verificar que el binario es un ejecutable válido
if [[ ! -s "$DEST" ]]; then
error "El archivo descargado está vacío: ${DEST}"
if [[ ! -s "$TMP_DEST" ]]; then
rm -f "$TMP_DEST"
error "El archivo descargado está vacío"
fi
mv "$TMP_DEST" "$DEST" || { cp "$TMP_DEST" "$DEST" && rm -f "$TMP_DEST"; } || error "No se pudo mover el binario a ${DEST}"
chmod +x "$DEST"
ok "Binario descargado ($(du -sh "$DEST" | cut -f1))"