mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-09 01:47:32 +08:00
Update progress.sh
This commit is contained in:
parent
c4a0035062
commit
5ccfca750e
@ -12,7 +12,8 @@ escape () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
file="$1"
|
file="$1"
|
||||||
body=$(escape "$2")
|
total="$2"
|
||||||
|
body=$(escape "$3")
|
||||||
info="/run/shm/msg.html"
|
info="/run/shm/msg.html"
|
||||||
|
|
||||||
if [[ "$body" == *"..." ]]; then
|
if [[ "$body" == *"..." ]]; then
|
||||||
@ -24,7 +25,12 @@ do
|
|||||||
if [ -s "$file" ]; then
|
if [ -s "$file" ]; then
|
||||||
bytes=$(du -sb "$file" | cut -f1)
|
bytes=$(du -sb "$file" | cut -f1)
|
||||||
if (( bytes > 1000 )); then
|
if (( bytes > 1000 )); then
|
||||||
size=$(echo "$bytes" | numfmt --to=iec --suffix=B | sed -r 's/([A-Z])/ \1/')
|
if [ -z "$total" ]; then
|
||||||
|
size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/')
|
||||||
|
else
|
||||||
|
size=$(printf '%.1f\n' "$((bytes*100*100/total))e-2")
|
||||||
|
size="$size%"
|
||||||
|
fi
|
||||||
echo "${body//(\[P\])/($size)}"> "$info"
|
echo "${body//(\[P\])/($size)}"> "$info"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user