Commits

Rémy HUBSCHER committed 42ec5a6

Version initiale du fichier

  • Participants

Comments (0)

Files changed (1)

calcul_progression_pcent.sh

+#!/bin/bash
+
+#
+# Script permettant de calculer le temps restant et la vitesse de copie
+#
+# FINAL contient la taille totale que doit avoir le répertoire à la
+# fin de la copie
+#
+
+COUNT=0
+INIT=$(du -s . | cut -f1)
+FINAL=38168166
+DURATION=2
+for (( ; ; ))
+do
+    CURRENT=$(du -s . | cut -f1)
+    VAR=$(echo "$CURRENT * 100 / $FINAL" | bc -l)
+
+    if [ $COUNT -gt 5 ]; then
+	SPEED=$(echo "($CURRENT - $INIT) / ($COUNT * $DURATION)" | bc -l)
+	UNIT="KB/s"
+	CSPEED=$(echo "${SPEED:0:6} $UNIT")
+
+	ETA=$(echo "($FINAL - $CURRENT) / ($SPEED)" | bc -l)
+	HOUR=$(echo "$ETA / 3600" | bc)
+	MIN=$(echo "($ETA - ($HOUR * 3600)) / 60" | bc)
+	SEC=$(echo "($ETA - ($HOUR * 3600) -($MIN * 60))" | bc -l)
+	CETA=$(echo "ETA : [$HOUR:$MIN:${SEC:0:4}]")
+
+	if [ "$SPEED > 1024" ]; then
+	    SPEED=$(echo "$SPEED / 1024" | bc -l)
+	    UNIT="MB/s"
+	    CSPEED=$(echo "${SPEED:0:4} $UNIT")
+	fi
+    fi
+
+    echo -en "\r$PWD - $COUNT\t${VAR:0:6}%" $(du -sh . | cut -f1) $CSPEED $CETA
+    sleep $DURATION
+    COUNT=$(expr $COUNT + 1)
+done