feat: Show download percentage (#55)
This commit is contained in:
parent
576682cda1
commit
e68fd18886
3 changed files with 9 additions and 5 deletions
|
@ -35,9 +35,7 @@ fi
|
||||||
# Check available memory as the very last step
|
# Check available memory as the very last step
|
||||||
|
|
||||||
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
RAM_AVAIL=$(free -b | grep -m 1 Mem: | awk '{print $7}')
|
||||||
RAM_TOTAL=$(free -b | grep -m 1 Mem: | awk '{print $2}')
|
|
||||||
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
AVAIL_GB=$(( (RAM_AVAIL + 1073741823)/1073741824 ))
|
||||||
TOTAL_GB=$(( (RAM_TOTAL + 1073741823)/1073741824 ))
|
|
||||||
|
|
||||||
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
if (( (RAM_WANTED + 500000000) > RAM_AVAIL )); then
|
||||||
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
error "Your configured RAM_SIZE of $WANTED_GB GB is higher than the $AVAIL_GB GB of memory available, please set a lower value."
|
||||||
|
|
|
@ -31,7 +31,7 @@ rm -f "$TMP"
|
||||||
MSG="Downloading $BASE..."
|
MSG="Downloading $BASE..."
|
||||||
info "$MSG" && html "$MSG"
|
info "$MSG" && html "$MSG"
|
||||||
|
|
||||||
/run/progress.sh "$TMP" "Downloading $BASE ([P])..." &
|
/run/progress.sh "$TMP" "" "Downloading $BASE ([P])..." &
|
||||||
{ wget "$BOOT" -O "$TMP" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
|
{ wget "$BOOT" -O "$TMP" -q --no-check-certificate --show-progress "$PROGRESS"; rc=$?; } || :
|
||||||
|
|
||||||
fKill "progress.sh"
|
fKill "progress.sh"
|
||||||
|
|
|
@ -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" ] || [[ "$total" == "0" ]]; 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…
Reference in a new issue