feat(v2.3.1): velocidad de descarga en MB/s en tiempo real
Calcula delta de bytes entre cada tick del loop (0.3 s) y lo convierte a MB/s con un decimal via awk. Se muestra en la misma línea de progreso: → [########------------] 42% (1823 de 4340 MB) 23.5 MB/s Sin Content-Length: "1247 MB 23.5 MB/s" Al completar: muestra tamaño final sin velocidad (limpia la línea). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b0e56f127f
commit
055d099363
+12
-5
@@ -5,7 +5,7 @@
|
|||||||
# Autor: Lic. Ricardo MONLA
|
# Autor: Lic. Ricardo MONLA
|
||||||
# Email: rmonla@gmail.com
|
# Email: rmonla@gmail.com
|
||||||
# GitHub: https://github.com/ricardomonla/rm-MULTIBOOT
|
# GitHub: https://github.com/ricardomonla/rm-MULTIBOOT
|
||||||
# Versión: 2.3.0
|
# Versión: 2.3.1
|
||||||
# Licencia: MIT
|
# Licencia: MIT
|
||||||
#
|
#
|
||||||
# Uso: sudo ./rm-multiboot.sh
|
# Uso: sudo ./rm-multiboot.sh
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# ─── Constantes ───────────────────────────────────────────────────────────────
|
# ─── Constantes ───────────────────────────────────────────────────────────────
|
||||||
readonly SCRIPT_VERSION="2.3.0"
|
readonly SCRIPT_VERSION="2.3.1"
|
||||||
readonly SCRIPT_AUTHOR="Lic. Ricardo MONLA"
|
readonly SCRIPT_AUTHOR="Lic. Ricardo MONLA"
|
||||||
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
readonly ISOS_CONF="$SCRIPT_DIR/isos.conf"
|
readonly ISOS_CONF="$SCRIPT_DIR/isos.conf"
|
||||||
@@ -453,21 +453,28 @@ download_with_progress() {
|
|||||||
|
|
||||||
# Loop de progreso
|
# Loop de progreso
|
||||||
local done_b pct done_mb total_mb filled empty bar
|
local done_b pct done_mb total_mb filled empty bar
|
||||||
|
local prev_bytes=0 speed_str="0.0"
|
||||||
while kill -0 "$dl_pid" 2>/dev/null; do
|
while kill -0 "$dl_pid" 2>/dev/null; do
|
||||||
done_b=0
|
done_b=0
|
||||||
[[ -f "$dest" ]] && done_b=$(stat -c%s "$dest" 2>/dev/null || echo 0)
|
[[ -f "$dest" ]] && done_b=$(stat -c%s "$dest" 2>/dev/null || echo 0)
|
||||||
done_mb=$(( done_b / 1024 / 1024 ))
|
done_mb=$(( done_b / 1024 / 1024 ))
|
||||||
|
|
||||||
|
# Velocidad: bytes descargados en el último intervalo (0.3 s) → MB/s
|
||||||
|
local delta=$(( done_b - prev_bytes ))
|
||||||
|
[[ $delta -gt 0 ]] && \
|
||||||
|
speed_str=$(awk "BEGIN {printf \"%.1f\", $delta / 0.3 / 1048576}")
|
||||||
|
prev_bytes=$done_b
|
||||||
|
|
||||||
if [[ "$total_bytes" -gt 0 ]]; then
|
if [[ "$total_bytes" -gt 0 ]]; then
|
||||||
pct=$(( done_b * 100 / total_bytes ))
|
pct=$(( done_b * 100 / total_bytes ))
|
||||||
total_mb=$(( total_bytes / 1024 / 1024 ))
|
total_mb=$(( total_bytes / 1024 / 1024 ))
|
||||||
filled=$(( pct * 20 / 100 ))
|
filled=$(( pct * 20 / 100 ))
|
||||||
empty=$(( 20 - filled ))
|
empty=$(( 20 - filled ))
|
||||||
bar=$(printf '%0.s#' $(seq 1 "$filled"))$(printf '%0.s-' $(seq 1 "$empty"))
|
bar=$(printf '%0.s#' $(seq 1 "$filled"))$(printf '%0.s-' $(seq 1 "$empty"))
|
||||||
printf "\r ${C}→${N} [%-20s] %3d%% (%d MB de %d MB)" \
|
printf "\r ${C}→${N} [%-20s] %3d%% (%d de %d MB) %s MB/s " \
|
||||||
"$bar" "$pct" "$done_mb" "$total_mb"
|
"$bar" "$pct" "$done_mb" "$total_mb" "$speed_str"
|
||||||
else
|
else
|
||||||
printf "\r ${C}→${N} %d MB descargados..." "$done_mb"
|
printf "\r ${C}→${N} %d MB %s MB/s " "$done_mb" "$speed_str"
|
||||||
fi
|
fi
|
||||||
sleep 0.3
|
sleep 0.3
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user