From f7f72055164ef2bb4dacd6135472fe105722f5a2 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Sat, 30 Aug 2008 13:38:17 +0200 Subject: [PATCH] sde-download: Enhanced mirror test to use KB/s or MB/s when proper --- lib/sde-download/mirror-test.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/sde-download/mirror-test.sh b/lib/sde-download/mirror-test.sh index 5cdb7a2..cf01ad5 100644 --- a/lib/sde-download/mirror-test.sh +++ b/lib/sde-download/mirror-test.sh @@ -19,6 +19,8 @@ maxspeed=0 mirror= . $SDEROOT/lib/libsde.in +DC="$( type -p dc )" + OLDIFS="$IFS" IFS=":" while read name country admin url ; do # translate $country @@ -42,7 +44,14 @@ while read name country admin url ; do if [ "${speed:-0}" = "0" ]; then echo ' failed' 1>&2 else - echo " $speed B/s" 1>&2 + if [ -z "$DC" -o $speed -lt 4096 ]; then + echo " $speed B/s" 1>&2 + elif [ $speed -lt 1048576 ]; then + echo " $($DC -e "2k $speed 1024 / p" ) KB/s" 1>&2 + else + echo " $($DC -e "2k $speed 1048576 / p" ) MB/s" 1>&2 + fi + # and make a choice if [ "$speed" -gt "$maxspeed" ]; then maxspeed="$speed"; mirror="$url"